blob: b8c689202c4041c4e22dc63d7415ffb2232e94a9 [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
Chris Wilsonf13d3f72010-09-20 17:36:15 +010043enum {
Chris Wilson69dc4982010-10-19 10:36:51 +010044 ACTIVE_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010045 INACTIVE_LIST,
Chris Wilsond21d5972010-09-26 11:19:33 +010046 PINNED_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010047};
Ben Gamari433e12f2009-02-17 20:08:51 -050048
Chris Wilson70d39fe2010-08-25 16:03:34 +010049static const char *yesno(int v)
50{
51 return v ? "yes" : "no";
52}
53
Damien Lespiau497666d2013-10-15 18:55:39 +010054/* As the drm_debugfs_init() routines are called before dev->dev_private is
55 * allocated we need to hook into the minor for release. */
56static int
57drm_add_fake_info_node(struct drm_minor *minor,
58 struct dentry *ent,
59 const void *key)
60{
61 struct drm_info_node *node;
62
63 node = kmalloc(sizeof(*node), GFP_KERNEL);
64 if (node == NULL) {
65 debugfs_remove(ent);
66 return -ENOMEM;
67 }
68
69 node->minor = minor;
70 node->dent = ent;
71 node->info_ent = (void *) key;
72
73 mutex_lock(&minor->debugfs_lock);
74 list_add(&node->list, &minor->debugfs_list);
75 mutex_unlock(&minor->debugfs_lock);
76
77 return 0;
78}
79
Chris Wilson70d39fe2010-08-25 16:03:34 +010080static int i915_capabilities(struct seq_file *m, void *data)
81{
Damien Lespiau9f25d002014-05-13 15:30:28 +010082 struct drm_info_node *node = m->private;
Chris Wilson70d39fe2010-08-25 16:03:34 +010083 struct drm_device *dev = node->minor->dev;
84 const struct intel_device_info *info = INTEL_INFO(dev);
85
86 seq_printf(m, "gen: %d\n", info->gen);
Paulo Zanoni03d00ac2011-10-14 18:17:41 -030087 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
Damien Lespiau79fc46d2013-04-23 16:37:17 +010088#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
89#define SEP_SEMICOLON ;
90 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
91#undef PRINT_FLAG
92#undef SEP_SEMICOLON
Chris Wilson70d39fe2010-08-25 16:03:34 +010093
94 return 0;
95}
Ben Gamari433e12f2009-02-17 20:08:51 -050096
Chris Wilson05394f32010-11-08 19:18:58 +000097static const char *get_pin_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000098{
Chris Wilson05394f32010-11-08 19:18:58 +000099 if (obj->user_pin_count > 0)
Chris Wilsona6172a82009-02-11 14:26:38 +0000100 return "P";
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800101 else if (i915_gem_obj_is_pinned(obj))
Chris Wilsona6172a82009-02-11 14:26:38 +0000102 return "p";
103 else
104 return " ";
105}
106
Chris Wilson05394f32010-11-08 19:18:58 +0000107static const char *get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +0000108{
Akshay Joshi0206e352011-08-16 15:34:10 -0400109 switch (obj->tiling_mode) {
110 default:
111 case I915_TILING_NONE: return " ";
112 case I915_TILING_X: return "X";
113 case I915_TILING_Y: return "Y";
114 }
Chris Wilsona6172a82009-02-11 14:26:38 +0000115}
116
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700117static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
118{
119 return obj->has_global_gtt_mapping ? "g" : " ";
120}
121
Chris Wilson37811fc2010-08-25 22:45:57 +0100122static void
123describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
124{
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700125 struct i915_vma *vma;
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800126 int pin_count = 0;
127
Ville Syrjäläfb1ae912013-08-22 19:21:30 +0300128 seq_printf(m, "%pK: %s%s%s %8zdKiB %02x %02x %u %u %u%s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100129 &obj->base,
130 get_pin_flag(obj),
131 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700132 get_global_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800133 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100134 obj->base.read_domains,
135 obj->base.write_domain,
Chris Wilson0201f1e2012-07-20 12:41:01 +0100136 obj->last_read_seqno,
137 obj->last_write_seqno,
Chris Wilsoncaea7472010-11-12 13:53:37 +0000138 obj->last_fenced_seqno,
Mika Kuoppala84734a02013-07-12 16:50:57 +0300139 i915_cache_level_str(obj->cache_level),
Chris Wilson37811fc2010-08-25 22:45:57 +0100140 obj->dirty ? " dirty" : "",
141 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
142 if (obj->base.name)
143 seq_printf(m, " (name: %d)", obj->base.name);
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800144 list_for_each_entry(vma, &obj->vma_list, vma_link)
145 if (vma->pin_count > 0)
146 pin_count++;
147 seq_printf(m, " (pinned x %d)", pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100148 if (obj->pin_display)
149 seq_printf(m, " (display)");
Chris Wilson37811fc2010-08-25 22:45:57 +0100150 if (obj->fence_reg != I915_FENCE_REG_NONE)
151 seq_printf(m, " (fence: %d)", obj->fence_reg);
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700152 list_for_each_entry(vma, &obj->vma_list, vma_link) {
153 if (!i915_is_ggtt(vma->vm))
154 seq_puts(m, " (pp");
155 else
156 seq_puts(m, " (g");
157 seq_printf(m, "gtt offset: %08lx, size: %08lx)",
158 vma->node.start, vma->node.size);
159 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000160 if (obj->stolen)
161 seq_printf(m, " (stolen: %08lx)", obj->stolen->start);
Chris Wilson6299f992010-11-24 12:23:44 +0000162 if (obj->pin_mappable || obj->fault_mappable) {
163 char s[3], *t = s;
164 if (obj->pin_mappable)
165 *t++ = 'p';
166 if (obj->fault_mappable)
167 *t++ = 'f';
168 *t = '\0';
169 seq_printf(m, " (%s mappable)", s);
170 }
Chris Wilson69dc4982010-10-19 10:36:51 +0100171 if (obj->ring != NULL)
172 seq_printf(m, " (%s)", obj->ring->name);
Chris Wilson37811fc2010-08-25 22:45:57 +0100173}
174
Oscar Mateo273497e2014-05-22 14:13:37 +0100175static void describe_ctx(struct seq_file *m, struct intel_context *ctx)
Ben Widawsky3ccfd192013-09-18 19:03:18 -0700176{
177 seq_putc(m, ctx->is_initialized ? 'I' : 'i');
178 seq_putc(m, ctx->remap_slice ? 'R' : 'r');
179 seq_putc(m, ' ');
180}
181
Ben Gamari433e12f2009-02-17 20:08:51 -0500182static int i915_gem_object_list_info(struct seq_file *m, void *data)
Ben Gamari20172632009-02-17 20:08:50 -0500183{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100184 struct drm_info_node *node = m->private;
Ben Gamari433e12f2009-02-17 20:08:51 -0500185 uintptr_t list = (uintptr_t) node->info_ent->data;
186 struct list_head *head;
Ben Gamari20172632009-02-17 20:08:50 -0500187 struct drm_device *dev = node->minor->dev;
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700188 struct drm_i915_private *dev_priv = dev->dev_private;
189 struct i915_address_space *vm = &dev_priv->gtt.base;
Ben Widawskyca191b12013-07-31 17:00:14 -0700190 struct i915_vma *vma;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100191 size_t total_obj_size, total_gtt_size;
192 int count, ret;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100193
194 ret = mutex_lock_interruptible(&dev->struct_mutex);
195 if (ret)
196 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500197
Ben Widawskyca191b12013-07-31 17:00:14 -0700198 /* FIXME: the user of this interface might want more than just GGTT */
Ben Gamari433e12f2009-02-17 20:08:51 -0500199 switch (list) {
200 case ACTIVE_LIST:
Damien Lespiau267f0c92013-06-24 22:59:48 +0100201 seq_puts(m, "Active:\n");
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700202 head = &vm->active_list;
Ben Gamari433e12f2009-02-17 20:08:51 -0500203 break;
204 case INACTIVE_LIST:
Damien Lespiau267f0c92013-06-24 22:59:48 +0100205 seq_puts(m, "Inactive:\n");
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700206 head = &vm->inactive_list;
Ben Gamari433e12f2009-02-17 20:08:51 -0500207 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500208 default:
Chris Wilsonde227ef2010-07-03 07:58:38 +0100209 mutex_unlock(&dev->struct_mutex);
210 return -EINVAL;
Ben Gamari433e12f2009-02-17 20:08:51 -0500211 }
212
Chris Wilson8f2480f2010-09-26 11:44:19 +0100213 total_obj_size = total_gtt_size = count = 0;
Ben Widawskyca191b12013-07-31 17:00:14 -0700214 list_for_each_entry(vma, head, mm_list) {
215 seq_printf(m, " ");
216 describe_obj(m, vma->obj);
217 seq_printf(m, "\n");
218 total_obj_size += vma->obj->base.size;
219 total_gtt_size += vma->node.size;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100220 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500221 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100222 mutex_unlock(&dev->struct_mutex);
Carl Worth5e118f42009-03-20 11:54:25 -0700223
Chris Wilson8f2480f2010-09-26 11:44:19 +0100224 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
225 count, total_obj_size, total_gtt_size);
Ben Gamari20172632009-02-17 20:08:50 -0500226 return 0;
227}
228
Chris Wilson6d2b8882013-08-07 18:30:54 +0100229static int obj_rank_by_stolen(void *priv,
230 struct list_head *A, struct list_head *B)
231{
232 struct drm_i915_gem_object *a =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200233 container_of(A, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100234 struct drm_i915_gem_object *b =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200235 container_of(B, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100236
237 return a->stolen->start - b->stolen->start;
238}
239
240static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
241{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100242 struct drm_info_node *node = m->private;
Chris Wilson6d2b8882013-08-07 18:30:54 +0100243 struct drm_device *dev = node->minor->dev;
244 struct drm_i915_private *dev_priv = dev->dev_private;
245 struct drm_i915_gem_object *obj;
246 size_t total_obj_size, total_gtt_size;
247 LIST_HEAD(stolen);
248 int count, ret;
249
250 ret = mutex_lock_interruptible(&dev->struct_mutex);
251 if (ret)
252 return ret;
253
254 total_obj_size = total_gtt_size = count = 0;
255 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
256 if (obj->stolen == NULL)
257 continue;
258
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200259 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100260
261 total_obj_size += obj->base.size;
262 total_gtt_size += i915_gem_obj_ggtt_size(obj);
263 count++;
264 }
265 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
266 if (obj->stolen == NULL)
267 continue;
268
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200269 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100270
271 total_obj_size += obj->base.size;
272 count++;
273 }
274 list_sort(NULL, &stolen, obj_rank_by_stolen);
275 seq_puts(m, "Stolen:\n");
276 while (!list_empty(&stolen)) {
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200277 obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100278 seq_puts(m, " ");
279 describe_obj(m, obj);
280 seq_putc(m, '\n');
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200281 list_del_init(&obj->obj_exec_link);
Chris Wilson6d2b8882013-08-07 18:30:54 +0100282 }
283 mutex_unlock(&dev->struct_mutex);
284
285 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
286 count, total_obj_size, total_gtt_size);
287 return 0;
288}
289
Chris Wilson6299f992010-11-24 12:23:44 +0000290#define count_objects(list, member) do { \
291 list_for_each_entry(obj, list, member) { \
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700292 size += i915_gem_obj_ggtt_size(obj); \
Chris Wilson6299f992010-11-24 12:23:44 +0000293 ++count; \
294 if (obj->map_and_fenceable) { \
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700295 mappable_size += i915_gem_obj_ggtt_size(obj); \
Chris Wilson6299f992010-11-24 12:23:44 +0000296 ++mappable_count; \
297 } \
298 } \
Akshay Joshi0206e352011-08-16 15:34:10 -0400299} while (0)
Chris Wilson6299f992010-11-24 12:23:44 +0000300
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100301struct file_stats {
Chris Wilson6313c202014-03-19 13:45:45 +0000302 struct drm_i915_file_private *file_priv;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100303 int count;
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000304 size_t total, unbound;
305 size_t global, shared;
306 size_t active, inactive;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100307};
308
309static int per_file_stats(int id, void *ptr, void *data)
310{
311 struct drm_i915_gem_object *obj = ptr;
312 struct file_stats *stats = data;
Chris Wilson6313c202014-03-19 13:45:45 +0000313 struct i915_vma *vma;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100314
315 stats->count++;
316 stats->total += obj->base.size;
317
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000318 if (obj->base.name || obj->base.dma_buf)
319 stats->shared += obj->base.size;
320
Chris Wilson6313c202014-03-19 13:45:45 +0000321 if (USES_FULL_PPGTT(obj->base.dev)) {
322 list_for_each_entry(vma, &obj->vma_list, vma_link) {
323 struct i915_hw_ppgtt *ppgtt;
324
325 if (!drm_mm_node_allocated(&vma->node))
326 continue;
327
328 if (i915_is_ggtt(vma->vm)) {
329 stats->global += obj->base.size;
330 continue;
331 }
332
333 ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
334 if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
335 continue;
336
337 if (obj->ring) /* XXX per-vma statistic */
338 stats->active += obj->base.size;
339 else
340 stats->inactive += obj->base.size;
341
342 return 0;
343 }
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100344 } else {
Chris Wilson6313c202014-03-19 13:45:45 +0000345 if (i915_gem_obj_ggtt_bound(obj)) {
346 stats->global += obj->base.size;
347 if (obj->ring)
348 stats->active += obj->base.size;
349 else
350 stats->inactive += obj->base.size;
351 return 0;
352 }
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100353 }
354
Chris Wilson6313c202014-03-19 13:45:45 +0000355 if (!list_empty(&obj->global_list))
356 stats->unbound += obj->base.size;
357
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100358 return 0;
359}
360
Ben Widawskyca191b12013-07-31 17:00:14 -0700361#define count_vmas(list, member) do { \
362 list_for_each_entry(vma, list, member) { \
363 size += i915_gem_obj_ggtt_size(vma->obj); \
364 ++count; \
365 if (vma->obj->map_and_fenceable) { \
366 mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
367 ++mappable_count; \
368 } \
369 } \
370} while (0)
371
372static int i915_gem_object_info(struct seq_file *m, void* data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100373{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100374 struct drm_info_node *node = m->private;
Chris Wilson73aa8082010-09-30 11:46:12 +0100375 struct drm_device *dev = node->minor->dev;
376 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilsonb7abb712012-08-20 11:33:30 +0200377 u32 count, mappable_count, purgeable_count;
378 size_t size, mappable_size, purgeable_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000379 struct drm_i915_gem_object *obj;
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700380 struct i915_address_space *vm = &dev_priv->gtt.base;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100381 struct drm_file *file;
Ben Widawskyca191b12013-07-31 17:00:14 -0700382 struct i915_vma *vma;
Chris Wilson73aa8082010-09-30 11:46:12 +0100383 int ret;
384
385 ret = mutex_lock_interruptible(&dev->struct_mutex);
386 if (ret)
387 return ret;
388
Chris Wilson6299f992010-11-24 12:23:44 +0000389 seq_printf(m, "%u objects, %zu bytes\n",
390 dev_priv->mm.object_count,
391 dev_priv->mm.object_memory);
392
393 size = count = mappable_size = mappable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700394 count_objects(&dev_priv->mm.bound_list, global_list);
Chris Wilson6299f992010-11-24 12:23:44 +0000395 seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
396 count, mappable_count, size, mappable_size);
397
398 size = count = mappable_size = mappable_count = 0;
Ben Widawskyca191b12013-07-31 17:00:14 -0700399 count_vmas(&vm->active_list, mm_list);
Chris Wilson6299f992010-11-24 12:23:44 +0000400 seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n",
401 count, mappable_count, size, mappable_size);
402
403 size = count = mappable_size = mappable_count = 0;
Ben Widawskyca191b12013-07-31 17:00:14 -0700404 count_vmas(&vm->inactive_list, mm_list);
Chris Wilson6299f992010-11-24 12:23:44 +0000405 seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n",
406 count, mappable_count, size, mappable_size);
407
Chris Wilsonb7abb712012-08-20 11:33:30 +0200408 size = count = purgeable_size = purgeable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700409 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
Chris Wilson6c085a72012-08-20 11:40:46 +0200410 size += obj->base.size, ++count;
Chris Wilsonb7abb712012-08-20 11:33:30 +0200411 if (obj->madv == I915_MADV_DONTNEED)
412 purgeable_size += obj->base.size, ++purgeable_count;
413 }
Chris Wilson6c085a72012-08-20 11:40:46 +0200414 seq_printf(m, "%u unbound objects, %zu bytes\n", count, size);
415
Chris Wilson6299f992010-11-24 12:23:44 +0000416 size = count = mappable_size = mappable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700417 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
Chris Wilson6299f992010-11-24 12:23:44 +0000418 if (obj->fault_mappable) {
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700419 size += i915_gem_obj_ggtt_size(obj);
Chris Wilson6299f992010-11-24 12:23:44 +0000420 ++count;
421 }
422 if (obj->pin_mappable) {
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700423 mappable_size += i915_gem_obj_ggtt_size(obj);
Chris Wilson6299f992010-11-24 12:23:44 +0000424 ++mappable_count;
425 }
Chris Wilsonb7abb712012-08-20 11:33:30 +0200426 if (obj->madv == I915_MADV_DONTNEED) {
427 purgeable_size += obj->base.size;
428 ++purgeable_count;
429 }
Chris Wilson6299f992010-11-24 12:23:44 +0000430 }
Chris Wilsonb7abb712012-08-20 11:33:30 +0200431 seq_printf(m, "%u purgeable objects, %zu bytes\n",
432 purgeable_count, purgeable_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000433 seq_printf(m, "%u pinned mappable objects, %zu bytes\n",
434 mappable_count, mappable_size);
435 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
436 count, size);
437
Ben Widawsky93d18792013-01-17 12:45:17 -0800438 seq_printf(m, "%zu [%lu] gtt total\n",
Ben Widawsky853ba5d2013-07-16 16:50:05 -0700439 dev_priv->gtt.base.total,
440 dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
Chris Wilson73aa8082010-09-30 11:46:12 +0100441
Damien Lespiau267f0c92013-06-24 22:59:48 +0100442 seq_putc(m, '\n');
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100443 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
444 struct file_stats stats;
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900445 struct task_struct *task;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100446
447 memset(&stats, 0, sizeof(stats));
Chris Wilson6313c202014-03-19 13:45:45 +0000448 stats.file_priv = file->driver_priv;
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100449 spin_lock(&file->table_lock);
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100450 idr_for_each(&file->object_idr, per_file_stats, &stats);
Chris Wilson5b5ffff2014-06-17 09:56:24 +0100451 spin_unlock(&file->table_lock);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900452 /*
453 * Although we have a valid reference on file->pid, that does
454 * not guarantee that the task_struct who called get_pid() is
455 * still alive (e.g. get_pid(current) => fork() => exit()).
456 * Therefore, we need to protect this ->comm access using RCU.
457 */
458 rcu_read_lock();
459 task = pid_task(file->pid, PIDTYPE_PID);
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000460 seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n",
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900461 task ? task->comm : "<unknown>",
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100462 stats.count,
463 stats.total,
464 stats.active,
465 stats.inactive,
Chris Wilson6313c202014-03-19 13:45:45 +0000466 stats.global,
Chris Wilsonc67a17e2014-03-19 13:45:46 +0000467 stats.shared,
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100468 stats.unbound);
Tetsuo Handa3ec2f422014-01-03 20:42:18 +0900469 rcu_read_unlock();
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100470 }
471
Chris Wilson73aa8082010-09-30 11:46:12 +0100472 mutex_unlock(&dev->struct_mutex);
473
474 return 0;
475}
476
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100477static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000478{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100479 struct drm_info_node *node = m->private;
Chris Wilson08c18322011-01-10 00:00:24 +0000480 struct drm_device *dev = node->minor->dev;
Chris Wilson1b502472012-04-24 15:47:30 +0100481 uintptr_t list = (uintptr_t) node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000482 struct drm_i915_private *dev_priv = dev->dev_private;
483 struct drm_i915_gem_object *obj;
484 size_t total_obj_size, total_gtt_size;
485 int count, ret;
486
487 ret = mutex_lock_interruptible(&dev->struct_mutex);
488 if (ret)
489 return ret;
490
491 total_obj_size = total_gtt_size = count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700492 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
Ben Widawskyd7f46fc2013-12-06 14:10:55 -0800493 if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj))
Chris Wilson1b502472012-04-24 15:47:30 +0100494 continue;
495
Damien Lespiau267f0c92013-06-24 22:59:48 +0100496 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000497 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100498 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000499 total_obj_size += obj->base.size;
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700500 total_gtt_size += i915_gem_obj_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000501 count++;
502 }
503
504 mutex_unlock(&dev->struct_mutex);
505
506 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
507 count, total_obj_size, total_gtt_size);
508
509 return 0;
510}
511
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100512static int i915_gem_pageflip_info(struct seq_file *m, void *data)
513{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100514 struct drm_info_node *node = m->private;
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100515 struct drm_device *dev = node->minor->dev;
516 unsigned long flags;
517 struct intel_crtc *crtc;
518
Damien Lespiaud3fcc802014-05-13 23:32:22 +0100519 for_each_intel_crtc(dev, crtc) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800520 const char pipe = pipe_name(crtc->pipe);
521 const char plane = plane_name(crtc->plane);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100522 struct intel_unpin_work *work;
523
524 spin_lock_irqsave(&dev->event_lock, flags);
525 work = crtc->unpin_work;
526 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800527 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100528 pipe, plane);
529 } else {
Chris Wilsone7d841c2012-12-03 11:36:30 +0000530 if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800531 seq_printf(m, "Flip queued on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100532 pipe, plane);
533 } else {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800534 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100535 pipe, plane);
536 }
537 if (work->enable_stall_check)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100538 seq_puts(m, "Stall check enabled, ");
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100539 else
Damien Lespiau267f0c92013-06-24 22:59:48 +0100540 seq_puts(m, "Stall check waiting for page flip ioctl, ");
Chris Wilsone7d841c2012-12-03 11:36:30 +0000541 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100542
543 if (work->old_fb_obj) {
Chris Wilson05394f32010-11-08 19:18:58 +0000544 struct drm_i915_gem_object *obj = work->old_fb_obj;
545 if (obj)
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700546 seq_printf(m, "Old framebuffer gtt_offset 0x%08lx\n",
547 i915_gem_obj_ggtt_offset(obj));
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100548 }
549 if (work->pending_flip_obj) {
Chris Wilson05394f32010-11-08 19:18:58 +0000550 struct drm_i915_gem_object *obj = work->pending_flip_obj;
551 if (obj)
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700552 seq_printf(m, "New framebuffer gtt_offset 0x%08lx\n",
553 i915_gem_obj_ggtt_offset(obj));
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100554 }
555 }
556 spin_unlock_irqrestore(&dev->event_lock, flags);
557 }
558
559 return 0;
560}
561
Ben Gamari20172632009-02-17 20:08:50 -0500562static int i915_gem_request_info(struct seq_file *m, void *data)
563{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100564 struct drm_info_node *node = m->private;
Ben Gamari20172632009-02-17 20:08:50 -0500565 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300566 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100567 struct intel_engine_cs *ring;
Ben Gamari20172632009-02-17 20:08:50 -0500568 struct drm_i915_gem_request *gem_request;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100569 int ret, count, i;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100570
571 ret = mutex_lock_interruptible(&dev->struct_mutex);
572 if (ret)
573 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500574
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100575 count = 0;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100576 for_each_ring(ring, dev_priv, i) {
577 if (list_empty(&ring->request_list))
578 continue;
579
580 seq_printf(m, "%s requests:\n", ring->name);
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100581 list_for_each_entry(gem_request,
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100582 &ring->request_list,
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100583 list) {
584 seq_printf(m, " %d @ %d\n",
585 gem_request->seqno,
586 (int) (jiffies - gem_request->emitted_jiffies));
587 }
588 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500589 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100590 mutex_unlock(&dev->struct_mutex);
591
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100592 if (count == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100593 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100594
Ben Gamari20172632009-02-17 20:08:50 -0500595 return 0;
596}
597
Chris Wilsonb2223492010-10-27 15:27:33 +0100598static void i915_ring_seqno_info(struct seq_file *m,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100599 struct intel_engine_cs *ring)
Chris Wilsonb2223492010-10-27 15:27:33 +0100600{
601 if (ring->get_seqno) {
Mika Kuoppala43a7b922012-12-04 15:12:01 +0200602 seq_printf(m, "Current sequence (%s): %u\n",
Chris Wilsonb2eadbc2012-08-09 10:58:30 +0100603 ring->name, ring->get_seqno(ring, false));
Chris Wilsonb2223492010-10-27 15:27:33 +0100604 }
605}
606
Ben Gamari20172632009-02-17 20:08:50 -0500607static int i915_gem_seqno_info(struct seq_file *m, void *data)
608{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100609 struct drm_info_node *node = m->private;
Ben Gamari20172632009-02-17 20:08:50 -0500610 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300611 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100612 struct intel_engine_cs *ring;
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000613 int ret, i;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100614
615 ret = mutex_lock_interruptible(&dev->struct_mutex);
616 if (ret)
617 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200618 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500619
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100620 for_each_ring(ring, dev_priv, i)
621 i915_ring_seqno_info(m, ring);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100622
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200623 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100624 mutex_unlock(&dev->struct_mutex);
625
Ben Gamari20172632009-02-17 20:08:50 -0500626 return 0;
627}
628
629
630static int i915_interrupt_info(struct seq_file *m, void *data)
631{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100632 struct drm_info_node *node = m->private;
Ben Gamari20172632009-02-17 20:08:50 -0500633 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300634 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100635 struct intel_engine_cs *ring;
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800636 int ret, i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100637
638 ret = mutex_lock_interruptible(&dev->struct_mutex);
639 if (ret)
640 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200641 intel_runtime_pm_get(dev_priv);
Ben Gamari20172632009-02-17 20:08:50 -0500642
Ville Syrjälä74e1ca82014-04-09 13:28:09 +0300643 if (IS_CHERRYVIEW(dev)) {
644 int i;
645 seq_printf(m, "Master Interrupt Control:\t%08x\n",
646 I915_READ(GEN8_MASTER_IRQ));
647
648 seq_printf(m, "Display IER:\t%08x\n",
649 I915_READ(VLV_IER));
650 seq_printf(m, "Display IIR:\t%08x\n",
651 I915_READ(VLV_IIR));
652 seq_printf(m, "Display IIR_RW:\t%08x\n",
653 I915_READ(VLV_IIR_RW));
654 seq_printf(m, "Display IMR:\t%08x\n",
655 I915_READ(VLV_IMR));
656 for_each_pipe(pipe)
657 seq_printf(m, "Pipe %c stat:\t%08x\n",
658 pipe_name(pipe),
659 I915_READ(PIPESTAT(pipe)));
660
661 seq_printf(m, "Port hotplug:\t%08x\n",
662 I915_READ(PORT_HOTPLUG_EN));
663 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
664 I915_READ(VLV_DPFLIPSTAT));
665 seq_printf(m, "DPINVGTT:\t%08x\n",
666 I915_READ(DPINVGTT));
667
668 for (i = 0; i < 4; i++) {
669 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
670 i, I915_READ(GEN8_GT_IMR(i)));
671 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
672 i, I915_READ(GEN8_GT_IIR(i)));
673 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
674 i, I915_READ(GEN8_GT_IER(i)));
675 }
676
677 seq_printf(m, "PCU interrupt mask:\t%08x\n",
678 I915_READ(GEN8_PCU_IMR));
679 seq_printf(m, "PCU interrupt identity:\t%08x\n",
680 I915_READ(GEN8_PCU_IIR));
681 seq_printf(m, "PCU interrupt enable:\t%08x\n",
682 I915_READ(GEN8_PCU_IER));
683 } else if (INTEL_INFO(dev)->gen >= 8) {
Ben Widawskya123f152013-11-02 21:07:10 -0700684 seq_printf(m, "Master Interrupt Control:\t%08x\n",
685 I915_READ(GEN8_MASTER_IRQ));
686
687 for (i = 0; i < 4; i++) {
688 seq_printf(m, "GT Interrupt IMR %d:\t%08x\n",
689 i, I915_READ(GEN8_GT_IMR(i)));
690 seq_printf(m, "GT Interrupt IIR %d:\t%08x\n",
691 i, I915_READ(GEN8_GT_IIR(i)));
692 seq_printf(m, "GT Interrupt IER %d:\t%08x\n",
693 i, I915_READ(GEN8_GT_IER(i)));
694 }
695
Damien Lespiau07d27e22014-03-03 17:31:46 +0000696 for_each_pipe(pipe) {
Ben Widawskya123f152013-11-02 21:07:10 -0700697 seq_printf(m, "Pipe %c IMR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000698 pipe_name(pipe),
699 I915_READ(GEN8_DE_PIPE_IMR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700700 seq_printf(m, "Pipe %c IIR:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000701 pipe_name(pipe),
702 I915_READ(GEN8_DE_PIPE_IIR(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700703 seq_printf(m, "Pipe %c IER:\t%08x\n",
Damien Lespiau07d27e22014-03-03 17:31:46 +0000704 pipe_name(pipe),
705 I915_READ(GEN8_DE_PIPE_IER(pipe)));
Ben Widawskya123f152013-11-02 21:07:10 -0700706 }
707
708 seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
709 I915_READ(GEN8_DE_PORT_IMR));
710 seq_printf(m, "Display Engine port interrupt identity:\t%08x\n",
711 I915_READ(GEN8_DE_PORT_IIR));
712 seq_printf(m, "Display Engine port interrupt enable:\t%08x\n",
713 I915_READ(GEN8_DE_PORT_IER));
714
715 seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n",
716 I915_READ(GEN8_DE_MISC_IMR));
717 seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n",
718 I915_READ(GEN8_DE_MISC_IIR));
719 seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n",
720 I915_READ(GEN8_DE_MISC_IER));
721
722 seq_printf(m, "PCU interrupt mask:\t%08x\n",
723 I915_READ(GEN8_PCU_IMR));
724 seq_printf(m, "PCU interrupt identity:\t%08x\n",
725 I915_READ(GEN8_PCU_IIR));
726 seq_printf(m, "PCU interrupt enable:\t%08x\n",
727 I915_READ(GEN8_PCU_IER));
728 } else if (IS_VALLEYVIEW(dev)) {
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700729 seq_printf(m, "Display IER:\t%08x\n",
730 I915_READ(VLV_IER));
731 seq_printf(m, "Display IIR:\t%08x\n",
732 I915_READ(VLV_IIR));
733 seq_printf(m, "Display IIR_RW:\t%08x\n",
734 I915_READ(VLV_IIR_RW));
735 seq_printf(m, "Display IMR:\t%08x\n",
736 I915_READ(VLV_IMR));
737 for_each_pipe(pipe)
738 seq_printf(m, "Pipe %c stat:\t%08x\n",
739 pipe_name(pipe),
740 I915_READ(PIPESTAT(pipe)));
741
742 seq_printf(m, "Master IER:\t%08x\n",
743 I915_READ(VLV_MASTER_IER));
744
745 seq_printf(m, "Render IER:\t%08x\n",
746 I915_READ(GTIER));
747 seq_printf(m, "Render IIR:\t%08x\n",
748 I915_READ(GTIIR));
749 seq_printf(m, "Render IMR:\t%08x\n",
750 I915_READ(GTIMR));
751
752 seq_printf(m, "PM IER:\t\t%08x\n",
753 I915_READ(GEN6_PMIER));
754 seq_printf(m, "PM IIR:\t\t%08x\n",
755 I915_READ(GEN6_PMIIR));
756 seq_printf(m, "PM IMR:\t\t%08x\n",
757 I915_READ(GEN6_PMIMR));
758
759 seq_printf(m, "Port hotplug:\t%08x\n",
760 I915_READ(PORT_HOTPLUG_EN));
761 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
762 I915_READ(VLV_DPFLIPSTAT));
763 seq_printf(m, "DPINVGTT:\t%08x\n",
764 I915_READ(DPINVGTT));
765
766 } else if (!HAS_PCH_SPLIT(dev)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800767 seq_printf(m, "Interrupt enable: %08x\n",
768 I915_READ(IER));
769 seq_printf(m, "Interrupt identity: %08x\n",
770 I915_READ(IIR));
771 seq_printf(m, "Interrupt mask: %08x\n",
772 I915_READ(IMR));
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800773 for_each_pipe(pipe)
774 seq_printf(m, "Pipe %c stat: %08x\n",
775 pipe_name(pipe),
776 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800777 } else {
778 seq_printf(m, "North Display Interrupt enable: %08x\n",
779 I915_READ(DEIER));
780 seq_printf(m, "North Display Interrupt identity: %08x\n",
781 I915_READ(DEIIR));
782 seq_printf(m, "North Display Interrupt mask: %08x\n",
783 I915_READ(DEIMR));
784 seq_printf(m, "South Display Interrupt enable: %08x\n",
785 I915_READ(SDEIER));
786 seq_printf(m, "South Display Interrupt identity: %08x\n",
787 I915_READ(SDEIIR));
788 seq_printf(m, "South Display Interrupt mask: %08x\n",
789 I915_READ(SDEIMR));
790 seq_printf(m, "Graphics Interrupt enable: %08x\n",
791 I915_READ(GTIER));
792 seq_printf(m, "Graphics Interrupt identity: %08x\n",
793 I915_READ(GTIIR));
794 seq_printf(m, "Graphics Interrupt mask: %08x\n",
795 I915_READ(GTIMR));
796 }
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100797 for_each_ring(ring, dev_priv, i) {
Ben Widawskya123f152013-11-02 21:07:10 -0700798 if (INTEL_INFO(dev)->gen >= 6) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100799 seq_printf(m,
800 "Graphics Interrupt mask (%s): %08x\n",
801 ring->name, I915_READ_IMR(ring));
Chris Wilson9862e602011-01-04 22:22:17 +0000802 }
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100803 i915_ring_seqno_info(m, ring);
Chris Wilson9862e602011-01-04 22:22:17 +0000804 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200805 intel_runtime_pm_put(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100806 mutex_unlock(&dev->struct_mutex);
807
Ben Gamari20172632009-02-17 20:08:50 -0500808 return 0;
809}
810
Chris Wilsona6172a82009-02-11 14:26:38 +0000811static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
812{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100813 struct drm_info_node *node = m->private;
Chris Wilsona6172a82009-02-11 14:26:38 +0000814 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300815 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100816 int i, ret;
817
818 ret = mutex_lock_interruptible(&dev->struct_mutex);
819 if (ret)
820 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000821
822 seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
823 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
824 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson05394f32010-11-08 19:18:58 +0000825 struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj;
Chris Wilsona6172a82009-02-11 14:26:38 +0000826
Chris Wilson6c085a72012-08-20 11:40:46 +0200827 seq_printf(m, "Fence %d, pin count = %d, object = ",
828 i, dev_priv->fence_regs[i].pin_count);
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100829 if (obj == NULL)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100830 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100831 else
Chris Wilson05394f32010-11-08 19:18:58 +0000832 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100833 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000834 }
835
Chris Wilson05394f32010-11-08 19:18:58 +0000836 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000837 return 0;
838}
839
Ben Gamari20172632009-02-17 20:08:50 -0500840static int i915_hws_info(struct seq_file *m, void *data)
841{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100842 struct drm_info_node *node = m->private;
Ben Gamari20172632009-02-17 20:08:50 -0500843 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300844 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100845 struct intel_engine_cs *ring;
Daniel Vetter1a240d42012-11-29 22:18:51 +0100846 const u32 *hws;
Chris Wilson4066c0a2010-10-29 21:00:54 +0100847 int i;
Ben Gamari20172632009-02-17 20:08:50 -0500848
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000849 ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
Daniel Vetter1a240d42012-11-29 22:18:51 +0100850 hws = ring->status_page.page_addr;
Ben Gamari20172632009-02-17 20:08:50 -0500851 if (hws == NULL)
852 return 0;
853
854 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
855 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
856 i * 4,
857 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
858 }
859 return 0;
860}
861
Daniel Vetterd5442302012-04-27 15:17:40 +0200862static ssize_t
863i915_error_state_write(struct file *filp,
864 const char __user *ubuf,
865 size_t cnt,
866 loff_t *ppos)
867{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300868 struct i915_error_state_file_priv *error_priv = filp->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200869 struct drm_device *dev = error_priv->dev;
Daniel Vetter22bcfc62012-08-09 15:07:02 +0200870 int ret;
Daniel Vetterd5442302012-04-27 15:17:40 +0200871
872 DRM_DEBUG_DRIVER("Resetting error state\n");
873
Daniel Vetter22bcfc62012-08-09 15:07:02 +0200874 ret = mutex_lock_interruptible(&dev->struct_mutex);
875 if (ret)
876 return ret;
877
Daniel Vetterd5442302012-04-27 15:17:40 +0200878 i915_destroy_error_state(dev);
879 mutex_unlock(&dev->struct_mutex);
880
881 return cnt;
882}
883
884static int i915_error_state_open(struct inode *inode, struct file *file)
885{
886 struct drm_device *dev = inode->i_private;
Daniel Vetterd5442302012-04-27 15:17:40 +0200887 struct i915_error_state_file_priv *error_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +0200888
889 error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
890 if (!error_priv)
891 return -ENOMEM;
892
893 error_priv->dev = dev;
894
Mika Kuoppala95d5bfb2013-06-06 15:18:40 +0300895 i915_error_state_get(dev, error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +0200896
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300897 file->private_data = error_priv;
898
899 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +0200900}
901
902static int i915_error_state_release(struct inode *inode, struct file *file)
903{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300904 struct i915_error_state_file_priv *error_priv = file->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200905
Mika Kuoppala95d5bfb2013-06-06 15:18:40 +0300906 i915_error_state_put(error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +0200907 kfree(error_priv);
908
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300909 return 0;
910}
911
912static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
913 size_t count, loff_t *pos)
914{
915 struct i915_error_state_file_priv *error_priv = file->private_data;
916 struct drm_i915_error_state_buf error_str;
917 loff_t tmp_pos = 0;
918 ssize_t ret_count = 0;
Mika Kuoppala4dc955f2013-06-06 15:18:41 +0300919 int ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300920
Mika Kuoppala4dc955f2013-06-06 15:18:41 +0300921 ret = i915_error_state_buf_init(&error_str, count, *pos);
922 if (ret)
923 return ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300924
Mika Kuoppalafc16b482013-06-06 15:18:39 +0300925 ret = i915_error_state_to_str(&error_str, error_priv);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300926 if (ret)
927 goto out;
928
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300929 ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
930 error_str.buf,
931 error_str.bytes);
932
933 if (ret_count < 0)
934 ret = ret_count;
935 else
936 *pos = error_str.start + ret_count;
937out:
Mika Kuoppala4dc955f2013-06-06 15:18:41 +0300938 i915_error_state_buf_release(&error_str);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300939 return ret ?: ret_count;
Daniel Vetterd5442302012-04-27 15:17:40 +0200940}
941
942static const struct file_operations i915_error_state_fops = {
943 .owner = THIS_MODULE,
944 .open = i915_error_state_open,
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300945 .read = i915_error_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +0200946 .write = i915_error_state_write,
947 .llseek = default_llseek,
948 .release = i915_error_state_release,
949};
950
Kees Cook647416f2013-03-10 14:10:06 -0700951static int
952i915_next_seqno_get(void *data, u64 *val)
Mika Kuoppala40633212012-12-04 15:12:00 +0200953{
Kees Cook647416f2013-03-10 14:10:06 -0700954 struct drm_device *dev = data;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300955 struct drm_i915_private *dev_priv = dev->dev_private;
Mika Kuoppala40633212012-12-04 15:12:00 +0200956 int ret;
957
958 ret = mutex_lock_interruptible(&dev->struct_mutex);
959 if (ret)
960 return ret;
961
Kees Cook647416f2013-03-10 14:10:06 -0700962 *val = dev_priv->next_seqno;
Mika Kuoppala40633212012-12-04 15:12:00 +0200963 mutex_unlock(&dev->struct_mutex);
964
Kees Cook647416f2013-03-10 14:10:06 -0700965 return 0;
Mika Kuoppala40633212012-12-04 15:12:00 +0200966}
967
Kees Cook647416f2013-03-10 14:10:06 -0700968static int
969i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +0200970{
Kees Cook647416f2013-03-10 14:10:06 -0700971 struct drm_device *dev = data;
Mika Kuoppala40633212012-12-04 15:12:00 +0200972 int ret;
973
Mika Kuoppala40633212012-12-04 15:12:00 +0200974 ret = mutex_lock_interruptible(&dev->struct_mutex);
975 if (ret)
976 return ret;
977
Mika Kuoppalae94fbaa2012-12-19 11:13:09 +0200978 ret = i915_gem_set_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +0200979 mutex_unlock(&dev->struct_mutex);
980
Kees Cook647416f2013-03-10 14:10:06 -0700981 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +0200982}
983
Kees Cook647416f2013-03-10 14:10:06 -0700984DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
985 i915_next_seqno_get, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +0300986 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +0200987
Jesse Barnesf97108d2010-01-29 11:27:07 -0800988static int i915_rstdby_delays(struct seq_file *m, void *unused)
989{
Damien Lespiau9f25d002014-05-13 15:30:28 +0100990 struct drm_info_node *node = m->private;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800991 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +0300992 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700993 u16 crstanddelay;
994 int ret;
995
996 ret = mutex_lock_interruptible(&dev->struct_mutex);
997 if (ret)
998 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -0200999 intel_runtime_pm_get(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001000
1001 crstanddelay = I915_READ16(CRSTANDVID);
1002
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001003 intel_runtime_pm_put(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001004 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001005
1006 seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
1007
1008 return 0;
1009}
1010
Deepak Sadb4bd12014-03-31 11:30:02 +05301011static int i915_frequency_info(struct seq_file *m, void *unused)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001012{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001013 struct drm_info_node *node = m->private;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001014 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001015 struct drm_i915_private *dev_priv = dev->dev_private;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001016 int ret = 0;
1017
1018 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001019
Tom O'Rourke5c9669c2013-09-16 14:56:43 -07001020 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
1021
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001022 if (IS_GEN5(dev)) {
1023 u16 rgvswctl = I915_READ16(MEMSWCTL);
1024 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
1025
1026 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
1027 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
1028 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
1029 MEMSTAT_VID_SHIFT);
1030 seq_printf(m, "Current P-state: %d\n",
1031 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
Jesse Barnes0a073b82013-04-17 15:54:58 -07001032 } else if ((IS_GEN6(dev) || IS_GEN7(dev)) && !IS_VALLEYVIEW(dev)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001033 u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
1034 u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
1035 u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001036 u32 rpmodectl, rpinclimit, rpdeclimit;
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001037 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001038 u32 rpupei, rpcurup, rpprevup;
1039 u32 rpdownei, rpcurdown, rpprevdown;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001040 int max_freq;
1041
1042 /* RPSTAT1 is in the GT power well */
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001043 ret = mutex_lock_interruptible(&dev->struct_mutex);
1044 if (ret)
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001045 goto out;
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001046
Deepak Sc8d9a592013-11-23 14:55:42 +05301047 gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001048
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001049 reqf = I915_READ(GEN6_RPNSWREQ);
1050 reqf &= ~GEN6_TURBO_DISABLE;
1051 if (IS_HASWELL(dev))
1052 reqf >>= 24;
1053 else
1054 reqf >>= 25;
1055 reqf *= GT_FREQUENCY_MULTIPLIER;
1056
Chris Wilson0d8f9492014-03-27 09:06:14 +00001057 rpmodectl = I915_READ(GEN6_RP_CONTROL);
1058 rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD);
1059 rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD);
1060
Jesse Barnesccab5c82011-01-18 15:49:25 -08001061 rpstat = I915_READ(GEN6_RPSTAT1);
1062 rpupei = I915_READ(GEN6_RP_CUR_UP_EI);
1063 rpcurup = I915_READ(GEN6_RP_CUR_UP);
1064 rpprevup = I915_READ(GEN6_RP_PREV_UP);
1065 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI);
1066 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN);
1067 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001068 if (IS_HASWELL(dev))
1069 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
1070 else
1071 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
1072 cagf *= GT_FREQUENCY_MULTIPLIER;
Jesse Barnesccab5c82011-01-18 15:49:25 -08001073
Deepak Sc8d9a592013-11-23 14:55:42 +05301074 gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawskyd1ebd8162011-04-25 20:11:50 +01001075 mutex_unlock(&dev->struct_mutex);
1076
Chris Wilson0d8f9492014-03-27 09:06:14 +00001077 seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n",
1078 I915_READ(GEN6_PMIER),
1079 I915_READ(GEN6_PMIMR),
1080 I915_READ(GEN6_PMISR),
1081 I915_READ(GEN6_PMIIR),
1082 I915_READ(GEN6_PMINTRMSK));
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001083 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001084 seq_printf(m, "Render p-state ratio: %d\n",
1085 (gt_perf_status & 0xff00) >> 8);
1086 seq_printf(m, "Render p-state VID: %d\n",
1087 gt_perf_status & 0xff);
1088 seq_printf(m, "Render p-state limit: %d\n",
1089 rp_state_limits & 0xff);
Chris Wilson0d8f9492014-03-27 09:06:14 +00001090 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
1091 seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl);
1092 seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit);
1093 seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit);
Chris Wilson8e8c06c2013-08-26 19:51:01 -03001094 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -08001095 seq_printf(m, "CAGF: %dMHz\n", cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -08001096 seq_printf(m, "RP CUR UP EI: %dus\n", rpupei &
1097 GEN6_CURICONT_MASK);
1098 seq_printf(m, "RP CUR UP: %dus\n", rpcurup &
1099 GEN6_CURBSYTAVG_MASK);
1100 seq_printf(m, "RP PREV UP: %dus\n", rpprevup &
1101 GEN6_CURBSYTAVG_MASK);
1102 seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei &
1103 GEN6_CURIAVG_MASK);
1104 seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown &
1105 GEN6_CURBSYTAVG_MASK);
1106 seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown &
1107 GEN6_CURBSYTAVG_MASK);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001108
1109 max_freq = (rp_state_cap & 0xff0000) >> 16;
1110 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ben Widawskyc8735b02012-09-07 19:43:39 -07001111 max_freq * GT_FREQUENCY_MULTIPLIER);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001112
1113 max_freq = (rp_state_cap & 0xff00) >> 8;
1114 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ben Widawskyc8735b02012-09-07 19:43:39 -07001115 max_freq * GT_FREQUENCY_MULTIPLIER);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001116
1117 max_freq = rp_state_cap & 0xff;
1118 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ben Widawskyc8735b02012-09-07 19:43:39 -07001119 max_freq * GT_FREQUENCY_MULTIPLIER);
Ben Widawsky31c77382013-04-05 14:29:22 -07001120
1121 seq_printf(m, "Max overclocked frequency: %dMHz\n",
Ben Widawskyb39fb292014-03-19 18:31:11 -07001122 dev_priv->rps.max_freq * GT_FREQUENCY_MULTIPLIER);
Jesse Barnes0a073b82013-04-17 15:54:58 -07001123 } else if (IS_VALLEYVIEW(dev)) {
1124 u32 freq_sts, val;
1125
Jesse Barnes259bd5d2013-04-22 15:59:30 -07001126 mutex_lock(&dev_priv->rps.hw_lock);
Jani Nikula64936252013-05-22 15:36:20 +03001127 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
Jesse Barnes0a073b82013-04-17 15:54:58 -07001128 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
1129 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
1130
Chon Ming Leec5bd2bf2013-11-07 15:23:27 +08001131 val = valleyview_rps_max_freq(dev_priv);
Jesse Barnes0a073b82013-04-17 15:54:58 -07001132 seq_printf(m, "max GPU freq: %d MHz\n",
Ville Syrjälä2ec38152013-11-05 22:42:29 +02001133 vlv_gpu_freq(dev_priv, val));
Jesse Barnes0a073b82013-04-17 15:54:58 -07001134
Chon Ming Leec5bd2bf2013-11-07 15:23:27 +08001135 val = valleyview_rps_min_freq(dev_priv);
Jesse Barnes0a073b82013-04-17 15:54:58 -07001136 seq_printf(m, "min GPU freq: %d MHz\n",
Ville Syrjälä2ec38152013-11-05 22:42:29 +02001137 vlv_gpu_freq(dev_priv, val));
Jesse Barnes0a073b82013-04-17 15:54:58 -07001138
1139 seq_printf(m, "current GPU freq: %d MHz\n",
Ville Syrjälä2ec38152013-11-05 22:42:29 +02001140 vlv_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff));
Jesse Barnes259bd5d2013-04-22 15:59:30 -07001141 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001142 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001143 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -08001144 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001145
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001146out:
1147 intel_runtime_pm_put(dev_priv);
1148 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001149}
1150
1151static int i915_delayfreq_table(struct seq_file *m, void *unused)
1152{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001153 struct drm_info_node *node = m->private;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001154 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001155 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001156 u32 delayfreq;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001157 int ret, i;
1158
1159 ret = mutex_lock_interruptible(&dev->struct_mutex);
1160 if (ret)
1161 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001162 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001163
1164 for (i = 0; i < 16; i++) {
1165 delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001166 seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
1167 (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001168 }
1169
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001170 intel_runtime_pm_put(dev_priv);
1171
Ben Widawsky616fdb52011-10-05 11:44:54 -07001172 mutex_unlock(&dev->struct_mutex);
1173
Jesse Barnesf97108d2010-01-29 11:27:07 -08001174 return 0;
1175}
1176
1177static inline int MAP_TO_MV(int map)
1178{
1179 return 1250 - (map * 25);
1180}
1181
1182static int i915_inttoext_table(struct seq_file *m, void *unused)
1183{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001184 struct drm_info_node *node = m->private;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001185 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001186 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001187 u32 inttoext;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001188 int ret, i;
1189
1190 ret = mutex_lock_interruptible(&dev->struct_mutex);
1191 if (ret)
1192 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001193 intel_runtime_pm_get(dev_priv);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001194
1195 for (i = 1; i <= 32; i++) {
1196 inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
1197 seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
1198 }
1199
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001200 intel_runtime_pm_put(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001201 mutex_unlock(&dev->struct_mutex);
1202
Jesse Barnesf97108d2010-01-29 11:27:07 -08001203 return 0;
1204}
1205
Ben Widawsky4d855292011-12-12 19:34:16 -08001206static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001207{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001208 struct drm_info_node *node = m->private;
Jesse Barnesf97108d2010-01-29 11:27:07 -08001209 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001210 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001211 u32 rgvmodectl, rstdbyctl;
1212 u16 crstandvid;
1213 int ret;
1214
1215 ret = mutex_lock_interruptible(&dev->struct_mutex);
1216 if (ret)
1217 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001218 intel_runtime_pm_get(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001219
1220 rgvmodectl = I915_READ(MEMMODECTL);
1221 rstdbyctl = I915_READ(RSTDBYCTL);
1222 crstandvid = I915_READ16(CRSTANDVID);
1223
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001224 intel_runtime_pm_put(dev_priv);
Ben Widawsky616fdb52011-10-05 11:44:54 -07001225 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001226
1227 seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
1228 "yes" : "no");
1229 seq_printf(m, "Boost freq: %d\n",
1230 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1231 MEMMODE_BOOST_FREQ_SHIFT);
1232 seq_printf(m, "HW control enabled: %s\n",
1233 rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
1234 seq_printf(m, "SW control enabled: %s\n",
1235 rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
1236 seq_printf(m, "Gated voltage change: %s\n",
1237 rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
1238 seq_printf(m, "Starting frequency: P%d\n",
1239 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001240 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001241 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001242 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1243 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1244 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1245 seq_printf(m, "Render standby enabled: %s\n",
1246 (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
Damien Lespiau267f0c92013-06-24 22:59:48 +01001247 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001248 switch (rstdbyctl & RSX_STATUS_MASK) {
1249 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001250 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001251 break;
1252 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001253 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001254 break;
1255 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001256 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001257 break;
1258 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001259 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001260 break;
1261 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001262 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001263 break;
1264 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001265 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001266 break;
1267 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001268 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001269 break;
1270 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001271
1272 return 0;
1273}
1274
Deepak S669ab5a2014-01-10 15:18:26 +05301275static int vlv_drpc_info(struct seq_file *m)
1276{
1277
Damien Lespiau9f25d002014-05-13 15:30:28 +01001278 struct drm_info_node *node = m->private;
Deepak S669ab5a2014-01-10 15:18:26 +05301279 struct drm_device *dev = node->minor->dev;
1280 struct drm_i915_private *dev_priv = dev->dev_private;
1281 u32 rpmodectl1, rcctl1;
1282 unsigned fw_rendercount = 0, fw_mediacount = 0;
1283
Imre Deakd46c0512014-04-14 20:24:27 +03001284 intel_runtime_pm_get(dev_priv);
1285
Deepak S669ab5a2014-01-10 15:18:26 +05301286 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1287 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1288
Imre Deakd46c0512014-04-14 20:24:27 +03001289 intel_runtime_pm_put(dev_priv);
1290
Deepak S669ab5a2014-01-10 15:18:26 +05301291 seq_printf(m, "Video Turbo Mode: %s\n",
1292 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1293 seq_printf(m, "Turbo enabled: %s\n",
1294 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1295 seq_printf(m, "HW control enabled: %s\n",
1296 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1297 seq_printf(m, "SW control enabled: %s\n",
1298 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1299 GEN6_RP_MEDIA_SW_MODE));
1300 seq_printf(m, "RC6 Enabled: %s\n",
1301 yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE |
1302 GEN6_RC_CTL_EI_MODE(1))));
1303 seq_printf(m, "Render Power Well: %s\n",
1304 (I915_READ(VLV_GTLC_PW_STATUS) &
1305 VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down");
1306 seq_printf(m, "Media Power Well: %s\n",
1307 (I915_READ(VLV_GTLC_PW_STATUS) &
1308 VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down");
1309
Imre Deak9cc19be2014-04-14 20:24:24 +03001310 seq_printf(m, "Render RC6 residency since boot: %u\n",
1311 I915_READ(VLV_GT_RENDER_RC6));
1312 seq_printf(m, "Media RC6 residency since boot: %u\n",
1313 I915_READ(VLV_GT_MEDIA_RC6));
1314
Deepak S669ab5a2014-01-10 15:18:26 +05301315 spin_lock_irq(&dev_priv->uncore.lock);
1316 fw_rendercount = dev_priv->uncore.fw_rendercount;
1317 fw_mediacount = dev_priv->uncore.fw_mediacount;
1318 spin_unlock_irq(&dev_priv->uncore.lock);
1319
1320 seq_printf(m, "Forcewake Render Count = %u\n", fw_rendercount);
1321 seq_printf(m, "Forcewake Media Count = %u\n", fw_mediacount);
1322
1323
1324 return 0;
1325}
1326
1327
Ben Widawsky4d855292011-12-12 19:34:16 -08001328static int gen6_drpc_info(struct seq_file *m)
1329{
1330
Damien Lespiau9f25d002014-05-13 15:30:28 +01001331 struct drm_info_node *node = m->private;
Ben Widawsky4d855292011-12-12 19:34:16 -08001332 struct drm_device *dev = node->minor->dev;
1333 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001334 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001335 unsigned forcewake_count;
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001336 int count = 0, ret;
Ben Widawsky4d855292011-12-12 19:34:16 -08001337
1338 ret = mutex_lock_interruptible(&dev->struct_mutex);
1339 if (ret)
1340 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001341 intel_runtime_pm_get(dev_priv);
Ben Widawsky4d855292011-12-12 19:34:16 -08001342
Chris Wilson907b28c2013-07-19 20:36:52 +01001343 spin_lock_irq(&dev_priv->uncore.lock);
1344 forcewake_count = dev_priv->uncore.forcewake_count;
1345 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001346
1347 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001348 seq_puts(m, "RC information inaccurate because somebody "
1349 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001350 } else {
1351 /* NB: we cannot use forcewake, else we read the wrong values */
1352 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1353 udelay(10);
1354 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1355 }
1356
1357 gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001358 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001359
1360 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1361 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1362 mutex_unlock(&dev->struct_mutex);
Ben Widawsky44cbd332012-11-06 14:36:36 +00001363 mutex_lock(&dev_priv->rps.hw_lock);
1364 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1365 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001366
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001367 intel_runtime_pm_put(dev_priv);
1368
Ben Widawsky4d855292011-12-12 19:34:16 -08001369 seq_printf(m, "Video Turbo Mode: %s\n",
1370 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1371 seq_printf(m, "HW control enabled: %s\n",
1372 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1373 seq_printf(m, "SW control enabled: %s\n",
1374 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1375 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001376 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001377 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1378 seq_printf(m, "RC6 Enabled: %s\n",
1379 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
1380 seq_printf(m, "Deep RC6 Enabled: %s\n",
1381 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1382 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1383 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001384 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001385 switch (gt_core_status & GEN6_RCn_MASK) {
1386 case GEN6_RC0:
1387 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001388 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001389 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001390 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001391 break;
1392 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001393 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001394 break;
1395 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001396 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001397 break;
1398 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001399 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001400 break;
1401 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001402 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001403 break;
1404 }
1405
1406 seq_printf(m, "Core Power Down: %s\n",
1407 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
Ben Widawskycce66a22012-03-27 18:59:38 -07001408
1409 /* Not exactly sure what this is */
1410 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1411 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1412 seq_printf(m, "RC6 residency since boot: %u\n",
1413 I915_READ(GEN6_GT_GFX_RC6));
1414 seq_printf(m, "RC6+ residency since boot: %u\n",
1415 I915_READ(GEN6_GT_GFX_RC6p));
1416 seq_printf(m, "RC6++ residency since boot: %u\n",
1417 I915_READ(GEN6_GT_GFX_RC6pp));
1418
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001419 seq_printf(m, "RC6 voltage: %dmV\n",
1420 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1421 seq_printf(m, "RC6+ voltage: %dmV\n",
1422 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1423 seq_printf(m, "RC6++ voltage: %dmV\n",
1424 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Ben Widawsky4d855292011-12-12 19:34:16 -08001425 return 0;
1426}
1427
1428static int i915_drpc_info(struct seq_file *m, void *unused)
1429{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001430 struct drm_info_node *node = m->private;
Ben Widawsky4d855292011-12-12 19:34:16 -08001431 struct drm_device *dev = node->minor->dev;
1432
Deepak S669ab5a2014-01-10 15:18:26 +05301433 if (IS_VALLEYVIEW(dev))
1434 return vlv_drpc_info(m);
1435 else if (IS_GEN6(dev) || IS_GEN7(dev))
Ben Widawsky4d855292011-12-12 19:34:16 -08001436 return gen6_drpc_info(m);
1437 else
1438 return ironlake_drpc_info(m);
1439}
1440
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001441static int i915_fbc_status(struct seq_file *m, void *unused)
1442{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001443 struct drm_info_node *node = m->private;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001444 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001445 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001446
Daniel Vetter3a77c4c2014-01-10 08:50:12 +01001447 if (!HAS_FBC(dev)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001448 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001449 return 0;
1450 }
1451
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001452 intel_runtime_pm_get(dev_priv);
1453
Adam Jacksonee5382a2010-04-23 11:17:39 -04001454 if (intel_fbc_enabled(dev)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001455 seq_puts(m, "FBC enabled\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001456 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001457 seq_puts(m, "FBC disabled: ");
Ben Widawsky5c3fe8b2013-06-27 16:30:21 -07001458 switch (dev_priv->fbc.no_fbc_reason) {
Chris Wilson29ebf902013-07-27 17:23:55 +01001459 case FBC_OK:
1460 seq_puts(m, "FBC actived, but currently disabled in hardware");
1461 break;
1462 case FBC_UNSUPPORTED:
1463 seq_puts(m, "unsupported by this chipset");
1464 break;
Chris Wilsonbed4a672010-09-11 10:47:47 +01001465 case FBC_NO_OUTPUT:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001466 seq_puts(m, "no outputs");
Chris Wilsonbed4a672010-09-11 10:47:47 +01001467 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001468 case FBC_STOLEN_TOO_SMALL:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001469 seq_puts(m, "not enough stolen memory");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001470 break;
1471 case FBC_UNSUPPORTED_MODE:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001472 seq_puts(m, "mode not supported");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001473 break;
1474 case FBC_MODE_TOO_LARGE:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001475 seq_puts(m, "mode too large");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001476 break;
1477 case FBC_BAD_PLANE:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001478 seq_puts(m, "FBC unsupported on plane");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001479 break;
1480 case FBC_NOT_TILED:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001481 seq_puts(m, "scanout buffer not tiled");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001482 break;
Jesse Barnes9c928d12010-07-23 15:20:00 -07001483 case FBC_MULTIPLE_PIPES:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001484 seq_puts(m, "multiple pipes are enabled");
Jesse Barnes9c928d12010-07-23 15:20:00 -07001485 break;
Jesse Barnesc1a9f042011-05-05 15:24:21 -07001486 case FBC_MODULE_PARAM:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001487 seq_puts(m, "disabled per module param (default off)");
Jesse Barnesc1a9f042011-05-05 15:24:21 -07001488 break;
Damien Lespiau8a5729a2013-06-24 16:22:02 +01001489 case FBC_CHIP_DEFAULT:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001490 seq_puts(m, "disabled per chip default");
Damien Lespiau8a5729a2013-06-24 16:22:02 +01001491 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001492 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001493 seq_puts(m, "unknown reason");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001494 }
Damien Lespiau267f0c92013-06-24 22:59:48 +01001495 seq_putc(m, '\n');
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001496 }
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001497
1498 intel_runtime_pm_put(dev_priv);
1499
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001500 return 0;
1501}
1502
Paulo Zanoni92d44622013-05-31 16:33:24 -03001503static int i915_ips_status(struct seq_file *m, void *unused)
1504{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001505 struct drm_info_node *node = m->private;
Paulo Zanoni92d44622013-05-31 16:33:24 -03001506 struct drm_device *dev = node->minor->dev;
1507 struct drm_i915_private *dev_priv = dev->dev_private;
1508
Damien Lespiauf5adf942013-06-24 18:29:34 +01001509 if (!HAS_IPS(dev)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001510 seq_puts(m, "not supported\n");
1511 return 0;
1512 }
1513
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001514 intel_runtime_pm_get(dev_priv);
1515
Jesse Barnese59150d2014-01-07 13:30:45 -08001516 if (IS_BROADWELL(dev) || I915_READ(IPS_CTL) & IPS_ENABLE)
Paulo Zanoni92d44622013-05-31 16:33:24 -03001517 seq_puts(m, "enabled\n");
1518 else
1519 seq_puts(m, "disabled\n");
1520
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001521 intel_runtime_pm_put(dev_priv);
1522
Paulo Zanoni92d44622013-05-31 16:33:24 -03001523 return 0;
1524}
1525
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001526static int i915_sr_status(struct seq_file *m, void *unused)
1527{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001528 struct drm_info_node *node = m->private;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001529 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001530 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001531 bool sr_enabled = false;
1532
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001533 intel_runtime_pm_get(dev_priv);
1534
Yuanhan Liu13982612010-12-15 15:42:31 +08001535 if (HAS_PCH_SPLIT(dev))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001536 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Chris Wilsona6c45cf2010-09-17 00:32:17 +01001537 else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001538 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
1539 else if (IS_I915GM(dev))
1540 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
1541 else if (IS_PINEVIEW(dev))
1542 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
1543
Paulo Zanoni36623ef2014-02-21 13:52:23 -03001544 intel_runtime_pm_put(dev_priv);
1545
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001546 seq_printf(m, "self-refresh: %s\n",
1547 sr_enabled ? "enabled" : "disabled");
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001548
1549 return 0;
1550}
1551
Jesse Barnes7648fa92010-05-20 14:28:11 -07001552static int i915_emon_status(struct seq_file *m, void *unused)
1553{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001554 struct drm_info_node *node = m->private;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001555 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001556 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001557 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001558 int ret;
1559
Chris Wilson582be6b2012-04-30 19:35:02 +01001560 if (!IS_GEN5(dev))
1561 return -ENODEV;
1562
Chris Wilsonde227ef2010-07-03 07:58:38 +01001563 ret = mutex_lock_interruptible(&dev->struct_mutex);
1564 if (ret)
1565 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001566
1567 temp = i915_mch_val(dev_priv);
1568 chipset = i915_chipset_val(dev_priv);
1569 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001570 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001571
1572 seq_printf(m, "GMCH temp: %ld\n", temp);
1573 seq_printf(m, "Chipset power: %ld\n", chipset);
1574 seq_printf(m, "GFX power: %ld\n", gfx);
1575 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1576
1577 return 0;
1578}
1579
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001580static int i915_ring_freq_table(struct seq_file *m, void *unused)
1581{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001582 struct drm_info_node *node = m->private;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001583 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001584 struct drm_i915_private *dev_priv = dev->dev_private;
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001585 int ret = 0;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001586 int gpu_freq, ia_freq;
1587
Jesse Barnes1c70c0c2011-06-29 13:34:36 -07001588 if (!(IS_GEN6(dev) || IS_GEN7(dev))) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001589 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001590 return 0;
1591 }
1592
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001593 intel_runtime_pm_get(dev_priv);
1594
Tom O'Rourke5c9669c2013-09-16 14:56:43 -07001595 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
1596
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001597 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001598 if (ret)
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001599 goto out;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001600
Damien Lespiau267f0c92013-06-24 22:59:48 +01001601 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001602
Ben Widawskyb39fb292014-03-19 18:31:11 -07001603 for (gpu_freq = dev_priv->rps.min_freq_softlimit;
1604 gpu_freq <= dev_priv->rps.max_freq_softlimit;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001605 gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001606 ia_freq = gpu_freq;
1607 sandybridge_pcode_read(dev_priv,
1608 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1609 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001610 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
1611 gpu_freq * GT_FREQUENCY_MULTIPLIER,
1612 ((ia_freq >> 0) & 0xff) * 100,
1613 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001614 }
1615
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001616 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001617
Paulo Zanoni5bfa0192013-12-19 11:54:52 -02001618out:
1619 intel_runtime_pm_put(dev_priv);
1620 return ret;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001621}
1622
Jesse Barnes7648fa92010-05-20 14:28:11 -07001623static int i915_gfxec(struct seq_file *m, void *unused)
1624{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001625 struct drm_info_node *node = m->private;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001626 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001627 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001628 int ret;
1629
1630 ret = mutex_lock_interruptible(&dev->struct_mutex);
1631 if (ret)
1632 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001633 intel_runtime_pm_get(dev_priv);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001634
1635 seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001636 intel_runtime_pm_put(dev_priv);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001637
Ben Widawsky616fdb52011-10-05 11:44:54 -07001638 mutex_unlock(&dev->struct_mutex);
1639
Jesse Barnes7648fa92010-05-20 14:28:11 -07001640 return 0;
1641}
1642
Chris Wilson44834a62010-08-19 16:09:23 +01001643static int i915_opregion(struct seq_file *m, void *unused)
1644{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001645 struct drm_info_node *node = m->private;
Chris Wilson44834a62010-08-19 16:09:23 +01001646 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001647 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilson44834a62010-08-19 16:09:23 +01001648 struct intel_opregion *opregion = &dev_priv->opregion;
Daniel Vetter0d38f002012-04-21 22:49:10 +02001649 void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL);
Chris Wilson44834a62010-08-19 16:09:23 +01001650 int ret;
1651
Daniel Vetter0d38f002012-04-21 22:49:10 +02001652 if (data == NULL)
1653 return -ENOMEM;
1654
Chris Wilson44834a62010-08-19 16:09:23 +01001655 ret = mutex_lock_interruptible(&dev->struct_mutex);
1656 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001657 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001658
Daniel Vetter0d38f002012-04-21 22:49:10 +02001659 if (opregion->header) {
1660 memcpy_fromio(data, opregion->header, OPREGION_SIZE);
1661 seq_write(m, data, OPREGION_SIZE);
1662 }
Chris Wilson44834a62010-08-19 16:09:23 +01001663
1664 mutex_unlock(&dev->struct_mutex);
1665
Daniel Vetter0d38f002012-04-21 22:49:10 +02001666out:
1667 kfree(data);
Chris Wilson44834a62010-08-19 16:09:23 +01001668 return 0;
1669}
1670
Chris Wilson37811fc2010-08-25 22:45:57 +01001671static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1672{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001673 struct drm_info_node *node = m->private;
Chris Wilson37811fc2010-08-25 22:45:57 +01001674 struct drm_device *dev = node->minor->dev;
Daniel Vetter4520f532013-10-09 09:18:51 +02001675 struct intel_fbdev *ifbdev = NULL;
Chris Wilson37811fc2010-08-25 22:45:57 +01001676 struct intel_framebuffer *fb;
Chris Wilson37811fc2010-08-25 22:45:57 +01001677
Daniel Vetter4520f532013-10-09 09:18:51 +02001678#ifdef CONFIG_DRM_I915_FBDEV
1679 struct drm_i915_private *dev_priv = dev->dev_private;
1680 int ret = mutex_lock_interruptible(&dev->mode_config.mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001681 if (ret)
1682 return ret;
1683
1684 ifbdev = dev_priv->fbdev;
1685 fb = to_intel_framebuffer(ifbdev->helper.fb);
1686
Daniel Vetter623f9782012-12-11 16:21:38 +01001687 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
Chris Wilson37811fc2010-08-25 22:45:57 +01001688 fb->base.width,
1689 fb->base.height,
1690 fb->base.depth,
Daniel Vetter623f9782012-12-11 16:21:38 +01001691 fb->base.bits_per_pixel,
1692 atomic_read(&fb->base.refcount.refcount));
Chris Wilson05394f32010-11-08 19:18:58 +00001693 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001694 seq_putc(m, '\n');
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001695 mutex_unlock(&dev->mode_config.mutex);
Daniel Vetter4520f532013-10-09 09:18:51 +02001696#endif
Chris Wilson37811fc2010-08-25 22:45:57 +01001697
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001698 mutex_lock(&dev->mode_config.fb_lock);
Chris Wilson37811fc2010-08-25 22:45:57 +01001699 list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
Daniel Vetter131a56d2013-10-17 14:35:31 +02001700 if (ifbdev && &fb->base == ifbdev->helper.fb)
Chris Wilson37811fc2010-08-25 22:45:57 +01001701 continue;
1702
Daniel Vetter623f9782012-12-11 16:21:38 +01001703 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
Chris Wilson37811fc2010-08-25 22:45:57 +01001704 fb->base.width,
1705 fb->base.height,
1706 fb->base.depth,
Daniel Vetter623f9782012-12-11 16:21:38 +01001707 fb->base.bits_per_pixel,
1708 atomic_read(&fb->base.refcount.refcount));
Chris Wilson05394f32010-11-08 19:18:58 +00001709 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001710 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001711 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001712 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson37811fc2010-08-25 22:45:57 +01001713
1714 return 0;
1715}
1716
Ben Widawskye76d3632011-03-19 18:14:29 -07001717static int i915_context_status(struct seq_file *m, void *unused)
1718{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001719 struct drm_info_node *node = m->private;
Ben Widawskye76d3632011-03-19 18:14:29 -07001720 struct drm_device *dev = node->minor->dev;
Jani Nikulae277a1f2014-03-31 14:27:14 +03001721 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +01001722 struct intel_engine_cs *ring;
Oscar Mateo273497e2014-05-22 14:13:37 +01001723 struct intel_context *ctx;
Ben Widawskya168c292013-02-14 15:05:12 -08001724 int ret, i;
Ben Widawskye76d3632011-03-19 18:14:29 -07001725
1726 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
1727 if (ret)
1728 return ret;
1729
Daniel Vetter3e373942012-11-02 19:55:04 +01001730 if (dev_priv->ips.pwrctx) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001731 seq_puts(m, "power context ");
Daniel Vetter3e373942012-11-02 19:55:04 +01001732 describe_obj(m, dev_priv->ips.pwrctx);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001733 seq_putc(m, '\n');
Ben Widawskydc501fb2011-06-29 11:41:51 -07001734 }
Ben Widawskye76d3632011-03-19 18:14:29 -07001735
Daniel Vetter3e373942012-11-02 19:55:04 +01001736 if (dev_priv->ips.renderctx) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001737 seq_puts(m, "render context ");
Daniel Vetter3e373942012-11-02 19:55:04 +01001738 describe_obj(m, dev_priv->ips.renderctx);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001739 seq_putc(m, '\n');
Ben Widawskydc501fb2011-06-29 11:41:51 -07001740 }
Ben Widawskye76d3632011-03-19 18:14:29 -07001741
Ben Widawskya33afea2013-09-17 21:12:45 -07001742 list_for_each_entry(ctx, &dev_priv->context_list, link) {
Chris Wilsonb77f6992014-04-30 08:30:00 +01001743 if (ctx->obj == NULL)
1744 continue;
1745
Ben Widawskya33afea2013-09-17 21:12:45 -07001746 seq_puts(m, "HW context ");
Ben Widawsky3ccfd192013-09-18 19:03:18 -07001747 describe_ctx(m, ctx);
Ben Widawskya33afea2013-09-17 21:12:45 -07001748 for_each_ring(ring, dev_priv, i)
1749 if (ring->default_context == ctx)
1750 seq_printf(m, "(default context %s) ", ring->name);
1751
1752 describe_obj(m, ctx->obj);
1753 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08001754 }
1755
Ben Widawskye76d3632011-03-19 18:14:29 -07001756 mutex_unlock(&dev->mode_config.mutex);
1757
1758 return 0;
1759}
1760
Ben Widawsky6d794d42011-04-25 11:25:56 -07001761static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
1762{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001763 struct drm_info_node *node = m->private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07001764 struct drm_device *dev = node->minor->dev;
1765 struct drm_i915_private *dev_priv = dev->dev_private;
Deepak S43709ba2013-11-23 14:55:44 +05301766 unsigned forcewake_count = 0, fw_rendercount = 0, fw_mediacount = 0;
Ben Widawsky6d794d42011-04-25 11:25:56 -07001767
Chris Wilson907b28c2013-07-19 20:36:52 +01001768 spin_lock_irq(&dev_priv->uncore.lock);
Deepak S43709ba2013-11-23 14:55:44 +05301769 if (IS_VALLEYVIEW(dev)) {
1770 fw_rendercount = dev_priv->uncore.fw_rendercount;
1771 fw_mediacount = dev_priv->uncore.fw_mediacount;
1772 } else
1773 forcewake_count = dev_priv->uncore.forcewake_count;
Chris Wilson907b28c2013-07-19 20:36:52 +01001774 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter9f1f46a2011-12-14 13:57:03 +01001775
Deepak S43709ba2013-11-23 14:55:44 +05301776 if (IS_VALLEYVIEW(dev)) {
1777 seq_printf(m, "fw_rendercount = %u\n", fw_rendercount);
1778 seq_printf(m, "fw_mediacount = %u\n", fw_mediacount);
1779 } else
1780 seq_printf(m, "forcewake count = %u\n", forcewake_count);
Ben Widawsky6d794d42011-04-25 11:25:56 -07001781
1782 return 0;
1783}
1784
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001785static const char *swizzle_string(unsigned swizzle)
1786{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001787 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001788 case I915_BIT_6_SWIZZLE_NONE:
1789 return "none";
1790 case I915_BIT_6_SWIZZLE_9:
1791 return "bit9";
1792 case I915_BIT_6_SWIZZLE_9_10:
1793 return "bit9/bit10";
1794 case I915_BIT_6_SWIZZLE_9_11:
1795 return "bit9/bit11";
1796 case I915_BIT_6_SWIZZLE_9_10_11:
1797 return "bit9/bit10/bit11";
1798 case I915_BIT_6_SWIZZLE_9_17:
1799 return "bit9/bit17";
1800 case I915_BIT_6_SWIZZLE_9_10_17:
1801 return "bit9/bit10/bit17";
1802 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09001803 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001804 }
1805
1806 return "bug";
1807}
1808
1809static int i915_swizzle_info(struct seq_file *m, void *data)
1810{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001811 struct drm_info_node *node = m->private;
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001812 struct drm_device *dev = node->minor->dev;
1813 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter22bcfc62012-08-09 15:07:02 +02001814 int ret;
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001815
Daniel Vetter22bcfc62012-08-09 15:07:02 +02001816 ret = mutex_lock_interruptible(&dev->struct_mutex);
1817 if (ret)
1818 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001819 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02001820
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001821 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
1822 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
1823 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
1824 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
1825
1826 if (IS_GEN3(dev) || IS_GEN4(dev)) {
1827 seq_printf(m, "DDC = 0x%08x\n",
1828 I915_READ(DCC));
1829 seq_printf(m, "C0DRB3 = 0x%04x\n",
1830 I915_READ16(C0DRB3));
1831 seq_printf(m, "C1DRB3 = 0x%04x\n",
1832 I915_READ16(C1DRB3));
Ben Widawsky9d3203e2013-11-02 21:07:14 -07001833 } else if (INTEL_INFO(dev)->gen >= 6) {
Daniel Vetter3fa7d232012-01-31 16:47:56 +01001834 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
1835 I915_READ(MAD_DIMM_C0));
1836 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
1837 I915_READ(MAD_DIMM_C1));
1838 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
1839 I915_READ(MAD_DIMM_C2));
1840 seq_printf(m, "TILECTL = 0x%08x\n",
1841 I915_READ(TILECTL));
Ben Widawsky9d3203e2013-11-02 21:07:14 -07001842 if (IS_GEN8(dev))
1843 seq_printf(m, "GAMTARBMODE = 0x%08x\n",
1844 I915_READ(GAMTARBMODE));
1845 else
1846 seq_printf(m, "ARB_MODE = 0x%08x\n",
1847 I915_READ(ARB_MODE));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01001848 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
1849 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001850 }
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001851 intel_runtime_pm_put(dev_priv);
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001852 mutex_unlock(&dev->struct_mutex);
1853
1854 return 0;
1855}
1856
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001857static int per_file_ctx(int id, void *ptr, void *data)
1858{
Oscar Mateo273497e2014-05-22 14:13:37 +01001859 struct intel_context *ctx = ptr;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001860 struct seq_file *m = data;
1861 struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx);
1862
Oscar Mateof83d6512014-05-22 14:13:38 +01001863 if (i915_gem_context_is_default(ctx))
1864 seq_puts(m, " default context:\n");
1865 else
1866 seq_printf(m, " context %d:\n", ctx->id);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001867 ppgtt->debug_dump(ppgtt, m);
1868
1869 return 0;
1870}
1871
Ben Widawsky77df6772013-11-02 21:07:30 -07001872static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev)
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001873{
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001874 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +01001875 struct intel_engine_cs *ring;
Ben Widawsky77df6772013-11-02 21:07:30 -07001876 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
1877 int unused, i;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001878
Ben Widawsky77df6772013-11-02 21:07:30 -07001879 if (!ppgtt)
1880 return;
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001881
Ben Widawsky77df6772013-11-02 21:07:30 -07001882 seq_printf(m, "Page directories: %d\n", ppgtt->num_pd_pages);
Ben Widawsky5abbcca2014-02-21 13:06:34 -08001883 seq_printf(m, "Page tables: %d\n", ppgtt->num_pd_entries);
Ben Widawsky77df6772013-11-02 21:07:30 -07001884 for_each_ring(ring, dev_priv, unused) {
1885 seq_printf(m, "%s\n", ring->name);
1886 for (i = 0; i < 4; i++) {
1887 u32 offset = 0x270 + i * 8;
1888 u64 pdp = I915_READ(ring->mmio_base + offset + 4);
1889 pdp <<= 32;
1890 pdp |= I915_READ(ring->mmio_base + offset);
Ville Syrjäläa2a5b152014-03-31 18:17:16 +03001891 seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp);
Ben Widawsky77df6772013-11-02 21:07:30 -07001892 }
1893 }
1894}
1895
1896static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev)
1897{
1898 struct drm_i915_private *dev_priv = dev->dev_private;
Oscar Mateoa4872ba2014-05-22 14:13:33 +01001899 struct intel_engine_cs *ring;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001900 struct drm_file *file;
Ben Widawsky77df6772013-11-02 21:07:30 -07001901 int i;
1902
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001903 if (INTEL_INFO(dev)->gen == 6)
1904 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
1905
Chris Wilsona2c7f6f2012-09-01 20:51:22 +01001906 for_each_ring(ring, dev_priv, i) {
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001907 seq_printf(m, "%s\n", ring->name);
1908 if (INTEL_INFO(dev)->gen == 7)
1909 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring)));
1910 seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring)));
1911 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring)));
1912 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring)));
1913 }
1914 if (dev_priv->mm.aliasing_ppgtt) {
1915 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
1916
Damien Lespiau267f0c92013-06-24 22:59:48 +01001917 seq_puts(m, "aliasing PPGTT:\n");
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001918 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001919
Ben Widawsky87d60b62013-12-06 14:11:29 -08001920 ppgtt->debug_dump(ppgtt, m);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001921 } else
1922 return;
1923
1924 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
1925 struct drm_i915_file_private *file_priv = file->driver_priv;
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001926
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001927 seq_printf(m, "proc: %s\n",
1928 get_pid_task(file->pid, PIDTYPE_PID)->comm);
Ben Widawsky1c60fef2013-12-06 14:11:30 -08001929 idr_for_each(&file_priv->context_idr, per_file_ctx, m);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001930 }
1931 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
Ben Widawsky77df6772013-11-02 21:07:30 -07001932}
1933
1934static int i915_ppgtt_info(struct seq_file *m, void *data)
1935{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001936 struct drm_info_node *node = m->private;
Ben Widawsky77df6772013-11-02 21:07:30 -07001937 struct drm_device *dev = node->minor->dev;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001938 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawsky77df6772013-11-02 21:07:30 -07001939
1940 int ret = mutex_lock_interruptible(&dev->struct_mutex);
1941 if (ret)
1942 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001943 intel_runtime_pm_get(dev_priv);
Ben Widawsky77df6772013-11-02 21:07:30 -07001944
1945 if (INTEL_INFO(dev)->gen >= 8)
1946 gen8_ppgtt_info(m, dev);
1947 else if (INTEL_INFO(dev)->gen >= 6)
1948 gen6_ppgtt_info(m, dev);
1949
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001950 intel_runtime_pm_put(dev_priv);
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001951 mutex_unlock(&dev->struct_mutex);
1952
1953 return 0;
1954}
1955
Ben Widawsky63573eb2013-07-04 11:02:07 -07001956static int i915_llc(struct seq_file *m, void *data)
1957{
Damien Lespiau9f25d002014-05-13 15:30:28 +01001958 struct drm_info_node *node = m->private;
Ben Widawsky63573eb2013-07-04 11:02:07 -07001959 struct drm_device *dev = node->minor->dev;
1960 struct drm_i915_private *dev_priv = dev->dev_private;
1961
1962 /* Size calculation for LLC is a bit of a pain. Ignore for now. */
1963 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev)));
1964 seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size);
1965
1966 return 0;
1967}
1968
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001969static int i915_edp_psr_status(struct seq_file *m, void *data)
1970{
1971 struct drm_info_node *node = m->private;
1972 struct drm_device *dev = node->minor->dev;
1973 struct drm_i915_private *dev_priv = dev->dev_private;
Rodrigo Vivia031d702013-10-03 16:15:06 -03001974 u32 psrperf = 0;
1975 bool enabled = false;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001976
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001977 intel_runtime_pm_get(dev_priv);
1978
Rodrigo Vivia031d702013-10-03 16:15:06 -03001979 seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
1980 seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001981
Rodrigo Vivia031d702013-10-03 16:15:06 -03001982 enabled = HAS_PSR(dev) &&
1983 I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE;
1984 seq_printf(m, "Enabled: %s\n", yesno(enabled));
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001985
Rodrigo Vivia031d702013-10-03 16:15:06 -03001986 if (HAS_PSR(dev))
1987 psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) &
1988 EDP_PSR_PERF_CNT_MASK;
1989 seq_printf(m, "Performance_Counter: %u\n", psrperf);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001990
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02001991 intel_runtime_pm_put(dev_priv);
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001992 return 0;
1993}
1994
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02001995static int i915_sink_crc(struct seq_file *m, void *data)
1996{
1997 struct drm_info_node *node = m->private;
1998 struct drm_device *dev = node->minor->dev;
1999 struct intel_encoder *encoder;
2000 struct intel_connector *connector;
2001 struct intel_dp *intel_dp = NULL;
2002 int ret;
2003 u8 crc[6];
2004
2005 drm_modeset_lock_all(dev);
2006 list_for_each_entry(connector, &dev->mode_config.connector_list,
2007 base.head) {
2008
2009 if (connector->base.dpms != DRM_MODE_DPMS_ON)
2010 continue;
2011
Paulo Zanonib6ae3c72014-02-13 17:51:33 -02002012 if (!connector->base.encoder)
2013 continue;
2014
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02002015 encoder = to_intel_encoder(connector->base.encoder);
2016 if (encoder->type != INTEL_OUTPUT_EDP)
2017 continue;
2018
2019 intel_dp = enc_to_intel_dp(&encoder->base);
2020
2021 ret = intel_dp_sink_crc(intel_dp, crc);
2022 if (ret)
2023 goto out;
2024
2025 seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
2026 crc[0], crc[1], crc[2],
2027 crc[3], crc[4], crc[5]);
2028 goto out;
2029 }
2030 ret = -ENODEV;
2031out:
2032 drm_modeset_unlock_all(dev);
2033 return ret;
2034}
2035
Jesse Barnesec013e72013-08-20 10:29:23 +01002036static int i915_energy_uJ(struct seq_file *m, void *data)
2037{
2038 struct drm_info_node *node = m->private;
2039 struct drm_device *dev = node->minor->dev;
2040 struct drm_i915_private *dev_priv = dev->dev_private;
2041 u64 power;
2042 u32 units;
2043
2044 if (INTEL_INFO(dev)->gen < 6)
2045 return -ENODEV;
2046
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002047 intel_runtime_pm_get(dev_priv);
2048
Jesse Barnesec013e72013-08-20 10:29:23 +01002049 rdmsrl(MSR_RAPL_POWER_UNIT, power);
2050 power = (power & 0x1f00) >> 8;
2051 units = 1000000 / (1 << power); /* convert to uJ */
2052 power = I915_READ(MCH_SECP_NRG_STTS);
2053 power *= units;
2054
Paulo Zanoni36623ef2014-02-21 13:52:23 -03002055 intel_runtime_pm_put(dev_priv);
2056
Jesse Barnesec013e72013-08-20 10:29:23 +01002057 seq_printf(m, "%llu", (long long unsigned)power);
Paulo Zanoni371db662013-08-19 13:18:10 -03002058
2059 return 0;
2060}
2061
2062static int i915_pc8_status(struct seq_file *m, void *unused)
2063{
Damien Lespiau9f25d002014-05-13 15:30:28 +01002064 struct drm_info_node *node = m->private;
Paulo Zanoni371db662013-08-19 13:18:10 -03002065 struct drm_device *dev = node->minor->dev;
2066 struct drm_i915_private *dev_priv = dev->dev_private;
2067
Zhenyu Wang85b8d5c2014-04-01 19:39:48 -03002068 if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
Paulo Zanoni371db662013-08-19 13:18:10 -03002069 seq_puts(m, "not supported\n");
2070 return 0;
2071 }
2072
Paulo Zanoni86c4ec02014-02-21 13:52:24 -03002073 seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy));
Paulo Zanoni371db662013-08-19 13:18:10 -03002074 seq_printf(m, "IRQs disabled: %s\n",
Paulo Zanoni5d584b22014-03-07 20:08:15 -03002075 yesno(dev_priv->pm.irqs_disabled));
Paulo Zanoni371db662013-08-19 13:18:10 -03002076
Jesse Barnesec013e72013-08-20 10:29:23 +01002077 return 0;
2078}
2079
Imre Deak1da51582013-11-25 17:15:35 +02002080static const char *power_domain_str(enum intel_display_power_domain domain)
2081{
2082 switch (domain) {
2083 case POWER_DOMAIN_PIPE_A:
2084 return "PIPE_A";
2085 case POWER_DOMAIN_PIPE_B:
2086 return "PIPE_B";
2087 case POWER_DOMAIN_PIPE_C:
2088 return "PIPE_C";
2089 case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
2090 return "PIPE_A_PANEL_FITTER";
2091 case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
2092 return "PIPE_B_PANEL_FITTER";
2093 case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
2094 return "PIPE_C_PANEL_FITTER";
2095 case POWER_DOMAIN_TRANSCODER_A:
2096 return "TRANSCODER_A";
2097 case POWER_DOMAIN_TRANSCODER_B:
2098 return "TRANSCODER_B";
2099 case POWER_DOMAIN_TRANSCODER_C:
2100 return "TRANSCODER_C";
2101 case POWER_DOMAIN_TRANSCODER_EDP:
2102 return "TRANSCODER_EDP";
Imre Deak319be8a2014-03-04 19:22:57 +02002103 case POWER_DOMAIN_PORT_DDI_A_2_LANES:
2104 return "PORT_DDI_A_2_LANES";
2105 case POWER_DOMAIN_PORT_DDI_A_4_LANES:
2106 return "PORT_DDI_A_4_LANES";
2107 case POWER_DOMAIN_PORT_DDI_B_2_LANES:
2108 return "PORT_DDI_B_2_LANES";
2109 case POWER_DOMAIN_PORT_DDI_B_4_LANES:
2110 return "PORT_DDI_B_4_LANES";
2111 case POWER_DOMAIN_PORT_DDI_C_2_LANES:
2112 return "PORT_DDI_C_2_LANES";
2113 case POWER_DOMAIN_PORT_DDI_C_4_LANES:
2114 return "PORT_DDI_C_4_LANES";
2115 case POWER_DOMAIN_PORT_DDI_D_2_LANES:
2116 return "PORT_DDI_D_2_LANES";
2117 case POWER_DOMAIN_PORT_DDI_D_4_LANES:
2118 return "PORT_DDI_D_4_LANES";
2119 case POWER_DOMAIN_PORT_DSI:
2120 return "PORT_DSI";
2121 case POWER_DOMAIN_PORT_CRT:
2122 return "PORT_CRT";
2123 case POWER_DOMAIN_PORT_OTHER:
2124 return "PORT_OTHER";
Imre Deak1da51582013-11-25 17:15:35 +02002125 case POWER_DOMAIN_VGA:
2126 return "VGA";
2127 case POWER_DOMAIN_AUDIO:
2128 return "AUDIO";
2129 case POWER_DOMAIN_INIT:
2130 return "INIT";
2131 default:
2132 WARN_ON(1);
2133 return "?";
2134 }
2135}
2136
2137static int i915_power_domain_info(struct seq_file *m, void *unused)
2138{
Damien Lespiau9f25d002014-05-13 15:30:28 +01002139 struct drm_info_node *node = m->private;
Imre Deak1da51582013-11-25 17:15:35 +02002140 struct drm_device *dev = node->minor->dev;
2141 struct drm_i915_private *dev_priv = dev->dev_private;
2142 struct i915_power_domains *power_domains = &dev_priv->power_domains;
2143 int i;
2144
2145 mutex_lock(&power_domains->lock);
2146
2147 seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count");
2148 for (i = 0; i < power_domains->power_well_count; i++) {
2149 struct i915_power_well *power_well;
2150 enum intel_display_power_domain power_domain;
2151
2152 power_well = &power_domains->power_wells[i];
2153 seq_printf(m, "%-25s %d\n", power_well->name,
2154 power_well->count);
2155
2156 for (power_domain = 0; power_domain < POWER_DOMAIN_NUM;
2157 power_domain++) {
2158 if (!(BIT(power_domain) & power_well->domains))
2159 continue;
2160
2161 seq_printf(m, " %-23s %d\n",
2162 power_domain_str(power_domain),
2163 power_domains->domain_use_count[power_domain]);
2164 }
2165 }
2166
2167 mutex_unlock(&power_domains->lock);
2168
2169 return 0;
2170}
2171
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002172static void intel_seq_print_mode(struct seq_file *m, int tabs,
2173 struct drm_display_mode *mode)
2174{
2175 int i;
2176
2177 for (i = 0; i < tabs; i++)
2178 seq_putc(m, '\t');
2179
2180 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",
2181 mode->base.id, mode->name,
2182 mode->vrefresh, mode->clock,
2183 mode->hdisplay, mode->hsync_start,
2184 mode->hsync_end, mode->htotal,
2185 mode->vdisplay, mode->vsync_start,
2186 mode->vsync_end, mode->vtotal,
2187 mode->type, mode->flags);
2188}
2189
2190static void intel_encoder_info(struct seq_file *m,
2191 struct intel_crtc *intel_crtc,
2192 struct intel_encoder *intel_encoder)
2193{
Damien Lespiau9f25d002014-05-13 15:30:28 +01002194 struct drm_info_node *node = m->private;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002195 struct drm_device *dev = node->minor->dev;
2196 struct drm_crtc *crtc = &intel_crtc->base;
2197 struct intel_connector *intel_connector;
2198 struct drm_encoder *encoder;
2199
2200 encoder = &intel_encoder->base;
2201 seq_printf(m, "\tencoder %d: type: %s, connectors:\n",
Jani Nikula8e329a02014-06-03 14:56:21 +03002202 encoder->base.id, encoder->name);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002203 for_each_connector_on_encoder(dev, encoder, intel_connector) {
2204 struct drm_connector *connector = &intel_connector->base;
2205 seq_printf(m, "\t\tconnector %d: type: %s, status: %s",
2206 connector->base.id,
Jani Nikulac23cc412014-06-03 14:56:17 +03002207 connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002208 drm_get_connector_status_name(connector->status));
2209 if (connector->status == connector_status_connected) {
2210 struct drm_display_mode *mode = &crtc->mode;
2211 seq_printf(m, ", mode:\n");
2212 intel_seq_print_mode(m, 2, mode);
2213 } else {
2214 seq_putc(m, '\n');
2215 }
2216 }
2217}
2218
2219static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc)
2220{
Damien Lespiau9f25d002014-05-13 15:30:28 +01002221 struct drm_info_node *node = m->private;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002222 struct drm_device *dev = node->minor->dev;
2223 struct drm_crtc *crtc = &intel_crtc->base;
2224 struct intel_encoder *intel_encoder;
2225
2226 seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n",
Matt Roperf4510a22014-04-01 15:22:40 -07002227 crtc->primary->fb->base.id, crtc->x, crtc->y,
2228 crtc->primary->fb->width, crtc->primary->fb->height);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002229 for_each_encoder_on_crtc(dev, crtc, intel_encoder)
2230 intel_encoder_info(m, intel_crtc, intel_encoder);
2231}
2232
2233static void intel_panel_info(struct seq_file *m, struct intel_panel *panel)
2234{
2235 struct drm_display_mode *mode = panel->fixed_mode;
2236
2237 seq_printf(m, "\tfixed mode:\n");
2238 intel_seq_print_mode(m, 2, mode);
2239}
2240
2241static void intel_dp_info(struct seq_file *m,
2242 struct intel_connector *intel_connector)
2243{
2244 struct intel_encoder *intel_encoder = intel_connector->encoder;
2245 struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
2246
2247 seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
2248 seq_printf(m, "\taudio support: %s\n", intel_dp->has_audio ? "yes" :
2249 "no");
2250 if (intel_encoder->type == INTEL_OUTPUT_EDP)
2251 intel_panel_info(m, &intel_connector->panel);
2252}
2253
2254static void intel_hdmi_info(struct seq_file *m,
2255 struct intel_connector *intel_connector)
2256{
2257 struct intel_encoder *intel_encoder = intel_connector->encoder;
2258 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
2259
2260 seq_printf(m, "\taudio support: %s\n", intel_hdmi->has_audio ? "yes" :
2261 "no");
2262}
2263
2264static void intel_lvds_info(struct seq_file *m,
2265 struct intel_connector *intel_connector)
2266{
2267 intel_panel_info(m, &intel_connector->panel);
2268}
2269
2270static void intel_connector_info(struct seq_file *m,
2271 struct drm_connector *connector)
2272{
2273 struct intel_connector *intel_connector = to_intel_connector(connector);
2274 struct intel_encoder *intel_encoder = intel_connector->encoder;
Jesse Barnesf103fc72014-02-20 12:39:57 -08002275 struct drm_display_mode *mode;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002276
2277 seq_printf(m, "connector %d: type %s, status: %s\n",
Jani Nikulac23cc412014-06-03 14:56:17 +03002278 connector->base.id, connector->name,
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002279 drm_get_connector_status_name(connector->status));
2280 if (connector->status == connector_status_connected) {
2281 seq_printf(m, "\tname: %s\n", connector->display_info.name);
2282 seq_printf(m, "\tphysical dimensions: %dx%dmm\n",
2283 connector->display_info.width_mm,
2284 connector->display_info.height_mm);
2285 seq_printf(m, "\tsubpixel order: %s\n",
2286 drm_get_subpixel_order_name(connector->display_info.subpixel_order));
2287 seq_printf(m, "\tCEA rev: %d\n",
2288 connector->display_info.cea_rev);
2289 }
2290 if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT ||
2291 intel_encoder->type == INTEL_OUTPUT_EDP)
2292 intel_dp_info(m, intel_connector);
2293 else if (intel_encoder->type == INTEL_OUTPUT_HDMI)
2294 intel_hdmi_info(m, intel_connector);
2295 else if (intel_encoder->type == INTEL_OUTPUT_LVDS)
2296 intel_lvds_info(m, intel_connector);
2297
Jesse Barnesf103fc72014-02-20 12:39:57 -08002298 seq_printf(m, "\tmodes:\n");
2299 list_for_each_entry(mode, &connector->modes, head)
2300 intel_seq_print_mode(m, 2, mode);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002301}
2302
Chris Wilson065f2ec2014-03-12 09:13:13 +00002303static bool cursor_active(struct drm_device *dev, int pipe)
2304{
2305 struct drm_i915_private *dev_priv = dev->dev_private;
2306 u32 state;
2307
2308 if (IS_845G(dev) || IS_I865G(dev))
2309 state = I915_READ(_CURACNTR) & CURSOR_ENABLE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00002310 else
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03002311 state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
Chris Wilson065f2ec2014-03-12 09:13:13 +00002312
2313 return state;
2314}
2315
2316static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y)
2317{
2318 struct drm_i915_private *dev_priv = dev->dev_private;
2319 u32 pos;
2320
Ville Syrjälä5efb3e22014-04-09 13:28:53 +03002321 pos = I915_READ(CURPOS(pipe));
Chris Wilson065f2ec2014-03-12 09:13:13 +00002322
2323 *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK;
2324 if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT))
2325 *x = -*x;
2326
2327 *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK;
2328 if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT))
2329 *y = -*y;
2330
2331 return cursor_active(dev, pipe);
2332}
2333
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002334static int i915_display_info(struct seq_file *m, void *unused)
2335{
Damien Lespiau9f25d002014-05-13 15:30:28 +01002336 struct drm_info_node *node = m->private;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002337 struct drm_device *dev = node->minor->dev;
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03002338 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilson065f2ec2014-03-12 09:13:13 +00002339 struct intel_crtc *crtc;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002340 struct drm_connector *connector;
2341
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03002342 intel_runtime_pm_get(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002343 drm_modeset_lock_all(dev);
2344 seq_printf(m, "CRTC info\n");
2345 seq_printf(m, "---------\n");
Damien Lespiaud3fcc802014-05-13 23:32:22 +01002346 for_each_intel_crtc(dev, crtc) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00002347 bool active;
2348 int x, y;
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002349
2350 seq_printf(m, "CRTC %d: pipe: %c, active: %s\n",
Chris Wilson065f2ec2014-03-12 09:13:13 +00002351 crtc->base.base.id, pipe_name(crtc->pipe),
2352 yesno(crtc->active));
Paulo Zanonia23dc652014-04-01 14:55:11 -03002353 if (crtc->active) {
Chris Wilson065f2ec2014-03-12 09:13:13 +00002354 intel_crtc_info(m, crtc);
2355
Paulo Zanonia23dc652014-04-01 14:55:11 -03002356 active = cursor_position(dev, crtc->pipe, &x, &y);
2357 seq_printf(m, "\tcursor visible? %s, position (%d, %d), addr 0x%08x, active? %s\n",
Chris Wilson4b0e3332014-05-30 16:35:26 +03002358 yesno(crtc->cursor_base),
Paulo Zanonia23dc652014-04-01 14:55:11 -03002359 x, y, crtc->cursor_addr,
2360 yesno(active));
2361 }
Daniel Vettercace8412014-05-22 17:56:31 +02002362
2363 seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n",
2364 yesno(!crtc->cpu_fifo_underrun_disabled),
2365 yesno(!crtc->pch_fifo_underrun_disabled));
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002366 }
2367
2368 seq_printf(m, "\n");
2369 seq_printf(m, "Connector info\n");
2370 seq_printf(m, "--------------\n");
2371 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2372 intel_connector_info(m, connector);
2373 }
2374 drm_modeset_unlock_all(dev);
Paulo Zanonib0e5ddf2014-04-01 14:55:10 -03002375 intel_runtime_pm_put(dev_priv);
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08002376
2377 return 0;
2378}
2379
Damien Lespiau07144422013-10-15 18:55:40 +01002380struct pipe_crc_info {
2381 const char *name;
2382 struct drm_device *dev;
2383 enum pipe pipe;
2384};
2385
2386static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
Shuang He8bf1e9f2013-10-15 18:55:27 +01002387{
Damien Lespiaube5c7a92013-10-15 18:55:41 +01002388 struct pipe_crc_info *info = inode->i_private;
2389 struct drm_i915_private *dev_priv = info->dev->dev_private;
2390 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
2391
Daniel Vetter7eb1c492013-11-14 11:30:43 +01002392 if (info->pipe >= INTEL_INFO(info->dev)->num_pipes)
2393 return -ENODEV;
2394
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002395 spin_lock_irq(&pipe_crc->lock);
2396
2397 if (pipe_crc->opened) {
2398 spin_unlock_irq(&pipe_crc->lock);
Damien Lespiaube5c7a92013-10-15 18:55:41 +01002399 return -EBUSY; /* already open */
2400 }
2401
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002402 pipe_crc->opened = true;
Damien Lespiau07144422013-10-15 18:55:40 +01002403 filep->private_data = inode->i_private;
2404
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002405 spin_unlock_irq(&pipe_crc->lock);
2406
Damien Lespiau07144422013-10-15 18:55:40 +01002407 return 0;
2408}
2409
2410static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
2411{
Damien Lespiaube5c7a92013-10-15 18:55:41 +01002412 struct pipe_crc_info *info = inode->i_private;
2413 struct drm_i915_private *dev_priv = info->dev->dev_private;
2414 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
2415
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002416 spin_lock_irq(&pipe_crc->lock);
2417 pipe_crc->opened = false;
2418 spin_unlock_irq(&pipe_crc->lock);
Damien Lespiaube5c7a92013-10-15 18:55:41 +01002419
Damien Lespiau07144422013-10-15 18:55:40 +01002420 return 0;
2421}
2422
2423/* (6 fields, 8 chars each, space separated (5) + '\n') */
2424#define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1)
2425/* account for \'0' */
2426#define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
2427
2428static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
2429{
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002430 assert_spin_locked(&pipe_crc->lock);
2431 return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
2432 INTEL_PIPE_CRC_ENTRIES_NR);
Damien Lespiau07144422013-10-15 18:55:40 +01002433}
Shuang He8bf1e9f2013-10-15 18:55:27 +01002434
Damien Lespiau07144422013-10-15 18:55:40 +01002435static ssize_t
2436i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
2437 loff_t *pos)
2438{
2439 struct pipe_crc_info *info = filep->private_data;
2440 struct drm_device *dev = info->dev;
2441 struct drm_i915_private *dev_priv = dev->dev_private;
2442 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
2443 char buf[PIPE_CRC_BUFFER_LEN];
2444 int head, tail, n_entries, n;
2445 ssize_t bytes_read;
2446
2447 /*
2448 * Don't allow user space to provide buffers not big enough to hold
2449 * a line of data.
2450 */
2451 if (count < PIPE_CRC_LINE_LEN)
2452 return -EINVAL;
2453
2454 if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
2455 return 0;
2456
2457 /* nothing to read */
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002458 spin_lock_irq(&pipe_crc->lock);
Damien Lespiau07144422013-10-15 18:55:40 +01002459 while (pipe_crc_data_count(pipe_crc) == 0) {
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002460 int ret;
Damien Lespiau07144422013-10-15 18:55:40 +01002461
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002462 if (filep->f_flags & O_NONBLOCK) {
2463 spin_unlock_irq(&pipe_crc->lock);
2464 return -EAGAIN;
2465 }
2466
2467 ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
2468 pipe_crc_data_count(pipe_crc), pipe_crc->lock);
2469 if (ret) {
2470 spin_unlock_irq(&pipe_crc->lock);
2471 return ret;
2472 }
Damien Lespiau07144422013-10-15 18:55:40 +01002473 }
2474
2475 /* We now have one or more entries to read */
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002476 head = pipe_crc->head;
2477 tail = pipe_crc->tail;
Damien Lespiau07144422013-10-15 18:55:40 +01002478 n_entries = min((size_t)CIRC_CNT(head, tail, INTEL_PIPE_CRC_ENTRIES_NR),
2479 count / PIPE_CRC_LINE_LEN);
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002480 spin_unlock_irq(&pipe_crc->lock);
2481
Damien Lespiau07144422013-10-15 18:55:40 +01002482 bytes_read = 0;
2483 n = 0;
2484 do {
2485 struct intel_pipe_crc_entry *entry = &pipe_crc->entries[tail];
2486 int ret;
2487
2488 bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN,
2489 "%8u %8x %8x %8x %8x %8x\n",
2490 entry->frame, entry->crc[0],
2491 entry->crc[1], entry->crc[2],
2492 entry->crc[3], entry->crc[4]);
2493
2494 ret = copy_to_user(user_buf + n * PIPE_CRC_LINE_LEN,
2495 buf, PIPE_CRC_LINE_LEN);
2496 if (ret == PIPE_CRC_LINE_LEN)
2497 return -EFAULT;
Damien Lespiaub2c88f52013-10-15 18:55:29 +01002498
2499 BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR);
2500 tail = (tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
Damien Lespiau07144422013-10-15 18:55:40 +01002501 n++;
2502 } while (--n_entries);
Shuang He8bf1e9f2013-10-15 18:55:27 +01002503
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002504 spin_lock_irq(&pipe_crc->lock);
2505 pipe_crc->tail = tail;
2506 spin_unlock_irq(&pipe_crc->lock);
2507
Damien Lespiau07144422013-10-15 18:55:40 +01002508 return bytes_read;
2509}
2510
2511static const struct file_operations i915_pipe_crc_fops = {
2512 .owner = THIS_MODULE,
2513 .open = i915_pipe_crc_open,
2514 .read = i915_pipe_crc_read,
2515 .release = i915_pipe_crc_release,
2516};
2517
2518static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = {
2519 {
2520 .name = "i915_pipe_A_crc",
2521 .pipe = PIPE_A,
2522 },
2523 {
2524 .name = "i915_pipe_B_crc",
2525 .pipe = PIPE_B,
2526 },
2527 {
2528 .name = "i915_pipe_C_crc",
2529 .pipe = PIPE_C,
2530 },
2531};
2532
2533static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor,
2534 enum pipe pipe)
2535{
2536 struct drm_device *dev = minor->dev;
2537 struct dentry *ent;
2538 struct pipe_crc_info *info = &i915_pipe_crc_data[pipe];
2539
2540 info->dev = dev;
2541 ent = debugfs_create_file(info->name, S_IRUGO, root, info,
2542 &i915_pipe_crc_fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08002543 if (!ent)
2544 return -ENOMEM;
Damien Lespiau07144422013-10-15 18:55:40 +01002545
2546 return drm_add_fake_info_node(minor, ent, info);
Shuang He8bf1e9f2013-10-15 18:55:27 +01002547}
2548
Daniel Vettere8dfcf72013-10-16 11:51:54 +02002549static const char * const pipe_crc_sources[] = {
Daniel Vetter926321d2013-10-16 13:30:34 +02002550 "none",
2551 "plane1",
2552 "plane2",
2553 "pf",
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002554 "pipe",
Daniel Vetter3d099a02013-10-16 22:55:58 +02002555 "TV",
2556 "DP-B",
2557 "DP-C",
2558 "DP-D",
Daniel Vetter46a19182013-11-01 10:50:20 +01002559 "auto",
Daniel Vetter926321d2013-10-16 13:30:34 +02002560};
2561
2562static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
2563{
2564 BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX);
2565 return pipe_crc_sources[source];
2566}
2567
Damien Lespiaubd9db022013-10-15 18:55:36 +01002568static int display_crc_ctl_show(struct seq_file *m, void *data)
Daniel Vetter926321d2013-10-16 13:30:34 +02002569{
2570 struct drm_device *dev = m->private;
2571 struct drm_i915_private *dev_priv = dev->dev_private;
2572 int i;
2573
2574 for (i = 0; i < I915_MAX_PIPES; i++)
2575 seq_printf(m, "%c %s\n", pipe_name(i),
2576 pipe_crc_source_name(dev_priv->pipe_crc[i].source));
2577
2578 return 0;
2579}
2580
Damien Lespiaubd9db022013-10-15 18:55:36 +01002581static int display_crc_ctl_open(struct inode *inode, struct file *file)
Daniel Vetter926321d2013-10-16 13:30:34 +02002582{
2583 struct drm_device *dev = inode->i_private;
2584
Damien Lespiaubd9db022013-10-15 18:55:36 +01002585 return single_open(file, display_crc_ctl_show, dev);
Daniel Vetter926321d2013-10-16 13:30:34 +02002586}
2587
Daniel Vetter46a19182013-11-01 10:50:20 +01002588static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
Daniel Vetter52f843f2013-10-21 17:26:38 +02002589 uint32_t *val)
2590{
Daniel Vetter46a19182013-11-01 10:50:20 +01002591 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
2592 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
2593
2594 switch (*source) {
Daniel Vetter52f843f2013-10-21 17:26:38 +02002595 case INTEL_PIPE_CRC_SOURCE_PIPE:
2596 *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX;
2597 break;
2598 case INTEL_PIPE_CRC_SOURCE_NONE:
2599 *val = 0;
2600 break;
2601 default:
2602 return -EINVAL;
2603 }
2604
2605 return 0;
2606}
2607
Daniel Vetter46a19182013-11-01 10:50:20 +01002608static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe,
2609 enum intel_pipe_crc_source *source)
2610{
2611 struct intel_encoder *encoder;
2612 struct intel_crtc *crtc;
Daniel Vetter26756802013-11-01 10:50:23 +01002613 struct intel_digital_port *dig_port;
Daniel Vetter46a19182013-11-01 10:50:20 +01002614 int ret = 0;
2615
2616 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
2617
Daniel Vetter6e9f7982014-05-29 23:54:47 +02002618 drm_modeset_lock_all(dev);
Daniel Vetter46a19182013-11-01 10:50:20 +01002619 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
2620 base.head) {
2621 if (!encoder->base.crtc)
2622 continue;
2623
2624 crtc = to_intel_crtc(encoder->base.crtc);
2625
2626 if (crtc->pipe != pipe)
2627 continue;
2628
2629 switch (encoder->type) {
2630 case INTEL_OUTPUT_TVOUT:
2631 *source = INTEL_PIPE_CRC_SOURCE_TV;
2632 break;
2633 case INTEL_OUTPUT_DISPLAYPORT:
2634 case INTEL_OUTPUT_EDP:
Daniel Vetter26756802013-11-01 10:50:23 +01002635 dig_port = enc_to_dig_port(&encoder->base);
2636 switch (dig_port->port) {
2637 case PORT_B:
2638 *source = INTEL_PIPE_CRC_SOURCE_DP_B;
2639 break;
2640 case PORT_C:
2641 *source = INTEL_PIPE_CRC_SOURCE_DP_C;
2642 break;
2643 case PORT_D:
2644 *source = INTEL_PIPE_CRC_SOURCE_DP_D;
2645 break;
2646 default:
2647 WARN(1, "nonexisting DP port %c\n",
2648 port_name(dig_port->port));
2649 break;
2650 }
Daniel Vetter46a19182013-11-01 10:50:20 +01002651 break;
2652 }
2653 }
Daniel Vetter6e9f7982014-05-29 23:54:47 +02002654 drm_modeset_unlock_all(dev);
Daniel Vetter46a19182013-11-01 10:50:20 +01002655
2656 return ret;
2657}
2658
2659static int vlv_pipe_crc_ctl_reg(struct drm_device *dev,
2660 enum pipe pipe,
2661 enum intel_pipe_crc_source *source,
Daniel Vetter7ac01292013-10-18 16:37:06 +02002662 uint32_t *val)
2663{
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002664 struct drm_i915_private *dev_priv = dev->dev_private;
2665 bool need_stable_symbols = false;
2666
Daniel Vetter46a19182013-11-01 10:50:20 +01002667 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
2668 int ret = i9xx_pipe_crc_auto_source(dev, pipe, source);
2669 if (ret)
2670 return ret;
2671 }
2672
2673 switch (*source) {
Daniel Vetter7ac01292013-10-18 16:37:06 +02002674 case INTEL_PIPE_CRC_SOURCE_PIPE:
2675 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV;
2676 break;
2677 case INTEL_PIPE_CRC_SOURCE_DP_B:
2678 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV;
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002679 need_stable_symbols = true;
Daniel Vetter7ac01292013-10-18 16:37:06 +02002680 break;
2681 case INTEL_PIPE_CRC_SOURCE_DP_C:
2682 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV;
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002683 need_stable_symbols = true;
Daniel Vetter7ac01292013-10-18 16:37:06 +02002684 break;
2685 case INTEL_PIPE_CRC_SOURCE_NONE:
2686 *val = 0;
2687 break;
2688 default:
2689 return -EINVAL;
2690 }
2691
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002692 /*
2693 * When the pipe CRC tap point is after the transcoders we need
2694 * to tweak symbol-level features to produce a deterministic series of
2695 * symbols for a given frame. We need to reset those features only once
2696 * a frame (instead of every nth symbol):
2697 * - DC-balance: used to ensure a better clock recovery from the data
2698 * link (SDVO)
2699 * - DisplayPort scrambling: used for EMI reduction
2700 */
2701 if (need_stable_symbols) {
2702 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
2703
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002704 tmp |= DC_BALANCE_RESET_VLV;
2705 if (pipe == PIPE_A)
2706 tmp |= PIPE_A_SCRAMBLE_RESET;
2707 else
2708 tmp |= PIPE_B_SCRAMBLE_RESET;
2709
2710 I915_WRITE(PORT_DFT2_G4X, tmp);
2711 }
2712
Daniel Vetter7ac01292013-10-18 16:37:06 +02002713 return 0;
2714}
2715
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002716static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev,
Daniel Vetter46a19182013-11-01 10:50:20 +01002717 enum pipe pipe,
2718 enum intel_pipe_crc_source *source,
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002719 uint32_t *val)
2720{
Daniel Vetter84093602013-11-01 10:50:21 +01002721 struct drm_i915_private *dev_priv = dev->dev_private;
2722 bool need_stable_symbols = false;
2723
Daniel Vetter46a19182013-11-01 10:50:20 +01002724 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
2725 int ret = i9xx_pipe_crc_auto_source(dev, pipe, source);
2726 if (ret)
2727 return ret;
2728 }
2729
2730 switch (*source) {
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002731 case INTEL_PIPE_CRC_SOURCE_PIPE:
2732 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX;
2733 break;
2734 case INTEL_PIPE_CRC_SOURCE_TV:
2735 if (!SUPPORTS_TV(dev))
2736 return -EINVAL;
2737 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE;
2738 break;
2739 case INTEL_PIPE_CRC_SOURCE_DP_B:
2740 if (!IS_G4X(dev))
2741 return -EINVAL;
2742 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X;
Daniel Vetter84093602013-11-01 10:50:21 +01002743 need_stable_symbols = true;
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002744 break;
2745 case INTEL_PIPE_CRC_SOURCE_DP_C:
2746 if (!IS_G4X(dev))
2747 return -EINVAL;
2748 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X;
Daniel Vetter84093602013-11-01 10:50:21 +01002749 need_stable_symbols = true;
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002750 break;
2751 case INTEL_PIPE_CRC_SOURCE_DP_D:
2752 if (!IS_G4X(dev))
2753 return -EINVAL;
2754 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X;
Daniel Vetter84093602013-11-01 10:50:21 +01002755 need_stable_symbols = true;
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002756 break;
2757 case INTEL_PIPE_CRC_SOURCE_NONE:
2758 *val = 0;
2759 break;
2760 default:
2761 return -EINVAL;
2762 }
2763
Daniel Vetter84093602013-11-01 10:50:21 +01002764 /*
2765 * When the pipe CRC tap point is after the transcoders we need
2766 * to tweak symbol-level features to produce a deterministic series of
2767 * symbols for a given frame. We need to reset those features only once
2768 * a frame (instead of every nth symbol):
2769 * - DC-balance: used to ensure a better clock recovery from the data
2770 * link (SDVO)
2771 * - DisplayPort scrambling: used for EMI reduction
2772 */
2773 if (need_stable_symbols) {
2774 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
2775
2776 WARN_ON(!IS_G4X(dev));
2777
2778 I915_WRITE(PORT_DFT_I9XX,
2779 I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET);
2780
2781 if (pipe == PIPE_A)
2782 tmp |= PIPE_A_SCRAMBLE_RESET;
2783 else
2784 tmp |= PIPE_B_SCRAMBLE_RESET;
2785
2786 I915_WRITE(PORT_DFT2_G4X, tmp);
2787 }
2788
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002789 return 0;
2790}
2791
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002792static void vlv_undo_pipe_scramble_reset(struct drm_device *dev,
2793 enum pipe pipe)
2794{
2795 struct drm_i915_private *dev_priv = dev->dev_private;
2796 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
2797
2798 if (pipe == PIPE_A)
2799 tmp &= ~PIPE_A_SCRAMBLE_RESET;
2800 else
2801 tmp &= ~PIPE_B_SCRAMBLE_RESET;
2802 if (!(tmp & PIPE_SCRAMBLE_RESET_MASK))
2803 tmp &= ~DC_BALANCE_RESET_VLV;
2804 I915_WRITE(PORT_DFT2_G4X, tmp);
2805
2806}
2807
Daniel Vetter84093602013-11-01 10:50:21 +01002808static void g4x_undo_pipe_scramble_reset(struct drm_device *dev,
2809 enum pipe pipe)
2810{
2811 struct drm_i915_private *dev_priv = dev->dev_private;
2812 uint32_t tmp = I915_READ(PORT_DFT2_G4X);
2813
2814 if (pipe == PIPE_A)
2815 tmp &= ~PIPE_A_SCRAMBLE_RESET;
2816 else
2817 tmp &= ~PIPE_B_SCRAMBLE_RESET;
2818 I915_WRITE(PORT_DFT2_G4X, tmp);
2819
2820 if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) {
2821 I915_WRITE(PORT_DFT_I9XX,
2822 I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET);
2823 }
2824}
2825
Daniel Vetter46a19182013-11-01 10:50:20 +01002826static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002827 uint32_t *val)
2828{
Daniel Vetter46a19182013-11-01 10:50:20 +01002829 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
2830 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
2831
2832 switch (*source) {
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002833 case INTEL_PIPE_CRC_SOURCE_PLANE1:
2834 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK;
2835 break;
2836 case INTEL_PIPE_CRC_SOURCE_PLANE2:
2837 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK;
2838 break;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002839 case INTEL_PIPE_CRC_SOURCE_PIPE:
2840 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK;
2841 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02002842 case INTEL_PIPE_CRC_SOURCE_NONE:
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002843 *val = 0;
2844 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02002845 default:
2846 return -EINVAL;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002847 }
2848
2849 return 0;
2850}
2851
Daniel Vetter46a19182013-11-01 10:50:20 +01002852static int ivb_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002853 uint32_t *val)
2854{
Daniel Vetter46a19182013-11-01 10:50:20 +01002855 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
2856 *source = INTEL_PIPE_CRC_SOURCE_PF;
2857
2858 switch (*source) {
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002859 case INTEL_PIPE_CRC_SOURCE_PLANE1:
2860 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB;
2861 break;
2862 case INTEL_PIPE_CRC_SOURCE_PLANE2:
2863 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB;
2864 break;
2865 case INTEL_PIPE_CRC_SOURCE_PF:
2866 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB;
2867 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02002868 case INTEL_PIPE_CRC_SOURCE_NONE:
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002869 *val = 0;
2870 break;
Daniel Vetter3d099a02013-10-16 22:55:58 +02002871 default:
2872 return -EINVAL;
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002873 }
2874
2875 return 0;
2876}
2877
Daniel Vetter926321d2013-10-16 13:30:34 +02002878static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
2879 enum intel_pipe_crc_source source)
2880{
2881 struct drm_i915_private *dev_priv = dev->dev_private;
Damien Lespiaucc3da172013-10-15 18:55:31 +01002882 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
Borislav Petkov432f3342013-11-21 16:49:46 +01002883 u32 val = 0; /* shut up gcc */
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002884 int ret;
Daniel Vetter926321d2013-10-16 13:30:34 +02002885
Damien Lespiaucc3da172013-10-15 18:55:31 +01002886 if (pipe_crc->source == source)
2887 return 0;
2888
Damien Lespiauae676fc2013-10-15 18:55:32 +01002889 /* forbid changing the source without going back to 'none' */
2890 if (pipe_crc->source && source)
2891 return -EINVAL;
2892
Daniel Vetter52f843f2013-10-21 17:26:38 +02002893 if (IS_GEN2(dev))
Daniel Vetter46a19182013-11-01 10:50:20 +01002894 ret = i8xx_pipe_crc_ctl_reg(&source, &val);
Daniel Vetter52f843f2013-10-21 17:26:38 +02002895 else if (INTEL_INFO(dev)->gen < 5)
Daniel Vetter46a19182013-11-01 10:50:20 +01002896 ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val);
Daniel Vetter7ac01292013-10-18 16:37:06 +02002897 else if (IS_VALLEYVIEW(dev))
Daniel Vetter46a19182013-11-01 10:50:20 +01002898 ret = vlv_pipe_crc_ctl_reg(dev,pipe, &source, &val);
Daniel Vetter4b79ebf2013-10-16 22:55:59 +02002899 else if (IS_GEN5(dev) || IS_GEN6(dev))
Daniel Vetter46a19182013-11-01 10:50:20 +01002900 ret = ilk_pipe_crc_ctl_reg(&source, &val);
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002901 else
Daniel Vetter46a19182013-11-01 10:50:20 +01002902 ret = ivb_pipe_crc_ctl_reg(&source, &val);
Daniel Vetter5b3a8562013-10-16 22:55:48 +02002903
2904 if (ret != 0)
2905 return ret;
2906
Damien Lespiau4b584362013-10-15 18:55:33 +01002907 /* none -> real source transition */
2908 if (source) {
Damien Lespiau7cd6ccf2013-10-15 18:55:38 +01002909 DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n",
2910 pipe_name(pipe), pipe_crc_source_name(source));
2911
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01002912 pipe_crc->entries = kzalloc(sizeof(*pipe_crc->entries) *
2913 INTEL_PIPE_CRC_ENTRIES_NR,
2914 GFP_KERNEL);
2915 if (!pipe_crc->entries)
2916 return -ENOMEM;
2917
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002918 spin_lock_irq(&pipe_crc->lock);
2919 pipe_crc->head = 0;
2920 pipe_crc->tail = 0;
2921 spin_unlock_irq(&pipe_crc->lock);
Damien Lespiau4b584362013-10-15 18:55:33 +01002922 }
2923
Damien Lespiaucc3da172013-10-15 18:55:31 +01002924 pipe_crc->source = source;
Daniel Vetter926321d2013-10-16 13:30:34 +02002925
Daniel Vetter926321d2013-10-16 13:30:34 +02002926 I915_WRITE(PIPE_CRC_CTL(pipe), val);
2927 POSTING_READ(PIPE_CRC_CTL(pipe));
2928
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01002929 /* real source -> none transition */
2930 if (source == INTEL_PIPE_CRC_SOURCE_NONE) {
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002931 struct intel_pipe_crc_entry *entries;
2932
Damien Lespiau7cd6ccf2013-10-15 18:55:38 +01002933 DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
2934 pipe_name(pipe));
2935
Daniel Vetterbcf17ab2013-10-16 22:55:50 +02002936 intel_wait_for_vblank(dev, pipe);
2937
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002938 spin_lock_irq(&pipe_crc->lock);
2939 entries = pipe_crc->entries;
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01002940 pipe_crc->entries = NULL;
Damien Lespiaud538bbd2013-10-21 14:29:30 +01002941 spin_unlock_irq(&pipe_crc->lock);
2942
2943 kfree(entries);
Daniel Vetter84093602013-11-01 10:50:21 +01002944
2945 if (IS_G4X(dev))
2946 g4x_undo_pipe_scramble_reset(dev, pipe);
Daniel Vetter8d2f24c2013-11-01 10:50:22 +01002947 else if (IS_VALLEYVIEW(dev))
2948 vlv_undo_pipe_scramble_reset(dev, pipe);
Damien Lespiaue5f75ac2013-10-15 18:55:34 +01002949 }
2950
Daniel Vetter926321d2013-10-16 13:30:34 +02002951 return 0;
2952}
2953
2954/*
2955 * Parse pipe CRC command strings:
Damien Lespiaub94dec82013-10-15 18:55:35 +01002956 * command: wsp* object wsp+ name wsp+ source wsp*
2957 * object: 'pipe'
2958 * name: (A | B | C)
Daniel Vetter926321d2013-10-16 13:30:34 +02002959 * source: (none | plane1 | plane2 | pf)
2960 * wsp: (#0x20 | #0x9 | #0xA)+
2961 *
2962 * eg.:
Damien Lespiaub94dec82013-10-15 18:55:35 +01002963 * "pipe A plane1" -> Start CRC computations on plane1 of pipe A
2964 * "pipe A none" -> Stop CRC
Daniel Vetter926321d2013-10-16 13:30:34 +02002965 */
Damien Lespiaubd9db022013-10-15 18:55:36 +01002966static int display_crc_ctl_tokenize(char *buf, char *words[], int max_words)
Daniel Vetter926321d2013-10-16 13:30:34 +02002967{
2968 int n_words = 0;
2969
2970 while (*buf) {
2971 char *end;
2972
2973 /* skip leading white space */
2974 buf = skip_spaces(buf);
2975 if (!*buf)
2976 break; /* end of buffer */
2977
2978 /* find end of word */
2979 for (end = buf; *end && !isspace(*end); end++)
2980 ;
2981
2982 if (n_words == max_words) {
2983 DRM_DEBUG_DRIVER("too many words, allowed <= %d\n",
2984 max_words);
2985 return -EINVAL; /* ran out of words[] before bytes */
2986 }
2987
2988 if (*end)
2989 *end++ = '\0';
2990 words[n_words++] = buf;
2991 buf = end;
2992 }
2993
2994 return n_words;
2995}
2996
Damien Lespiaub94dec82013-10-15 18:55:35 +01002997enum intel_pipe_crc_object {
2998 PIPE_CRC_OBJECT_PIPE,
2999};
3000
Daniel Vettere8dfcf72013-10-16 11:51:54 +02003001static const char * const pipe_crc_objects[] = {
Damien Lespiaub94dec82013-10-15 18:55:35 +01003002 "pipe",
3003};
3004
3005static int
Damien Lespiaubd9db022013-10-15 18:55:36 +01003006display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o)
Damien Lespiaub94dec82013-10-15 18:55:35 +01003007{
3008 int i;
3009
3010 for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++)
3011 if (!strcmp(buf, pipe_crc_objects[i])) {
Damien Lespiaubd9db022013-10-15 18:55:36 +01003012 *o = i;
Damien Lespiaub94dec82013-10-15 18:55:35 +01003013 return 0;
3014 }
3015
3016 return -EINVAL;
3017}
3018
Damien Lespiaubd9db022013-10-15 18:55:36 +01003019static int display_crc_ctl_parse_pipe(const char *buf, enum pipe *pipe)
Daniel Vetter926321d2013-10-16 13:30:34 +02003020{
3021 const char name = buf[0];
3022
3023 if (name < 'A' || name >= pipe_name(I915_MAX_PIPES))
3024 return -EINVAL;
3025
3026 *pipe = name - 'A';
3027
3028 return 0;
3029}
3030
3031static int
Damien Lespiaubd9db022013-10-15 18:55:36 +01003032display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
Daniel Vetter926321d2013-10-16 13:30:34 +02003033{
3034 int i;
3035
3036 for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
3037 if (!strcmp(buf, pipe_crc_sources[i])) {
Damien Lespiaubd9db022013-10-15 18:55:36 +01003038 *s = i;
Daniel Vetter926321d2013-10-16 13:30:34 +02003039 return 0;
3040 }
3041
3042 return -EINVAL;
3043}
3044
Damien Lespiaubd9db022013-10-15 18:55:36 +01003045static int display_crc_ctl_parse(struct drm_device *dev, char *buf, size_t len)
Daniel Vetter926321d2013-10-16 13:30:34 +02003046{
Damien Lespiaub94dec82013-10-15 18:55:35 +01003047#define N_WORDS 3
Daniel Vetter926321d2013-10-16 13:30:34 +02003048 int n_words;
Damien Lespiaub94dec82013-10-15 18:55:35 +01003049 char *words[N_WORDS];
Daniel Vetter926321d2013-10-16 13:30:34 +02003050 enum pipe pipe;
Damien Lespiaub94dec82013-10-15 18:55:35 +01003051 enum intel_pipe_crc_object object;
Daniel Vetter926321d2013-10-16 13:30:34 +02003052 enum intel_pipe_crc_source source;
3053
Damien Lespiaubd9db022013-10-15 18:55:36 +01003054 n_words = display_crc_ctl_tokenize(buf, words, N_WORDS);
Damien Lespiaub94dec82013-10-15 18:55:35 +01003055 if (n_words != N_WORDS) {
3056 DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n",
3057 N_WORDS);
Daniel Vetter926321d2013-10-16 13:30:34 +02003058 return -EINVAL;
3059 }
3060
Damien Lespiaubd9db022013-10-15 18:55:36 +01003061 if (display_crc_ctl_parse_object(words[0], &object) < 0) {
Damien Lespiaub94dec82013-10-15 18:55:35 +01003062 DRM_DEBUG_DRIVER("unknown object %s\n", words[0]);
Daniel Vetter926321d2013-10-16 13:30:34 +02003063 return -EINVAL;
3064 }
3065
Damien Lespiaubd9db022013-10-15 18:55:36 +01003066 if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) {
Damien Lespiaub94dec82013-10-15 18:55:35 +01003067 DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]);
3068 return -EINVAL;
3069 }
3070
Damien Lespiaubd9db022013-10-15 18:55:36 +01003071 if (display_crc_ctl_parse_source(words[2], &source) < 0) {
Damien Lespiaub94dec82013-10-15 18:55:35 +01003072 DRM_DEBUG_DRIVER("unknown source %s\n", words[2]);
Daniel Vetter926321d2013-10-16 13:30:34 +02003073 return -EINVAL;
3074 }
3075
3076 return pipe_crc_set_source(dev, pipe, source);
3077}
3078
Damien Lespiaubd9db022013-10-15 18:55:36 +01003079static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf,
3080 size_t len, loff_t *offp)
Daniel Vetter926321d2013-10-16 13:30:34 +02003081{
3082 struct seq_file *m = file->private_data;
3083 struct drm_device *dev = m->private;
3084 char *tmpbuf;
3085 int ret;
3086
3087 if (len == 0)
3088 return 0;
3089
3090 if (len > PAGE_SIZE - 1) {
3091 DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n",
3092 PAGE_SIZE);
3093 return -E2BIG;
3094 }
3095
3096 tmpbuf = kmalloc(len + 1, GFP_KERNEL);
3097 if (!tmpbuf)
3098 return -ENOMEM;
3099
3100 if (copy_from_user(tmpbuf, ubuf, len)) {
3101 ret = -EFAULT;
3102 goto out;
3103 }
3104 tmpbuf[len] = '\0';
3105
Damien Lespiaubd9db022013-10-15 18:55:36 +01003106 ret = display_crc_ctl_parse(dev, tmpbuf, len);
Daniel Vetter926321d2013-10-16 13:30:34 +02003107
3108out:
3109 kfree(tmpbuf);
3110 if (ret < 0)
3111 return ret;
3112
3113 *offp += len;
3114 return len;
3115}
3116
Damien Lespiaubd9db022013-10-15 18:55:36 +01003117static const struct file_operations i915_display_crc_ctl_fops = {
Daniel Vetter926321d2013-10-16 13:30:34 +02003118 .owner = THIS_MODULE,
Damien Lespiaubd9db022013-10-15 18:55:36 +01003119 .open = display_crc_ctl_open,
Daniel Vetter926321d2013-10-16 13:30:34 +02003120 .read = seq_read,
3121 .llseek = seq_lseek,
3122 .release = single_release,
Damien Lespiaubd9db022013-10-15 18:55:36 +01003123 .write = display_crc_ctl_write
Daniel Vetter926321d2013-10-16 13:30:34 +02003124};
3125
Ville Syrjälä369a1342014-01-22 14:36:08 +02003126static void wm_latency_show(struct seq_file *m, const uint16_t wm[5])
3127{
3128 struct drm_device *dev = m->private;
Damien Lespiau546c81f2014-05-13 15:30:26 +01003129 int num_levels = ilk_wm_max_level(dev) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003130 int level;
3131
3132 drm_modeset_lock_all(dev);
3133
3134 for (level = 0; level < num_levels; level++) {
3135 unsigned int latency = wm[level];
3136
3137 /* WM1+ latency values in 0.5us units */
3138 if (level > 0)
3139 latency *= 5;
3140
3141 seq_printf(m, "WM%d %u (%u.%u usec)\n",
3142 level, wm[level],
3143 latency / 10, latency % 10);
3144 }
3145
3146 drm_modeset_unlock_all(dev);
3147}
3148
3149static int pri_wm_latency_show(struct seq_file *m, void *data)
3150{
3151 struct drm_device *dev = m->private;
3152
3153 wm_latency_show(m, to_i915(dev)->wm.pri_latency);
3154
3155 return 0;
3156}
3157
3158static int spr_wm_latency_show(struct seq_file *m, void *data)
3159{
3160 struct drm_device *dev = m->private;
3161
3162 wm_latency_show(m, to_i915(dev)->wm.spr_latency);
3163
3164 return 0;
3165}
3166
3167static int cur_wm_latency_show(struct seq_file *m, void *data)
3168{
3169 struct drm_device *dev = m->private;
3170
3171 wm_latency_show(m, to_i915(dev)->wm.cur_latency);
3172
3173 return 0;
3174}
3175
3176static int pri_wm_latency_open(struct inode *inode, struct file *file)
3177{
3178 struct drm_device *dev = inode->i_private;
3179
3180 if (!HAS_PCH_SPLIT(dev))
3181 return -ENODEV;
3182
3183 return single_open(file, pri_wm_latency_show, dev);
3184}
3185
3186static int spr_wm_latency_open(struct inode *inode, struct file *file)
3187{
3188 struct drm_device *dev = inode->i_private;
3189
3190 if (!HAS_PCH_SPLIT(dev))
3191 return -ENODEV;
3192
3193 return single_open(file, spr_wm_latency_show, dev);
3194}
3195
3196static int cur_wm_latency_open(struct inode *inode, struct file *file)
3197{
3198 struct drm_device *dev = inode->i_private;
3199
3200 if (!HAS_PCH_SPLIT(dev))
3201 return -ENODEV;
3202
3203 return single_open(file, cur_wm_latency_show, dev);
3204}
3205
3206static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
3207 size_t len, loff_t *offp, uint16_t wm[5])
3208{
3209 struct seq_file *m = file->private_data;
3210 struct drm_device *dev = m->private;
3211 uint16_t new[5] = { 0 };
Damien Lespiau546c81f2014-05-13 15:30:26 +01003212 int num_levels = ilk_wm_max_level(dev) + 1;
Ville Syrjälä369a1342014-01-22 14:36:08 +02003213 int level;
3214 int ret;
3215 char tmp[32];
3216
3217 if (len >= sizeof(tmp))
3218 return -EINVAL;
3219
3220 if (copy_from_user(tmp, ubuf, len))
3221 return -EFAULT;
3222
3223 tmp[len] = '\0';
3224
3225 ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]);
3226 if (ret != num_levels)
3227 return -EINVAL;
3228
3229 drm_modeset_lock_all(dev);
3230
3231 for (level = 0; level < num_levels; level++)
3232 wm[level] = new[level];
3233
3234 drm_modeset_unlock_all(dev);
3235
3236 return len;
3237}
3238
3239
3240static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
3241 size_t len, loff_t *offp)
3242{
3243 struct seq_file *m = file->private_data;
3244 struct drm_device *dev = m->private;
3245
3246 return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency);
3247}
3248
3249static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
3250 size_t len, loff_t *offp)
3251{
3252 struct seq_file *m = file->private_data;
3253 struct drm_device *dev = m->private;
3254
3255 return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency);
3256}
3257
3258static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
3259 size_t len, loff_t *offp)
3260{
3261 struct seq_file *m = file->private_data;
3262 struct drm_device *dev = m->private;
3263
3264 return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency);
3265}
3266
3267static const struct file_operations i915_pri_wm_latency_fops = {
3268 .owner = THIS_MODULE,
3269 .open = pri_wm_latency_open,
3270 .read = seq_read,
3271 .llseek = seq_lseek,
3272 .release = single_release,
3273 .write = pri_wm_latency_write
3274};
3275
3276static const struct file_operations i915_spr_wm_latency_fops = {
3277 .owner = THIS_MODULE,
3278 .open = spr_wm_latency_open,
3279 .read = seq_read,
3280 .llseek = seq_lseek,
3281 .release = single_release,
3282 .write = spr_wm_latency_write
3283};
3284
3285static const struct file_operations i915_cur_wm_latency_fops = {
3286 .owner = THIS_MODULE,
3287 .open = cur_wm_latency_open,
3288 .read = seq_read,
3289 .llseek = seq_lseek,
3290 .release = single_release,
3291 .write = cur_wm_latency_write
3292};
3293
Kees Cook647416f2013-03-10 14:10:06 -07003294static int
3295i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003296{
Kees Cook647416f2013-03-10 14:10:06 -07003297 struct drm_device *dev = data;
Jani Nikulae277a1f2014-03-31 14:27:14 +03003298 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003299
Kees Cook647416f2013-03-10 14:10:06 -07003300 *val = atomic_read(&dev_priv->gpu_error.reset_counter);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003301
Kees Cook647416f2013-03-10 14:10:06 -07003302 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003303}
3304
Kees Cook647416f2013-03-10 14:10:06 -07003305static int
3306i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003307{
Kees Cook647416f2013-03-10 14:10:06 -07003308 struct drm_device *dev = data;
Imre Deakd46c0512014-04-14 20:24:27 +03003309 struct drm_i915_private *dev_priv = dev->dev_private;
3310
3311 intel_runtime_pm_get(dev_priv);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003312
Mika Kuoppala58174462014-02-25 17:11:26 +02003313 i915_handle_error(dev, val,
3314 "Manually setting wedged to %llu", val);
Imre Deakd46c0512014-04-14 20:24:27 +03003315
3316 intel_runtime_pm_put(dev_priv);
3317
Kees Cook647416f2013-03-10 14:10:06 -07003318 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003319}
3320
Kees Cook647416f2013-03-10 14:10:06 -07003321DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
3322 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03003323 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003324
Kees Cook647416f2013-03-10 14:10:06 -07003325static int
3326i915_ring_stop_get(void *data, u64 *val)
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003327{
Kees Cook647416f2013-03-10 14:10:06 -07003328 struct drm_device *dev = data;
Jani Nikulae277a1f2014-03-31 14:27:14 +03003329 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003330
Kees Cook647416f2013-03-10 14:10:06 -07003331 *val = dev_priv->gpu_error.stop_rings;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003332
Kees Cook647416f2013-03-10 14:10:06 -07003333 return 0;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003334}
3335
Kees Cook647416f2013-03-10 14:10:06 -07003336static int
3337i915_ring_stop_set(void *data, u64 val)
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003338{
Kees Cook647416f2013-03-10 14:10:06 -07003339 struct drm_device *dev = data;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003340 struct drm_i915_private *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07003341 int ret;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003342
Kees Cook647416f2013-03-10 14:10:06 -07003343 DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val);
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003344
Daniel Vetter22bcfc62012-08-09 15:07:02 +02003345 ret = mutex_lock_interruptible(&dev->struct_mutex);
3346 if (ret)
3347 return ret;
3348
Daniel Vetter99584db2012-11-14 17:14:04 +01003349 dev_priv->gpu_error.stop_rings = val;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003350 mutex_unlock(&dev->struct_mutex);
3351
Kees Cook647416f2013-03-10 14:10:06 -07003352 return 0;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02003353}
3354
Kees Cook647416f2013-03-10 14:10:06 -07003355DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops,
3356 i915_ring_stop_get, i915_ring_stop_set,
3357 "0x%08llx\n");
Daniel Vetterd5442302012-04-27 15:17:40 +02003358
Chris Wilson094f9a52013-09-25 17:34:55 +01003359static int
3360i915_ring_missed_irq_get(void *data, u64 *val)
3361{
3362 struct drm_device *dev = data;
3363 struct drm_i915_private *dev_priv = dev->dev_private;
3364
3365 *val = dev_priv->gpu_error.missed_irq_rings;
3366 return 0;
3367}
3368
3369static int
3370i915_ring_missed_irq_set(void *data, u64 val)
3371{
3372 struct drm_device *dev = data;
3373 struct drm_i915_private *dev_priv = dev->dev_private;
3374 int ret;
3375
3376 /* Lock against concurrent debugfs callers */
3377 ret = mutex_lock_interruptible(&dev->struct_mutex);
3378 if (ret)
3379 return ret;
3380 dev_priv->gpu_error.missed_irq_rings = val;
3381 mutex_unlock(&dev->struct_mutex);
3382
3383 return 0;
3384}
3385
3386DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
3387 i915_ring_missed_irq_get, i915_ring_missed_irq_set,
3388 "0x%08llx\n");
3389
3390static int
3391i915_ring_test_irq_get(void *data, u64 *val)
3392{
3393 struct drm_device *dev = data;
3394 struct drm_i915_private *dev_priv = dev->dev_private;
3395
3396 *val = dev_priv->gpu_error.test_irq_rings;
3397
3398 return 0;
3399}
3400
3401static int
3402i915_ring_test_irq_set(void *data, u64 val)
3403{
3404 struct drm_device *dev = data;
3405 struct drm_i915_private *dev_priv = dev->dev_private;
3406 int ret;
3407
3408 DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val);
3409
3410 /* Lock against concurrent debugfs callers */
3411 ret = mutex_lock_interruptible(&dev->struct_mutex);
3412 if (ret)
3413 return ret;
3414
3415 dev_priv->gpu_error.test_irq_rings = val;
3416 mutex_unlock(&dev->struct_mutex);
3417
3418 return 0;
3419}
3420
3421DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
3422 i915_ring_test_irq_get, i915_ring_test_irq_set,
3423 "0x%08llx\n");
3424
Chris Wilsondd624af2013-01-15 12:39:35 +00003425#define DROP_UNBOUND 0x1
3426#define DROP_BOUND 0x2
3427#define DROP_RETIRE 0x4
3428#define DROP_ACTIVE 0x8
3429#define DROP_ALL (DROP_UNBOUND | \
3430 DROP_BOUND | \
3431 DROP_RETIRE | \
3432 DROP_ACTIVE)
Kees Cook647416f2013-03-10 14:10:06 -07003433static int
3434i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00003435{
Kees Cook647416f2013-03-10 14:10:06 -07003436 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00003437
Kees Cook647416f2013-03-10 14:10:06 -07003438 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00003439}
3440
Kees Cook647416f2013-03-10 14:10:06 -07003441static int
3442i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00003443{
Kees Cook647416f2013-03-10 14:10:06 -07003444 struct drm_device *dev = data;
Chris Wilsondd624af2013-01-15 12:39:35 +00003445 struct drm_i915_private *dev_priv = dev->dev_private;
3446 struct drm_i915_gem_object *obj, *next;
Ben Widawskyca191b12013-07-31 17:00:14 -07003447 struct i915_address_space *vm;
3448 struct i915_vma *vma, *x;
Kees Cook647416f2013-03-10 14:10:06 -07003449 int ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00003450
Ben Widawsky2f9fe5f2013-11-25 09:54:37 -08003451 DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00003452
3453 /* No need to check and wait for gpu resets, only libdrm auto-restarts
3454 * on ioctls on -EAGAIN. */
3455 ret = mutex_lock_interruptible(&dev->struct_mutex);
3456 if (ret)
3457 return ret;
3458
3459 if (val & DROP_ACTIVE) {
3460 ret = i915_gpu_idle(dev);
3461 if (ret)
3462 goto unlock;
3463 }
3464
3465 if (val & (DROP_RETIRE | DROP_ACTIVE))
3466 i915_gem_retire_requests(dev);
3467
3468 if (val & DROP_BOUND) {
Ben Widawskyca191b12013-07-31 17:00:14 -07003469 list_for_each_entry(vm, &dev_priv->vm_list, global_link) {
3470 list_for_each_entry_safe(vma, x, &vm->inactive_list,
3471 mm_list) {
Ben Widawskyd7f46fc2013-12-06 14:10:55 -08003472 if (vma->pin_count)
Ben Widawskyca191b12013-07-31 17:00:14 -07003473 continue;
Ben Widawsky31a46c92013-07-31 16:59:55 -07003474
Ben Widawskyca191b12013-07-31 17:00:14 -07003475 ret = i915_vma_unbind(vma);
3476 if (ret)
3477 goto unlock;
3478 }
Ben Widawsky31a46c92013-07-31 16:59:55 -07003479 }
Chris Wilsondd624af2013-01-15 12:39:35 +00003480 }
3481
3482 if (val & DROP_UNBOUND) {
Ben Widawsky35c20a62013-05-31 11:28:48 -07003483 list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list,
3484 global_list)
Chris Wilsondd624af2013-01-15 12:39:35 +00003485 if (obj->pages_pin_count == 0) {
3486 ret = i915_gem_object_put_pages(obj);
3487 if (ret)
3488 goto unlock;
3489 }
3490 }
3491
3492unlock:
3493 mutex_unlock(&dev->struct_mutex);
3494
Kees Cook647416f2013-03-10 14:10:06 -07003495 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00003496}
3497
Kees Cook647416f2013-03-10 14:10:06 -07003498DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
3499 i915_drop_caches_get, i915_drop_caches_set,
3500 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00003501
Kees Cook647416f2013-03-10 14:10:06 -07003502static int
3503i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07003504{
Kees Cook647416f2013-03-10 14:10:06 -07003505 struct drm_device *dev = data;
Jani Nikulae277a1f2014-03-31 14:27:14 +03003506 struct drm_i915_private *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07003507 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02003508
3509 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
3510 return -ENODEV;
3511
Tom O'Rourke5c9669c2013-09-16 14:56:43 -07003512 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
3513
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003514 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02003515 if (ret)
3516 return ret;
Jesse Barnes358733e2011-07-27 11:53:01 -07003517
Jesse Barnes0a073b82013-04-17 15:54:58 -07003518 if (IS_VALLEYVIEW(dev))
Ben Widawskyb39fb292014-03-19 18:31:11 -07003519 *val = vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit);
Jesse Barnes0a073b82013-04-17 15:54:58 -07003520 else
Ben Widawskyb39fb292014-03-19 18:31:11 -07003521 *val = dev_priv->rps.max_freq_softlimit * GT_FREQUENCY_MULTIPLIER;
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003522 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07003523
Kees Cook647416f2013-03-10 14:10:06 -07003524 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07003525}
3526
Kees Cook647416f2013-03-10 14:10:06 -07003527static int
3528i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07003529{
Kees Cook647416f2013-03-10 14:10:06 -07003530 struct drm_device *dev = data;
Jesse Barnes358733e2011-07-27 11:53:01 -07003531 struct drm_i915_private *dev_priv = dev->dev_private;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003532 u32 rp_state_cap, hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07003533 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02003534
3535 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
3536 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07003537
Tom O'Rourke5c9669c2013-09-16 14:56:43 -07003538 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
3539
Kees Cook647416f2013-03-10 14:10:06 -07003540 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07003541
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003542 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02003543 if (ret)
3544 return ret;
3545
Jesse Barnes358733e2011-07-27 11:53:01 -07003546 /*
3547 * Turbo will still be enabled, but won't go above the set value.
3548 */
Jesse Barnes0a073b82013-04-17 15:54:58 -07003549 if (IS_VALLEYVIEW(dev)) {
Ville Syrjälä2ec38152013-11-05 22:42:29 +02003550 val = vlv_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003551
3552 hw_max = valleyview_rps_max_freq(dev_priv);
3553 hw_min = valleyview_rps_min_freq(dev_priv);
Jesse Barnes0a073b82013-04-17 15:54:58 -07003554 } else {
3555 do_div(val, GT_FREQUENCY_MULTIPLIER);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003556
3557 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
Ben Widawskyb39fb292014-03-19 18:31:11 -07003558 hw_max = dev_priv->rps.max_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003559 hw_min = (rp_state_cap >> 16) & 0xff;
Jesse Barnes0a073b82013-04-17 15:54:58 -07003560 }
3561
Ben Widawskyb39fb292014-03-19 18:31:11 -07003562 if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003563 mutex_unlock(&dev_priv->rps.hw_lock);
3564 return -EINVAL;
3565 }
3566
Ben Widawskyb39fb292014-03-19 18:31:11 -07003567 dev_priv->rps.max_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003568
3569 if (IS_VALLEYVIEW(dev))
3570 valleyview_set_rps(dev, val);
3571 else
3572 gen6_set_rps(dev, val);
3573
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003574 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07003575
Kees Cook647416f2013-03-10 14:10:06 -07003576 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07003577}
3578
Kees Cook647416f2013-03-10 14:10:06 -07003579DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
3580 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03003581 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07003582
Kees Cook647416f2013-03-10 14:10:06 -07003583static int
3584i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07003585{
Kees Cook647416f2013-03-10 14:10:06 -07003586 struct drm_device *dev = data;
Jani Nikulae277a1f2014-03-31 14:27:14 +03003587 struct drm_i915_private *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07003588 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02003589
3590 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
3591 return -ENODEV;
3592
Tom O'Rourke5c9669c2013-09-16 14:56:43 -07003593 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
3594
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003595 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02003596 if (ret)
3597 return ret;
Jesse Barnes1523c312012-05-25 12:34:54 -07003598
Jesse Barnes0a073b82013-04-17 15:54:58 -07003599 if (IS_VALLEYVIEW(dev))
Ben Widawskyb39fb292014-03-19 18:31:11 -07003600 *val = vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit);
Jesse Barnes0a073b82013-04-17 15:54:58 -07003601 else
Ben Widawskyb39fb292014-03-19 18:31:11 -07003602 *val = dev_priv->rps.min_freq_softlimit * GT_FREQUENCY_MULTIPLIER;
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003603 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07003604
Kees Cook647416f2013-03-10 14:10:06 -07003605 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07003606}
3607
Kees Cook647416f2013-03-10 14:10:06 -07003608static int
3609i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07003610{
Kees Cook647416f2013-03-10 14:10:06 -07003611 struct drm_device *dev = data;
Jesse Barnes1523c312012-05-25 12:34:54 -07003612 struct drm_i915_private *dev_priv = dev->dev_private;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003613 u32 rp_state_cap, hw_max, hw_min;
Kees Cook647416f2013-03-10 14:10:06 -07003614 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02003615
3616 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
3617 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07003618
Tom O'Rourke5c9669c2013-09-16 14:56:43 -07003619 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
3620
Kees Cook647416f2013-03-10 14:10:06 -07003621 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07003622
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003623 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02003624 if (ret)
3625 return ret;
3626
Jesse Barnes1523c312012-05-25 12:34:54 -07003627 /*
3628 * Turbo will still be enabled, but won't go below the set value.
3629 */
Jesse Barnes0a073b82013-04-17 15:54:58 -07003630 if (IS_VALLEYVIEW(dev)) {
Ville Syrjälä2ec38152013-11-05 22:42:29 +02003631 val = vlv_freq_opcode(dev_priv, val);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003632
3633 hw_max = valleyview_rps_max_freq(dev_priv);
3634 hw_min = valleyview_rps_min_freq(dev_priv);
Jesse Barnes0a073b82013-04-17 15:54:58 -07003635 } else {
3636 do_div(val, GT_FREQUENCY_MULTIPLIER);
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003637
3638 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
Ben Widawskyb39fb292014-03-19 18:31:11 -07003639 hw_max = dev_priv->rps.max_freq;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003640 hw_min = (rp_state_cap >> 16) & 0xff;
Jesse Barnes0a073b82013-04-17 15:54:58 -07003641 }
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003642
Ben Widawskyb39fb292014-03-19 18:31:11 -07003643 if (val < hw_min || val > hw_max || val > dev_priv->rps.max_freq_softlimit) {
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003644 mutex_unlock(&dev_priv->rps.hw_lock);
3645 return -EINVAL;
3646 }
3647
Ben Widawskyb39fb292014-03-19 18:31:11 -07003648 dev_priv->rps.min_freq_softlimit = val;
Jeff McGeedd0a1aa2014-02-04 11:32:31 -06003649
3650 if (IS_VALLEYVIEW(dev))
3651 valleyview_set_rps(dev, val);
3652 else
3653 gen6_set_rps(dev, val);
3654
Jesse Barnes4fc688c2012-11-02 11:14:01 -07003655 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07003656
Kees Cook647416f2013-03-10 14:10:06 -07003657 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07003658}
3659
Kees Cook647416f2013-03-10 14:10:06 -07003660DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
3661 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03003662 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07003663
Kees Cook647416f2013-03-10 14:10:06 -07003664static int
3665i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003666{
Kees Cook647416f2013-03-10 14:10:06 -07003667 struct drm_device *dev = data;
Jani Nikulae277a1f2014-03-31 14:27:14 +03003668 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003669 u32 snpcr;
Kees Cook647416f2013-03-10 14:10:06 -07003670 int ret;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003671
Daniel Vetter004777c2012-08-09 15:07:01 +02003672 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
3673 return -ENODEV;
3674
Daniel Vetter22bcfc62012-08-09 15:07:02 +02003675 ret = mutex_lock_interruptible(&dev->struct_mutex);
3676 if (ret)
3677 return ret;
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02003678 intel_runtime_pm_get(dev_priv);
Daniel Vetter22bcfc62012-08-09 15:07:02 +02003679
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003680 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02003681
3682 intel_runtime_pm_put(dev_priv);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003683 mutex_unlock(&dev_priv->dev->struct_mutex);
3684
Kees Cook647416f2013-03-10 14:10:06 -07003685 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003686
Kees Cook647416f2013-03-10 14:10:06 -07003687 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003688}
3689
Kees Cook647416f2013-03-10 14:10:06 -07003690static int
3691i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003692{
Kees Cook647416f2013-03-10 14:10:06 -07003693 struct drm_device *dev = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003694 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003695 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003696
Daniel Vetter004777c2012-08-09 15:07:01 +02003697 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
3698 return -ENODEV;
3699
Kees Cook647416f2013-03-10 14:10:06 -07003700 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003701 return -EINVAL;
3702
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02003703 intel_runtime_pm_get(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07003704 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003705
3706 /* Update the cache sharing policy here as well */
3707 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
3708 snpcr &= ~GEN6_MBC_SNPCR_MASK;
3709 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
3710 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
3711
Paulo Zanonic8c8fb32013-11-27 18:21:54 -02003712 intel_runtime_pm_put(dev_priv);
Kees Cook647416f2013-03-10 14:10:06 -07003713 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003714}
3715
Kees Cook647416f2013-03-10 14:10:06 -07003716DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
3717 i915_cache_sharing_get, i915_cache_sharing_set,
3718 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003719
Ben Widawsky6d794d42011-04-25 11:25:56 -07003720static int i915_forcewake_open(struct inode *inode, struct file *file)
3721{
3722 struct drm_device *dev = inode->i_private;
3723 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07003724
Daniel Vetter075edca2012-01-24 09:44:28 +01003725 if (INTEL_INFO(dev)->gen < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07003726 return 0;
3727
Deepak Sc8d9a592013-11-23 14:55:42 +05303728 gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
Ben Widawsky6d794d42011-04-25 11:25:56 -07003729
3730 return 0;
3731}
3732
Ben Widawskyc43b5632012-04-16 14:07:40 -07003733static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07003734{
3735 struct drm_device *dev = inode->i_private;
3736 struct drm_i915_private *dev_priv = dev->dev_private;
3737
Daniel Vetter075edca2012-01-24 09:44:28 +01003738 if (INTEL_INFO(dev)->gen < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07003739 return 0;
3740
Deepak Sc8d9a592013-11-23 14:55:42 +05303741 gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
Ben Widawsky6d794d42011-04-25 11:25:56 -07003742
3743 return 0;
3744}
3745
3746static const struct file_operations i915_forcewake_fops = {
3747 .owner = THIS_MODULE,
3748 .open = i915_forcewake_open,
3749 .release = i915_forcewake_release,
3750};
3751
3752static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
3753{
3754 struct drm_device *dev = minor->dev;
3755 struct dentry *ent;
3756
3757 ent = debugfs_create_file("i915_forcewake_user",
Ben Widawsky8eb57292011-05-11 15:10:58 -07003758 S_IRUSR,
Ben Widawsky6d794d42011-04-25 11:25:56 -07003759 root, dev,
3760 &i915_forcewake_fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08003761 if (!ent)
3762 return -ENOMEM;
Ben Widawsky6d794d42011-04-25 11:25:56 -07003763
Ben Widawsky8eb57292011-05-11 15:10:58 -07003764 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
Ben Widawsky6d794d42011-04-25 11:25:56 -07003765}
3766
Daniel Vetter6a9c3082011-12-14 13:57:11 +01003767static int i915_debugfs_create(struct dentry *root,
3768 struct drm_minor *minor,
3769 const char *name,
3770 const struct file_operations *fops)
Jesse Barnes358733e2011-07-27 11:53:01 -07003771{
3772 struct drm_device *dev = minor->dev;
3773 struct dentry *ent;
3774
Daniel Vetter6a9c3082011-12-14 13:57:11 +01003775 ent = debugfs_create_file(name,
Jesse Barnes358733e2011-07-27 11:53:01 -07003776 S_IRUGO | S_IWUSR,
3777 root, dev,
Daniel Vetter6a9c3082011-12-14 13:57:11 +01003778 fops);
Wei Yongjunf3c5fe92013-12-16 14:13:25 +08003779 if (!ent)
3780 return -ENOMEM;
Jesse Barnes358733e2011-07-27 11:53:01 -07003781
Daniel Vetter6a9c3082011-12-14 13:57:11 +01003782 return drm_add_fake_info_node(minor, ent, fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07003783}
3784
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01003785static const struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00003786 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01003787 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00003788 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson1b502472012-04-24 15:47:30 +01003789 {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05003790 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05003791 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
Chris Wilson6d2b8882013-08-07 18:30:54 +01003792 {"i915_gem_stolen", i915_gem_stolen_list_info },
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01003793 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05003794 {"i915_gem_request", i915_gem_request_info, 0},
3795 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00003796 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05003797 {"i915_gem_interrupt", i915_interrupt_info, 0},
Chris Wilson1ec14ad2010-12-04 11:30:53 +00003798 {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
3799 {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
3800 {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
Xiang, Haihao9010ebf2013-05-29 09:22:36 -07003801 {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS},
Jesse Barnesf97108d2010-01-29 11:27:07 -08003802 {"i915_rstdby_delays", i915_rstdby_delays, 0},
Deepak Sadb4bd12014-03-31 11:30:02 +05303803 {"i915_frequency_info", i915_frequency_info, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08003804 {"i915_delayfreq_table", i915_delayfreq_table, 0},
3805 {"i915_inttoext_table", i915_inttoext_table, 0},
3806 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07003807 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07003808 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07003809 {"i915_gfxec", i915_gfxec, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08003810 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03003811 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08003812 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01003813 {"i915_opregion", i915_opregion, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01003814 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07003815 {"i915_context_status", i915_context_status, 0},
Ben Widawsky6d794d42011-04-25 11:25:56 -07003816 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01003817 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01003818 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07003819 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03003820 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Rodrigo Vivid2e216d2014-01-24 13:36:17 -02003821 {"i915_sink_crc_eDP1", i915_sink_crc, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01003822 {"i915_energy_uJ", i915_energy_uJ, 0},
Paulo Zanoni371db662013-08-19 13:18:10 -03003823 {"i915_pc8_status", i915_pc8_status, 0},
Imre Deak1da51582013-11-25 17:15:35 +02003824 {"i915_power_domain_info", i915_power_domain_info, 0},
Jesse Barnes53f5e3c2014-02-07 12:48:15 -08003825 {"i915_display_info", i915_display_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05003826};
Ben Gamari27c202a2009-07-01 22:26:52 -04003827#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05003828
Lespiau, Damien06c5bf82013-10-17 19:09:56 +01003829static const struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02003830 const char *name;
3831 const struct file_operations *fops;
3832} i915_debugfs_files[] = {
3833 {"i915_wedged", &i915_wedged_fops},
3834 {"i915_max_freq", &i915_max_freq_fops},
3835 {"i915_min_freq", &i915_min_freq_fops},
3836 {"i915_cache_sharing", &i915_cache_sharing_fops},
3837 {"i915_ring_stop", &i915_ring_stop_fops},
Chris Wilson094f9a52013-09-25 17:34:55 +01003838 {"i915_ring_missed_irq", &i915_ring_missed_irq_fops},
3839 {"i915_ring_test_irq", &i915_ring_test_irq_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02003840 {"i915_gem_drop_caches", &i915_drop_caches_fops},
3841 {"i915_error_state", &i915_error_state_fops},
3842 {"i915_next_seqno", &i915_next_seqno_fops},
Damien Lespiaubd9db022013-10-15 18:55:36 +01003843 {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
Ville Syrjälä369a1342014-01-22 14:36:08 +02003844 {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
3845 {"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
3846 {"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
Daniel Vetter34b96742013-07-04 20:49:44 +02003847};
3848
Damien Lespiau07144422013-10-15 18:55:40 +01003849void intel_display_crc_init(struct drm_device *dev)
3850{
3851 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetterb3783602013-11-14 11:30:42 +01003852 enum pipe pipe;
Damien Lespiau07144422013-10-15 18:55:40 +01003853
Daniel Vetterb3783602013-11-14 11:30:42 +01003854 for_each_pipe(pipe) {
3855 struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
Damien Lespiau07144422013-10-15 18:55:40 +01003856
Damien Lespiaud538bbd2013-10-21 14:29:30 +01003857 pipe_crc->opened = false;
3858 spin_lock_init(&pipe_crc->lock);
Damien Lespiau07144422013-10-15 18:55:40 +01003859 init_waitqueue_head(&pipe_crc->wq);
3860 }
3861}
3862
Ben Gamari27c202a2009-07-01 22:26:52 -04003863int i915_debugfs_init(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05003864{
Daniel Vetter34b96742013-07-04 20:49:44 +02003865 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01003866
Ben Widawsky6d794d42011-04-25 11:25:56 -07003867 ret = i915_forcewake_create(minor->debugfs_root, minor);
3868 if (ret)
3869 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01003870
Damien Lespiau07144422013-10-15 18:55:40 +01003871 for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
3872 ret = i915_pipe_crc_create(minor->debugfs_root, minor, i);
3873 if (ret)
3874 return ret;
3875 }
3876
Daniel Vetter34b96742013-07-04 20:49:44 +02003877 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
3878 ret = i915_debugfs_create(minor->debugfs_root, minor,
3879 i915_debugfs_files[i].name,
3880 i915_debugfs_files[i].fops);
3881 if (ret)
3882 return ret;
3883 }
Mika Kuoppala40633212012-12-04 15:12:00 +02003884
Ben Gamari27c202a2009-07-01 22:26:52 -04003885 return drm_debugfs_create_files(i915_debugfs_list,
3886 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05003887 minor->debugfs_root, minor);
3888}
3889
Ben Gamari27c202a2009-07-01 22:26:52 -04003890void i915_debugfs_cleanup(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05003891{
Daniel Vetter34b96742013-07-04 20:49:44 +02003892 int i;
3893
Ben Gamari27c202a2009-07-01 22:26:52 -04003894 drm_debugfs_remove_files(i915_debugfs_list,
3895 I915_DEBUGFS_ENTRIES, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01003896
Ben Widawsky6d794d42011-04-25 11:25:56 -07003897 drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops,
3898 1, minor);
Damien Lespiau07144422013-10-15 18:55:40 +01003899
Daniel Vettere309a992013-10-16 22:55:51 +02003900 for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
Damien Lespiau07144422013-10-15 18:55:40 +01003901 struct drm_info_list *info_list =
3902 (struct drm_info_list *)&i915_pipe_crc_data[i];
3903
3904 drm_debugfs_remove_files(info_list, 1, minor);
3905 }
3906
Daniel Vetter34b96742013-07-04 20:49:44 +02003907 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
3908 struct drm_info_list *info_list =
3909 (struct drm_info_list *) i915_debugfs_files[i].fops;
3910
3911 drm_debugfs_remove_files(info_list, 1, minor);
3912 }
Ben Gamari20172632009-02-17 20:08:50 -05003913}