blob: ada095023dad20061609909c7724b309a66a25fc [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>
Chris Wilsonf3cd4742009-10-13 22:20:20 +010030#include <linux/debugfs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090031#include <linux/slab.h>
Paul Gortmaker2d1a8a42011-08-30 18:16:33 -040032#include <linux/export.h>
Chris Wilson6d2b88852013-08-07 18:30:54 +010033#include <linux/list_sort.h>
Jesse Barnesec013e72013-08-20 10:29:23 +010034#include <asm/msr-index.h>
David Howells760285e2012-10-02 18:01:07 +010035#include <drm/drmP.h>
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010036#include "intel_drv.h"
Chris Wilsone5c65262010-11-01 11:35:28 +000037#include "intel_ringbuffer.h"
David Howells760285e2012-10-02 18:01:07 +010038#include <drm/i915_drm.h>
Ben Gamari20172632009-02-17 20:08:50 -050039#include "i915_drv.h"
40
41#define DRM_I915_RING_DEBUG 1
42
43
44#if defined(CONFIG_DEBUG_FS)
45
Chris Wilsonf13d3f72010-09-20 17:36:15 +010046enum {
Chris Wilson69dc4982010-10-19 10:36:51 +010047 ACTIVE_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010048 INACTIVE_LIST,
Chris Wilsond21d5972010-09-26 11:19:33 +010049 PINNED_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010050};
Ben Gamari433e12f2009-02-17 20:08:51 -050051
Chris Wilson70d39fe2010-08-25 16:03:34 +010052static const char *yesno(int v)
53{
54 return v ? "yes" : "no";
55}
56
57static int i915_capabilities(struct seq_file *m, void *data)
58{
59 struct drm_info_node *node = (struct drm_info_node *) m->private;
60 struct drm_device *dev = node->minor->dev;
61 const struct intel_device_info *info = INTEL_INFO(dev);
62
63 seq_printf(m, "gen: %d\n", info->gen);
Paulo Zanoni03d00ac2011-10-14 18:17:41 -030064 seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
Damien Lespiau79fc46d2013-04-23 16:37:17 +010065#define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
66#define SEP_SEMICOLON ;
67 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
68#undef PRINT_FLAG
69#undef SEP_SEMICOLON
Chris Wilson70d39fe2010-08-25 16:03:34 +010070
71 return 0;
72}
Ben Gamari433e12f2009-02-17 20:08:51 -050073
Chris Wilson05394f32010-11-08 19:18:58 +000074static const char *get_pin_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000075{
Chris Wilson05394f32010-11-08 19:18:58 +000076 if (obj->user_pin_count > 0)
Chris Wilsona6172a82009-02-11 14:26:38 +000077 return "P";
Chris Wilson05394f32010-11-08 19:18:58 +000078 else if (obj->pin_count > 0)
Chris Wilsona6172a82009-02-11 14:26:38 +000079 return "p";
80 else
81 return " ";
82}
83
Chris Wilson05394f32010-11-08 19:18:58 +000084static const char *get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000085{
Akshay Joshi0206e352011-08-16 15:34:10 -040086 switch (obj->tiling_mode) {
87 default:
88 case I915_TILING_NONE: return " ";
89 case I915_TILING_X: return "X";
90 case I915_TILING_Y: return "Y";
91 }
Chris Wilsona6172a82009-02-11 14:26:38 +000092}
93
Ben Widawsky1d693bc2013-07-31 17:00:00 -070094static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
95{
96 return obj->has_global_gtt_mapping ? "g" : " ";
97}
98
Chris Wilson37811fc2010-08-25 22:45:57 +010099static void
100describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
101{
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700102 struct i915_vma *vma;
Ville Syrjäläfb1ae912013-08-22 19:21:30 +0300103 seq_printf(m, "%pK: %s%s%s %8zdKiB %02x %02x %u %u %u%s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100104 &obj->base,
105 get_pin_flag(obj),
106 get_tiling_flag(obj),
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700107 get_global_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800108 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100109 obj->base.read_domains,
110 obj->base.write_domain,
Chris Wilson0201f1e2012-07-20 12:41:01 +0100111 obj->last_read_seqno,
112 obj->last_write_seqno,
Chris Wilsoncaea7472010-11-12 13:53:37 +0000113 obj->last_fenced_seqno,
Mika Kuoppala84734a02013-07-12 16:50:57 +0300114 i915_cache_level_str(obj->cache_level),
Chris Wilson37811fc2010-08-25 22:45:57 +0100115 obj->dirty ? " dirty" : "",
116 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
117 if (obj->base.name)
118 seq_printf(m, " (name: %d)", obj->base.name);
Chris Wilsonc110a6d2012-08-11 15:41:02 +0100119 if (obj->pin_count)
120 seq_printf(m, " (pinned x %d)", obj->pin_count);
Chris Wilsoncc98b412013-08-09 12:25:09 +0100121 if (obj->pin_display)
122 seq_printf(m, " (display)");
Chris Wilson37811fc2010-08-25 22:45:57 +0100123 if (obj->fence_reg != I915_FENCE_REG_NONE)
124 seq_printf(m, " (fence: %d)", obj->fence_reg);
Ben Widawsky1d693bc2013-07-31 17:00:00 -0700125 list_for_each_entry(vma, &obj->vma_list, vma_link) {
126 if (!i915_is_ggtt(vma->vm))
127 seq_puts(m, " (pp");
128 else
129 seq_puts(m, " (g");
130 seq_printf(m, "gtt offset: %08lx, size: %08lx)",
131 vma->node.start, vma->node.size);
132 }
Chris Wilsonc1ad11f2012-11-15 11:32:21 +0000133 if (obj->stolen)
134 seq_printf(m, " (stolen: %08lx)", obj->stolen->start);
Chris Wilson6299f992010-11-24 12:23:44 +0000135 if (obj->pin_mappable || obj->fault_mappable) {
136 char s[3], *t = s;
137 if (obj->pin_mappable)
138 *t++ = 'p';
139 if (obj->fault_mappable)
140 *t++ = 'f';
141 *t = '\0';
142 seq_printf(m, " (%s mappable)", s);
143 }
Chris Wilson69dc4982010-10-19 10:36:51 +0100144 if (obj->ring != NULL)
145 seq_printf(m, " (%s)", obj->ring->name);
Chris Wilson37811fc2010-08-25 22:45:57 +0100146}
147
Ben Gamari433e12f2009-02-17 20:08:51 -0500148static int i915_gem_object_list_info(struct seq_file *m, void *data)
Ben Gamari20172632009-02-17 20:08:50 -0500149{
150 struct drm_info_node *node = (struct drm_info_node *) m->private;
Ben Gamari433e12f2009-02-17 20:08:51 -0500151 uintptr_t list = (uintptr_t) node->info_ent->data;
152 struct list_head *head;
Ben Gamari20172632009-02-17 20:08:50 -0500153 struct drm_device *dev = node->minor->dev;
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700154 struct drm_i915_private *dev_priv = dev->dev_private;
155 struct i915_address_space *vm = &dev_priv->gtt.base;
Ben Widawskyca191b12013-07-31 17:00:14 -0700156 struct i915_vma *vma;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100157 size_t total_obj_size, total_gtt_size;
158 int count, ret;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100159
160 ret = mutex_lock_interruptible(&dev->struct_mutex);
161 if (ret)
162 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500163
Ben Widawskyca191b12013-07-31 17:00:14 -0700164 /* FIXME: the user of this interface might want more than just GGTT */
Ben Gamari433e12f2009-02-17 20:08:51 -0500165 switch (list) {
166 case ACTIVE_LIST:
Damien Lespiau267f0c92013-06-24 22:59:48 +0100167 seq_puts(m, "Active:\n");
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700168 head = &vm->active_list;
Ben Gamari433e12f2009-02-17 20:08:51 -0500169 break;
170 case INACTIVE_LIST:
Damien Lespiau267f0c92013-06-24 22:59:48 +0100171 seq_puts(m, "Inactive:\n");
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700172 head = &vm->inactive_list;
Ben Gamari433e12f2009-02-17 20:08:51 -0500173 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500174 default:
Chris Wilsonde227ef2010-07-03 07:58:38 +0100175 mutex_unlock(&dev->struct_mutex);
176 return -EINVAL;
Ben Gamari433e12f2009-02-17 20:08:51 -0500177 }
178
Chris Wilson8f2480f2010-09-26 11:44:19 +0100179 total_obj_size = total_gtt_size = count = 0;
Ben Widawskyca191b12013-07-31 17:00:14 -0700180 list_for_each_entry(vma, head, mm_list) {
181 seq_printf(m, " ");
182 describe_obj(m, vma->obj);
183 seq_printf(m, "\n");
184 total_obj_size += vma->obj->base.size;
185 total_gtt_size += vma->node.size;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100186 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500187 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100188 mutex_unlock(&dev->struct_mutex);
Carl Worth5e118f42009-03-20 11:54:25 -0700189
Chris Wilson8f2480f2010-09-26 11:44:19 +0100190 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
191 count, total_obj_size, total_gtt_size);
Ben Gamari20172632009-02-17 20:08:50 -0500192 return 0;
193}
194
Chris Wilson6d2b88852013-08-07 18:30:54 +0100195static int obj_rank_by_stolen(void *priv,
196 struct list_head *A, struct list_head *B)
197{
198 struct drm_i915_gem_object *a =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200199 container_of(A, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100200 struct drm_i915_gem_object *b =
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200201 container_of(B, struct drm_i915_gem_object, obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100202
203 return a->stolen->start - b->stolen->start;
204}
205
206static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
207{
208 struct drm_info_node *node = (struct drm_info_node *) m->private;
209 struct drm_device *dev = node->minor->dev;
210 struct drm_i915_private *dev_priv = dev->dev_private;
211 struct drm_i915_gem_object *obj;
212 size_t total_obj_size, total_gtt_size;
213 LIST_HEAD(stolen);
214 int count, ret;
215
216 ret = mutex_lock_interruptible(&dev->struct_mutex);
217 if (ret)
218 return ret;
219
220 total_obj_size = total_gtt_size = count = 0;
221 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
222 if (obj->stolen == NULL)
223 continue;
224
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200225 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100226
227 total_obj_size += obj->base.size;
228 total_gtt_size += i915_gem_obj_ggtt_size(obj);
229 count++;
230 }
231 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
232 if (obj->stolen == NULL)
233 continue;
234
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200235 list_add(&obj->obj_exec_link, &stolen);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100236
237 total_obj_size += obj->base.size;
238 count++;
239 }
240 list_sort(NULL, &stolen, obj_rank_by_stolen);
241 seq_puts(m, "Stolen:\n");
242 while (!list_empty(&stolen)) {
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200243 obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100244 seq_puts(m, " ");
245 describe_obj(m, obj);
246 seq_putc(m, '\n');
Ben Widawskyb25cb2f2013-08-14 11:38:33 +0200247 list_del_init(&obj->obj_exec_link);
Chris Wilson6d2b88852013-08-07 18:30:54 +0100248 }
249 mutex_unlock(&dev->struct_mutex);
250
251 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
252 count, total_obj_size, total_gtt_size);
253 return 0;
254}
255
Chris Wilson6299f992010-11-24 12:23:44 +0000256#define count_objects(list, member) do { \
257 list_for_each_entry(obj, list, member) { \
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700258 size += i915_gem_obj_ggtt_size(obj); \
Chris Wilson6299f992010-11-24 12:23:44 +0000259 ++count; \
260 if (obj->map_and_fenceable) { \
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700261 mappable_size += i915_gem_obj_ggtt_size(obj); \
Chris Wilson6299f992010-11-24 12:23:44 +0000262 ++mappable_count; \
263 } \
264 } \
Akshay Joshi0206e352011-08-16 15:34:10 -0400265} while (0)
Chris Wilson6299f992010-11-24 12:23:44 +0000266
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100267struct file_stats {
268 int count;
269 size_t total, active, inactive, unbound;
270};
271
272static int per_file_stats(int id, void *ptr, void *data)
273{
274 struct drm_i915_gem_object *obj = ptr;
275 struct file_stats *stats = data;
276
277 stats->count++;
278 stats->total += obj->base.size;
279
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700280 if (i915_gem_obj_ggtt_bound(obj)) {
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100281 if (!list_empty(&obj->ring_list))
282 stats->active += obj->base.size;
283 else
284 stats->inactive += obj->base.size;
285 } else {
286 if (!list_empty(&obj->global_list))
287 stats->unbound += obj->base.size;
288 }
289
290 return 0;
291}
292
Ben Widawskyca191b12013-07-31 17:00:14 -0700293#define count_vmas(list, member) do { \
294 list_for_each_entry(vma, list, member) { \
295 size += i915_gem_obj_ggtt_size(vma->obj); \
296 ++count; \
297 if (vma->obj->map_and_fenceable) { \
298 mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
299 ++mappable_count; \
300 } \
301 } \
302} while (0)
303
304static int i915_gem_object_info(struct seq_file *m, void* data)
Chris Wilson73aa8082010-09-30 11:46:12 +0100305{
306 struct drm_info_node *node = (struct drm_info_node *) m->private;
307 struct drm_device *dev = node->minor->dev;
308 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilsonb7abb712012-08-20 11:33:30 +0200309 u32 count, mappable_count, purgeable_count;
310 size_t size, mappable_size, purgeable_size;
Chris Wilson6299f992010-11-24 12:23:44 +0000311 struct drm_i915_gem_object *obj;
Ben Widawsky5cef07e2013-07-16 16:50:08 -0700312 struct i915_address_space *vm = &dev_priv->gtt.base;
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100313 struct drm_file *file;
Ben Widawskyca191b12013-07-31 17:00:14 -0700314 struct i915_vma *vma;
Chris Wilson73aa8082010-09-30 11:46:12 +0100315 int ret;
316
317 ret = mutex_lock_interruptible(&dev->struct_mutex);
318 if (ret)
319 return ret;
320
Chris Wilson6299f992010-11-24 12:23:44 +0000321 seq_printf(m, "%u objects, %zu bytes\n",
322 dev_priv->mm.object_count,
323 dev_priv->mm.object_memory);
324
325 size = count = mappable_size = mappable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700326 count_objects(&dev_priv->mm.bound_list, global_list);
Chris Wilson6299f992010-11-24 12:23:44 +0000327 seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
328 count, mappable_count, size, mappable_size);
329
330 size = count = mappable_size = mappable_count = 0;
Ben Widawskyca191b12013-07-31 17:00:14 -0700331 count_vmas(&vm->active_list, mm_list);
Chris Wilson6299f992010-11-24 12:23:44 +0000332 seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n",
333 count, mappable_count, size, mappable_size);
334
335 size = count = mappable_size = mappable_count = 0;
Ben Widawskyca191b12013-07-31 17:00:14 -0700336 count_vmas(&vm->inactive_list, mm_list);
Chris Wilson6299f992010-11-24 12:23:44 +0000337 seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n",
338 count, mappable_count, size, mappable_size);
339
Chris Wilsonb7abb712012-08-20 11:33:30 +0200340 size = count = purgeable_size = purgeable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700341 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
Chris Wilson6c085a72012-08-20 11:40:46 +0200342 size += obj->base.size, ++count;
Chris Wilsonb7abb712012-08-20 11:33:30 +0200343 if (obj->madv == I915_MADV_DONTNEED)
344 purgeable_size += obj->base.size, ++purgeable_count;
345 }
Chris Wilson6c085a72012-08-20 11:40:46 +0200346 seq_printf(m, "%u unbound objects, %zu bytes\n", count, size);
347
Chris Wilson6299f992010-11-24 12:23:44 +0000348 size = count = mappable_size = mappable_count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700349 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
Chris Wilson6299f992010-11-24 12:23:44 +0000350 if (obj->fault_mappable) {
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700351 size += i915_gem_obj_ggtt_size(obj);
Chris Wilson6299f992010-11-24 12:23:44 +0000352 ++count;
353 }
354 if (obj->pin_mappable) {
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700355 mappable_size += i915_gem_obj_ggtt_size(obj);
Chris Wilson6299f992010-11-24 12:23:44 +0000356 ++mappable_count;
357 }
Chris Wilsonb7abb712012-08-20 11:33:30 +0200358 if (obj->madv == I915_MADV_DONTNEED) {
359 purgeable_size += obj->base.size;
360 ++purgeable_count;
361 }
Chris Wilson6299f992010-11-24 12:23:44 +0000362 }
Chris Wilsonb7abb712012-08-20 11:33:30 +0200363 seq_printf(m, "%u purgeable objects, %zu bytes\n",
364 purgeable_count, purgeable_size);
Chris Wilson6299f992010-11-24 12:23:44 +0000365 seq_printf(m, "%u pinned mappable objects, %zu bytes\n",
366 mappable_count, mappable_size);
367 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
368 count, size);
369
Ben Widawsky93d18792013-01-17 12:45:17 -0800370 seq_printf(m, "%zu [%lu] gtt total\n",
Ben Widawsky853ba5d2013-07-16 16:50:05 -0700371 dev_priv->gtt.base.total,
372 dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
Chris Wilson73aa8082010-09-30 11:46:12 +0100373
Damien Lespiau267f0c92013-06-24 22:59:48 +0100374 seq_putc(m, '\n');
Chris Wilson2db8e9d2013-06-04 23:49:08 +0100375 list_for_each_entry_reverse(file, &dev->filelist, lhead) {
376 struct file_stats stats;
377
378 memset(&stats, 0, sizeof(stats));
379 idr_for_each(&file->object_idr, per_file_stats, &stats);
380 seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n",
381 get_pid_task(file->pid, PIDTYPE_PID)->comm,
382 stats.count,
383 stats.total,
384 stats.active,
385 stats.inactive,
386 stats.unbound);
387 }
388
Chris Wilson73aa8082010-09-30 11:46:12 +0100389 mutex_unlock(&dev->struct_mutex);
390
391 return 0;
392}
393
Damien Lespiauaee56cf2013-06-24 22:59:49 +0100394static int i915_gem_gtt_info(struct seq_file *m, void *data)
Chris Wilson08c18322011-01-10 00:00:24 +0000395{
396 struct drm_info_node *node = (struct drm_info_node *) m->private;
397 struct drm_device *dev = node->minor->dev;
Chris Wilson1b502472012-04-24 15:47:30 +0100398 uintptr_t list = (uintptr_t) node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000399 struct drm_i915_private *dev_priv = dev->dev_private;
400 struct drm_i915_gem_object *obj;
401 size_t total_obj_size, total_gtt_size;
402 int count, ret;
403
404 ret = mutex_lock_interruptible(&dev->struct_mutex);
405 if (ret)
406 return ret;
407
408 total_obj_size = total_gtt_size = count = 0;
Ben Widawsky35c20a62013-05-31 11:28:48 -0700409 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
Chris Wilson1b502472012-04-24 15:47:30 +0100410 if (list == PINNED_LIST && obj->pin_count == 0)
411 continue;
412
Damien Lespiau267f0c92013-06-24 22:59:48 +0100413 seq_puts(m, " ");
Chris Wilson08c18322011-01-10 00:00:24 +0000414 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100415 seq_putc(m, '\n');
Chris Wilson08c18322011-01-10 00:00:24 +0000416 total_obj_size += obj->base.size;
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700417 total_gtt_size += i915_gem_obj_ggtt_size(obj);
Chris Wilson08c18322011-01-10 00:00:24 +0000418 count++;
419 }
420
421 mutex_unlock(&dev->struct_mutex);
422
423 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
424 count, total_obj_size, total_gtt_size);
425
426 return 0;
427}
428
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100429static int i915_gem_pageflip_info(struct seq_file *m, void *data)
430{
431 struct drm_info_node *node = (struct drm_info_node *) m->private;
432 struct drm_device *dev = node->minor->dev;
433 unsigned long flags;
434 struct intel_crtc *crtc;
435
436 list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800437 const char pipe = pipe_name(crtc->pipe);
438 const char plane = plane_name(crtc->plane);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100439 struct intel_unpin_work *work;
440
441 spin_lock_irqsave(&dev->event_lock, flags);
442 work = crtc->unpin_work;
443 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800444 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100445 pipe, plane);
446 } else {
Chris Wilsone7d841c2012-12-03 11:36:30 +0000447 if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800448 seq_printf(m, "Flip queued on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100449 pipe, plane);
450 } else {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800451 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100452 pipe, plane);
453 }
454 if (work->enable_stall_check)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100455 seq_puts(m, "Stall check enabled, ");
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100456 else
Damien Lespiau267f0c92013-06-24 22:59:48 +0100457 seq_puts(m, "Stall check waiting for page flip ioctl, ");
Chris Wilsone7d841c2012-12-03 11:36:30 +0000458 seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100459
460 if (work->old_fb_obj) {
Chris Wilson05394f32010-11-08 19:18:58 +0000461 struct drm_i915_gem_object *obj = work->old_fb_obj;
462 if (obj)
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700463 seq_printf(m, "Old framebuffer gtt_offset 0x%08lx\n",
464 i915_gem_obj_ggtt_offset(obj));
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100465 }
466 if (work->pending_flip_obj) {
Chris Wilson05394f32010-11-08 19:18:58 +0000467 struct drm_i915_gem_object *obj = work->pending_flip_obj;
468 if (obj)
Ben Widawskyf343c5f2013-07-05 14:41:04 -0700469 seq_printf(m, "New framebuffer gtt_offset 0x%08lx\n",
470 i915_gem_obj_ggtt_offset(obj));
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100471 }
472 }
473 spin_unlock_irqrestore(&dev->event_lock, flags);
474 }
475
476 return 0;
477}
478
Ben Gamari20172632009-02-17 20:08:50 -0500479static int i915_gem_request_info(struct seq_file *m, void *data)
480{
481 struct drm_info_node *node = (struct drm_info_node *) m->private;
482 struct drm_device *dev = node->minor->dev;
483 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100484 struct intel_ring_buffer *ring;
Ben Gamari20172632009-02-17 20:08:50 -0500485 struct drm_i915_gem_request *gem_request;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100486 int ret, count, i;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100487
488 ret = mutex_lock_interruptible(&dev->struct_mutex);
489 if (ret)
490 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500491
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100492 count = 0;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100493 for_each_ring(ring, dev_priv, i) {
494 if (list_empty(&ring->request_list))
495 continue;
496
497 seq_printf(m, "%s requests:\n", ring->name);
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100498 list_for_each_entry(gem_request,
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100499 &ring->request_list,
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100500 list) {
501 seq_printf(m, " %d @ %d\n",
502 gem_request->seqno,
503 (int) (jiffies - gem_request->emitted_jiffies));
504 }
505 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500506 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100507 mutex_unlock(&dev->struct_mutex);
508
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100509 if (count == 0)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100510 seq_puts(m, "No requests\n");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100511
Ben Gamari20172632009-02-17 20:08:50 -0500512 return 0;
513}
514
Chris Wilsonb2223492010-10-27 15:27:33 +0100515static void i915_ring_seqno_info(struct seq_file *m,
516 struct intel_ring_buffer *ring)
517{
518 if (ring->get_seqno) {
Mika Kuoppala43a7b922012-12-04 15:12:01 +0200519 seq_printf(m, "Current sequence (%s): %u\n",
Chris Wilsonb2eadbc2012-08-09 10:58:30 +0100520 ring->name, ring->get_seqno(ring, false));
Chris Wilsonb2223492010-10-27 15:27:33 +0100521 }
522}
523
Ben Gamari20172632009-02-17 20:08:50 -0500524static int i915_gem_seqno_info(struct seq_file *m, void *data)
525{
526 struct drm_info_node *node = (struct drm_info_node *) m->private;
527 struct drm_device *dev = node->minor->dev;
528 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100529 struct intel_ring_buffer *ring;
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000530 int ret, i;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100531
532 ret = mutex_lock_interruptible(&dev->struct_mutex);
533 if (ret)
534 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500535
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100536 for_each_ring(ring, dev_priv, i)
537 i915_ring_seqno_info(m, ring);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100538
539 mutex_unlock(&dev->struct_mutex);
540
Ben Gamari20172632009-02-17 20:08:50 -0500541 return 0;
542}
543
544
545static int i915_interrupt_info(struct seq_file *m, void *data)
546{
547 struct drm_info_node *node = (struct drm_info_node *) m->private;
548 struct drm_device *dev = node->minor->dev;
549 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100550 struct intel_ring_buffer *ring;
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800551 int ret, i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100552
553 ret = mutex_lock_interruptible(&dev->struct_mutex);
554 if (ret)
555 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500556
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700557 if (IS_VALLEYVIEW(dev)) {
558 seq_printf(m, "Display IER:\t%08x\n",
559 I915_READ(VLV_IER));
560 seq_printf(m, "Display IIR:\t%08x\n",
561 I915_READ(VLV_IIR));
562 seq_printf(m, "Display IIR_RW:\t%08x\n",
563 I915_READ(VLV_IIR_RW));
564 seq_printf(m, "Display IMR:\t%08x\n",
565 I915_READ(VLV_IMR));
566 for_each_pipe(pipe)
567 seq_printf(m, "Pipe %c stat:\t%08x\n",
568 pipe_name(pipe),
569 I915_READ(PIPESTAT(pipe)));
570
571 seq_printf(m, "Master IER:\t%08x\n",
572 I915_READ(VLV_MASTER_IER));
573
574 seq_printf(m, "Render IER:\t%08x\n",
575 I915_READ(GTIER));
576 seq_printf(m, "Render IIR:\t%08x\n",
577 I915_READ(GTIIR));
578 seq_printf(m, "Render IMR:\t%08x\n",
579 I915_READ(GTIMR));
580
581 seq_printf(m, "PM IER:\t\t%08x\n",
582 I915_READ(GEN6_PMIER));
583 seq_printf(m, "PM IIR:\t\t%08x\n",
584 I915_READ(GEN6_PMIIR));
585 seq_printf(m, "PM IMR:\t\t%08x\n",
586 I915_READ(GEN6_PMIMR));
587
588 seq_printf(m, "Port hotplug:\t%08x\n",
589 I915_READ(PORT_HOTPLUG_EN));
590 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
591 I915_READ(VLV_DPFLIPSTAT));
592 seq_printf(m, "DPINVGTT:\t%08x\n",
593 I915_READ(DPINVGTT));
594
595 } else if (!HAS_PCH_SPLIT(dev)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800596 seq_printf(m, "Interrupt enable: %08x\n",
597 I915_READ(IER));
598 seq_printf(m, "Interrupt identity: %08x\n",
599 I915_READ(IIR));
600 seq_printf(m, "Interrupt mask: %08x\n",
601 I915_READ(IMR));
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800602 for_each_pipe(pipe)
603 seq_printf(m, "Pipe %c stat: %08x\n",
604 pipe_name(pipe),
605 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800606 } else {
607 seq_printf(m, "North Display Interrupt enable: %08x\n",
608 I915_READ(DEIER));
609 seq_printf(m, "North Display Interrupt identity: %08x\n",
610 I915_READ(DEIIR));
611 seq_printf(m, "North Display Interrupt mask: %08x\n",
612 I915_READ(DEIMR));
613 seq_printf(m, "South Display Interrupt enable: %08x\n",
614 I915_READ(SDEIER));
615 seq_printf(m, "South Display Interrupt identity: %08x\n",
616 I915_READ(SDEIIR));
617 seq_printf(m, "South Display Interrupt mask: %08x\n",
618 I915_READ(SDEIMR));
619 seq_printf(m, "Graphics Interrupt enable: %08x\n",
620 I915_READ(GTIER));
621 seq_printf(m, "Graphics Interrupt identity: %08x\n",
622 I915_READ(GTIIR));
623 seq_printf(m, "Graphics Interrupt mask: %08x\n",
624 I915_READ(GTIMR));
625 }
Ben Gamari20172632009-02-17 20:08:50 -0500626 seq_printf(m, "Interrupts received: %d\n",
627 atomic_read(&dev_priv->irq_received));
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100628 for_each_ring(ring, dev_priv, i) {
Jesse Barnesda64c6f2011-08-09 09:17:46 -0700629 if (IS_GEN6(dev) || IS_GEN7(dev)) {
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100630 seq_printf(m,
631 "Graphics Interrupt mask (%s): %08x\n",
632 ring->name, I915_READ_IMR(ring));
Chris Wilson9862e602011-01-04 22:22:17 +0000633 }
Chris Wilsona2c7f6f2012-09-01 20:51:22 +0100634 i915_ring_seqno_info(m, ring);
Chris Wilson9862e602011-01-04 22:22:17 +0000635 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100636 mutex_unlock(&dev->struct_mutex);
637
Ben Gamari20172632009-02-17 20:08:50 -0500638 return 0;
639}
640
Chris Wilsona6172a82009-02-11 14:26:38 +0000641static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
642{
643 struct drm_info_node *node = (struct drm_info_node *) m->private;
644 struct drm_device *dev = node->minor->dev;
645 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100646 int i, ret;
647
648 ret = mutex_lock_interruptible(&dev->struct_mutex);
649 if (ret)
650 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000651
652 seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
653 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
654 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson05394f32010-11-08 19:18:58 +0000655 struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj;
Chris Wilsona6172a82009-02-11 14:26:38 +0000656
Chris Wilson6c085a72012-08-20 11:40:46 +0200657 seq_printf(m, "Fence %d, pin count = %d, object = ",
658 i, dev_priv->fence_regs[i].pin_count);
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100659 if (obj == NULL)
Damien Lespiau267f0c92013-06-24 22:59:48 +0100660 seq_puts(m, "unused");
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100661 else
Chris Wilson05394f32010-11-08 19:18:58 +0000662 describe_obj(m, obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +0100663 seq_putc(m, '\n');
Chris Wilsona6172a82009-02-11 14:26:38 +0000664 }
665
Chris Wilson05394f32010-11-08 19:18:58 +0000666 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000667 return 0;
668}
669
Ben Gamari20172632009-02-17 20:08:50 -0500670static int i915_hws_info(struct seq_file *m, void *data)
671{
672 struct drm_info_node *node = (struct drm_info_node *) m->private;
673 struct drm_device *dev = node->minor->dev;
674 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilson4066c0a2010-10-29 21:00:54 +0100675 struct intel_ring_buffer *ring;
Daniel Vetter1a240d42012-11-29 22:18:51 +0100676 const u32 *hws;
Chris Wilson4066c0a2010-10-29 21:00:54 +0100677 int i;
Ben Gamari20172632009-02-17 20:08:50 -0500678
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000679 ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
Daniel Vetter1a240d42012-11-29 22:18:51 +0100680 hws = ring->status_page.page_addr;
Ben Gamari20172632009-02-17 20:08:50 -0500681 if (hws == NULL)
682 return 0;
683
684 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
685 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
686 i * 4,
687 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
688 }
689 return 0;
690}
691
Daniel Vetterd5442302012-04-27 15:17:40 +0200692static ssize_t
693i915_error_state_write(struct file *filp,
694 const char __user *ubuf,
695 size_t cnt,
696 loff_t *ppos)
697{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300698 struct i915_error_state_file_priv *error_priv = filp->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200699 struct drm_device *dev = error_priv->dev;
Daniel Vetter22bcfc62012-08-09 15:07:02 +0200700 int ret;
Daniel Vetterd5442302012-04-27 15:17:40 +0200701
702 DRM_DEBUG_DRIVER("Resetting error state\n");
703
Daniel Vetter22bcfc62012-08-09 15:07:02 +0200704 ret = mutex_lock_interruptible(&dev->struct_mutex);
705 if (ret)
706 return ret;
707
Daniel Vetterd5442302012-04-27 15:17:40 +0200708 i915_destroy_error_state(dev);
709 mutex_unlock(&dev->struct_mutex);
710
711 return cnt;
712}
713
714static int i915_error_state_open(struct inode *inode, struct file *file)
715{
716 struct drm_device *dev = inode->i_private;
Daniel Vetterd5442302012-04-27 15:17:40 +0200717 struct i915_error_state_file_priv *error_priv;
Daniel Vetterd5442302012-04-27 15:17:40 +0200718
719 error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
720 if (!error_priv)
721 return -ENOMEM;
722
723 error_priv->dev = dev;
724
Mika Kuoppala95d5bfb32013-06-06 15:18:40 +0300725 i915_error_state_get(dev, error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +0200726
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300727 file->private_data = error_priv;
728
729 return 0;
Daniel Vetterd5442302012-04-27 15:17:40 +0200730}
731
732static int i915_error_state_release(struct inode *inode, struct file *file)
733{
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300734 struct i915_error_state_file_priv *error_priv = file->private_data;
Daniel Vetterd5442302012-04-27 15:17:40 +0200735
Mika Kuoppala95d5bfb32013-06-06 15:18:40 +0300736 i915_error_state_put(error_priv);
Daniel Vetterd5442302012-04-27 15:17:40 +0200737 kfree(error_priv);
738
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300739 return 0;
740}
741
742static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
743 size_t count, loff_t *pos)
744{
745 struct i915_error_state_file_priv *error_priv = file->private_data;
746 struct drm_i915_error_state_buf error_str;
747 loff_t tmp_pos = 0;
748 ssize_t ret_count = 0;
Mika Kuoppala4dc955f2013-06-06 15:18:41 +0300749 int ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300750
Mika Kuoppala4dc955f2013-06-06 15:18:41 +0300751 ret = i915_error_state_buf_init(&error_str, count, *pos);
752 if (ret)
753 return ret;
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300754
Mika Kuoppalafc16b482013-06-06 15:18:39 +0300755 ret = i915_error_state_to_str(&error_str, error_priv);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300756 if (ret)
757 goto out;
758
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300759 ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
760 error_str.buf,
761 error_str.bytes);
762
763 if (ret_count < 0)
764 ret = ret_count;
765 else
766 *pos = error_str.start + ret_count;
767out:
Mika Kuoppala4dc955f2013-06-06 15:18:41 +0300768 i915_error_state_buf_release(&error_str);
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300769 return ret ?: ret_count;
Daniel Vetterd5442302012-04-27 15:17:40 +0200770}
771
772static const struct file_operations i915_error_state_fops = {
773 .owner = THIS_MODULE,
774 .open = i915_error_state_open,
Mika Kuoppalaedc3d882013-05-23 13:55:35 +0300775 .read = i915_error_state_read,
Daniel Vetterd5442302012-04-27 15:17:40 +0200776 .write = i915_error_state_write,
777 .llseek = default_llseek,
778 .release = i915_error_state_release,
779};
780
Kees Cook647416f2013-03-10 14:10:06 -0700781static int
782i915_next_seqno_get(void *data, u64 *val)
Mika Kuoppala40633212012-12-04 15:12:00 +0200783{
Kees Cook647416f2013-03-10 14:10:06 -0700784 struct drm_device *dev = data;
Mika Kuoppala40633212012-12-04 15:12:00 +0200785 drm_i915_private_t *dev_priv = dev->dev_private;
Mika Kuoppala40633212012-12-04 15:12:00 +0200786 int ret;
787
788 ret = mutex_lock_interruptible(&dev->struct_mutex);
789 if (ret)
790 return ret;
791
Kees Cook647416f2013-03-10 14:10:06 -0700792 *val = dev_priv->next_seqno;
Mika Kuoppala40633212012-12-04 15:12:00 +0200793 mutex_unlock(&dev->struct_mutex);
794
Kees Cook647416f2013-03-10 14:10:06 -0700795 return 0;
Mika Kuoppala40633212012-12-04 15:12:00 +0200796}
797
Kees Cook647416f2013-03-10 14:10:06 -0700798static int
799i915_next_seqno_set(void *data, u64 val)
Mika Kuoppala40633212012-12-04 15:12:00 +0200800{
Kees Cook647416f2013-03-10 14:10:06 -0700801 struct drm_device *dev = data;
Mika Kuoppala40633212012-12-04 15:12:00 +0200802 int ret;
803
Mika Kuoppala40633212012-12-04 15:12:00 +0200804 ret = mutex_lock_interruptible(&dev->struct_mutex);
805 if (ret)
806 return ret;
807
Mika Kuoppalae94fbaa2012-12-19 11:13:09 +0200808 ret = i915_gem_set_seqno(dev, val);
Mika Kuoppala40633212012-12-04 15:12:00 +0200809 mutex_unlock(&dev->struct_mutex);
810
Kees Cook647416f2013-03-10 14:10:06 -0700811 return ret;
Mika Kuoppala40633212012-12-04 15:12:00 +0200812}
813
Kees Cook647416f2013-03-10 14:10:06 -0700814DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
815 i915_next_seqno_get, i915_next_seqno_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +0300816 "0x%llx\n");
Mika Kuoppala40633212012-12-04 15:12:00 +0200817
Jesse Barnesf97108d2010-01-29 11:27:07 -0800818static int i915_rstdby_delays(struct seq_file *m, void *unused)
819{
820 struct drm_info_node *node = (struct drm_info_node *) m->private;
821 struct drm_device *dev = node->minor->dev;
822 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700823 u16 crstanddelay;
824 int ret;
825
826 ret = mutex_lock_interruptible(&dev->struct_mutex);
827 if (ret)
828 return ret;
829
830 crstanddelay = I915_READ16(CRSTANDVID);
831
832 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800833
834 seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
835
836 return 0;
837}
838
839static int i915_cur_delayinfo(struct seq_file *m, void *unused)
840{
841 struct drm_info_node *node = (struct drm_info_node *) m->private;
842 struct drm_device *dev = node->minor->dev;
843 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawskyd1ebd8162011-04-25 20:11:50 +0100844 int ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800845
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800846 if (IS_GEN5(dev)) {
847 u16 rgvswctl = I915_READ16(MEMSWCTL);
848 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
849
850 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
851 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
852 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
853 MEMSTAT_VID_SHIFT);
854 seq_printf(m, "Current P-state: %d\n",
855 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
Jesse Barnes0a073b82013-04-17 15:54:58 -0700856 } else if ((IS_GEN6(dev) || IS_GEN7(dev)) && !IS_VALLEYVIEW(dev)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800857 u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
858 u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
859 u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
Chris Wilson8e8c06c2013-08-26 19:51:01 -0300860 u32 rpstat, cagf, reqf;
Jesse Barnesccab5c82011-01-18 15:49:25 -0800861 u32 rpupei, rpcurup, rpprevup;
862 u32 rpdownei, rpcurdown, rpprevdown;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800863 int max_freq;
864
865 /* RPSTAT1 is in the GT power well */
Ben Widawskyd1ebd8162011-04-25 20:11:50 +0100866 ret = mutex_lock_interruptible(&dev->struct_mutex);
867 if (ret)
868 return ret;
869
Ben Widawskyfcca7922011-04-25 11:23:07 -0700870 gen6_gt_force_wake_get(dev_priv);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800871
Chris Wilson8e8c06c2013-08-26 19:51:01 -0300872 reqf = I915_READ(GEN6_RPNSWREQ);
873 reqf &= ~GEN6_TURBO_DISABLE;
874 if (IS_HASWELL(dev))
875 reqf >>= 24;
876 else
877 reqf >>= 25;
878 reqf *= GT_FREQUENCY_MULTIPLIER;
879
Jesse Barnesccab5c82011-01-18 15:49:25 -0800880 rpstat = I915_READ(GEN6_RPSTAT1);
881 rpupei = I915_READ(GEN6_RP_CUR_UP_EI);
882 rpcurup = I915_READ(GEN6_RP_CUR_UP);
883 rpprevup = I915_READ(GEN6_RP_PREV_UP);
884 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI);
885 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN);
886 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN);
Ben Widawskyf82855d2013-01-29 12:00:15 -0800887 if (IS_HASWELL(dev))
888 cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
889 else
890 cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
891 cagf *= GT_FREQUENCY_MULTIPLIER;
Jesse Barnesccab5c82011-01-18 15:49:25 -0800892
Ben Widawskyd1ebd8162011-04-25 20:11:50 +0100893 gen6_gt_force_wake_put(dev_priv);
894 mutex_unlock(&dev->struct_mutex);
895
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800896 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnesccab5c82011-01-18 15:49:25 -0800897 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800898 seq_printf(m, "Render p-state ratio: %d\n",
899 (gt_perf_status & 0xff00) >> 8);
900 seq_printf(m, "Render p-state VID: %d\n",
901 gt_perf_status & 0xff);
902 seq_printf(m, "Render p-state limit: %d\n",
903 rp_state_limits & 0xff);
Chris Wilson8e8c06c2013-08-26 19:51:01 -0300904 seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
Ben Widawskyf82855d2013-01-29 12:00:15 -0800905 seq_printf(m, "CAGF: %dMHz\n", cagf);
Jesse Barnesccab5c82011-01-18 15:49:25 -0800906 seq_printf(m, "RP CUR UP EI: %dus\n", rpupei &
907 GEN6_CURICONT_MASK);
908 seq_printf(m, "RP CUR UP: %dus\n", rpcurup &
909 GEN6_CURBSYTAVG_MASK);
910 seq_printf(m, "RP PREV UP: %dus\n", rpprevup &
911 GEN6_CURBSYTAVG_MASK);
912 seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei &
913 GEN6_CURIAVG_MASK);
914 seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown &
915 GEN6_CURBSYTAVG_MASK);
916 seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown &
917 GEN6_CURBSYTAVG_MASK);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800918
919 max_freq = (rp_state_cap & 0xff0000) >> 16;
920 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Ben Widawskyc8735b02012-09-07 19:43:39 -0700921 max_freq * GT_FREQUENCY_MULTIPLIER);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800922
923 max_freq = (rp_state_cap & 0xff00) >> 8;
924 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Ben Widawskyc8735b02012-09-07 19:43:39 -0700925 max_freq * GT_FREQUENCY_MULTIPLIER);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800926
927 max_freq = rp_state_cap & 0xff;
928 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Ben Widawskyc8735b02012-09-07 19:43:39 -0700929 max_freq * GT_FREQUENCY_MULTIPLIER);
Ben Widawsky31c77382013-04-05 14:29:22 -0700930
931 seq_printf(m, "Max overclocked frequency: %dMHz\n",
932 dev_priv->rps.hw_max * GT_FREQUENCY_MULTIPLIER);
Jesse Barnes0a073b82013-04-17 15:54:58 -0700933 } else if (IS_VALLEYVIEW(dev)) {
934 u32 freq_sts, val;
935
Jesse Barnes259bd5d2013-04-22 15:59:30 -0700936 mutex_lock(&dev_priv->rps.hw_lock);
Jani Nikula64936252013-05-22 15:36:20 +0300937 freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
Jesse Barnes0a073b82013-04-17 15:54:58 -0700938 seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
939 seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
940
Jani Nikula64936252013-05-22 15:36:20 +0300941 val = vlv_punit_read(dev_priv, PUNIT_FUSE_BUS1);
Jesse Barnes0a073b82013-04-17 15:54:58 -0700942 seq_printf(m, "max GPU freq: %d MHz\n",
943 vlv_gpu_freq(dev_priv->mem_freq, val));
944
Jani Nikula64936252013-05-22 15:36:20 +0300945 val = vlv_punit_read(dev_priv, PUNIT_REG_GPU_LFM);
Jesse Barnes0a073b82013-04-17 15:54:58 -0700946 seq_printf(m, "min GPU freq: %d MHz\n",
947 vlv_gpu_freq(dev_priv->mem_freq, val));
948
949 seq_printf(m, "current GPU freq: %d MHz\n",
950 vlv_gpu_freq(dev_priv->mem_freq,
951 (freq_sts >> 8) & 0xff));
Jesse Barnes259bd5d2013-04-22 15:59:30 -0700952 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800953 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +0100954 seq_puts(m, "no P-state info available\n");
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800955 }
Jesse Barnesf97108d2010-01-29 11:27:07 -0800956
957 return 0;
958}
959
960static int i915_delayfreq_table(struct seq_file *m, void *unused)
961{
962 struct drm_info_node *node = (struct drm_info_node *) m->private;
963 struct drm_device *dev = node->minor->dev;
964 drm_i915_private_t *dev_priv = dev->dev_private;
965 u32 delayfreq;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700966 int ret, i;
967
968 ret = mutex_lock_interruptible(&dev->struct_mutex);
969 if (ret)
970 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800971
972 for (i = 0; i < 16; i++) {
973 delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700974 seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
975 (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800976 }
977
Ben Widawsky616fdb52011-10-05 11:44:54 -0700978 mutex_unlock(&dev->struct_mutex);
979
Jesse Barnesf97108d2010-01-29 11:27:07 -0800980 return 0;
981}
982
983static inline int MAP_TO_MV(int map)
984{
985 return 1250 - (map * 25);
986}
987
988static int i915_inttoext_table(struct seq_file *m, void *unused)
989{
990 struct drm_info_node *node = (struct drm_info_node *) m->private;
991 struct drm_device *dev = node->minor->dev;
992 drm_i915_private_t *dev_priv = dev->dev_private;
993 u32 inttoext;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700994 int ret, i;
995
996 ret = mutex_lock_interruptible(&dev->struct_mutex);
997 if (ret)
998 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800999
1000 for (i = 1; i <= 32; i++) {
1001 inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
1002 seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
1003 }
1004
Ben Widawsky616fdb52011-10-05 11:44:54 -07001005 mutex_unlock(&dev->struct_mutex);
1006
Jesse Barnesf97108d2010-01-29 11:27:07 -08001007 return 0;
1008}
1009
Ben Widawsky4d855292011-12-12 19:34:16 -08001010static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -08001011{
1012 struct drm_info_node *node = (struct drm_info_node *) m->private;
1013 struct drm_device *dev = node->minor->dev;
1014 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001015 u32 rgvmodectl, rstdbyctl;
1016 u16 crstandvid;
1017 int ret;
1018
1019 ret = mutex_lock_interruptible(&dev->struct_mutex);
1020 if (ret)
1021 return ret;
1022
1023 rgvmodectl = I915_READ(MEMMODECTL);
1024 rstdbyctl = I915_READ(RSTDBYCTL);
1025 crstandvid = I915_READ16(CRSTANDVID);
1026
1027 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -08001028
1029 seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
1030 "yes" : "no");
1031 seq_printf(m, "Boost freq: %d\n",
1032 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
1033 MEMMODE_BOOST_FREQ_SHIFT);
1034 seq_printf(m, "HW control enabled: %s\n",
1035 rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
1036 seq_printf(m, "SW control enabled: %s\n",
1037 rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
1038 seq_printf(m, "Gated voltage change: %s\n",
1039 rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
1040 seq_printf(m, "Starting frequency: P%d\n",
1041 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001042 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -08001043 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001044 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
1045 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
1046 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
1047 seq_printf(m, "Render standby enabled: %s\n",
1048 (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
Damien Lespiau267f0c92013-06-24 22:59:48 +01001049 seq_puts(m, "Current RS state: ");
Jesse Barnes88271da2011-01-05 12:01:24 -08001050 switch (rstdbyctl & RSX_STATUS_MASK) {
1051 case RSX_STATUS_ON:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001052 seq_puts(m, "on\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001053 break;
1054 case RSX_STATUS_RC1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001055 seq_puts(m, "RC1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001056 break;
1057 case RSX_STATUS_RC1E:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001058 seq_puts(m, "RC1E\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001059 break;
1060 case RSX_STATUS_RS1:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001061 seq_puts(m, "RS1\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001062 break;
1063 case RSX_STATUS_RS2:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001064 seq_puts(m, "RS2 (RC6)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001065 break;
1066 case RSX_STATUS_RS3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001067 seq_puts(m, "RC3 (RC6+)\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001068 break;
1069 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001070 seq_puts(m, "unknown\n");
Jesse Barnes88271da2011-01-05 12:01:24 -08001071 break;
1072 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001073
1074 return 0;
1075}
1076
Ben Widawsky4d855292011-12-12 19:34:16 -08001077static int gen6_drpc_info(struct seq_file *m)
1078{
1079
1080 struct drm_info_node *node = (struct drm_info_node *) m->private;
1081 struct drm_device *dev = node->minor->dev;
1082 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001083 u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001084 unsigned forcewake_count;
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001085 int count = 0, ret;
Ben Widawsky4d855292011-12-12 19:34:16 -08001086
1087 ret = mutex_lock_interruptible(&dev->struct_mutex);
1088 if (ret)
1089 return ret;
1090
Chris Wilson907b28c2013-07-19 20:36:52 +01001091 spin_lock_irq(&dev_priv->uncore.lock);
1092 forcewake_count = dev_priv->uncore.forcewake_count;
1093 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter93b525d2012-01-25 13:52:43 +01001094
1095 if (forcewake_count) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001096 seq_puts(m, "RC information inaccurate because somebody "
1097 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001098 } else {
1099 /* NB: we cannot use forcewake, else we read the wrong values */
1100 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1101 udelay(10);
1102 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1103 }
1104
1105 gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS);
Chris Wilsoned71f1b2013-07-19 20:36:56 +01001106 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
Ben Widawsky4d855292011-12-12 19:34:16 -08001107
1108 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1109 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1110 mutex_unlock(&dev->struct_mutex);
Ben Widawsky44cbd332012-11-06 14:36:36 +00001111 mutex_lock(&dev_priv->rps.hw_lock);
1112 sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
1113 mutex_unlock(&dev_priv->rps.hw_lock);
Ben Widawsky4d855292011-12-12 19:34:16 -08001114
1115 seq_printf(m, "Video Turbo Mode: %s\n",
1116 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1117 seq_printf(m, "HW control enabled: %s\n",
1118 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1119 seq_printf(m, "SW control enabled: %s\n",
1120 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1121 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001122 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001123 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1124 seq_printf(m, "RC6 Enabled: %s\n",
1125 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
1126 seq_printf(m, "Deep RC6 Enabled: %s\n",
1127 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1128 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1129 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
Damien Lespiau267f0c92013-06-24 22:59:48 +01001130 seq_puts(m, "Current RC state: ");
Ben Widawsky4d855292011-12-12 19:34:16 -08001131 switch (gt_core_status & GEN6_RCn_MASK) {
1132 case GEN6_RC0:
1133 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
Damien Lespiau267f0c92013-06-24 22:59:48 +01001134 seq_puts(m, "Core Power Down\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001135 else
Damien Lespiau267f0c92013-06-24 22:59:48 +01001136 seq_puts(m, "on\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001137 break;
1138 case GEN6_RC3:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001139 seq_puts(m, "RC3\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001140 break;
1141 case GEN6_RC6:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001142 seq_puts(m, "RC6\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001143 break;
1144 case GEN6_RC7:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001145 seq_puts(m, "RC7\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001146 break;
1147 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001148 seq_puts(m, "Unknown\n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001149 break;
1150 }
1151
1152 seq_printf(m, "Core Power Down: %s\n",
1153 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
Ben Widawskycce66a22012-03-27 18:59:38 -07001154
1155 /* Not exactly sure what this is */
1156 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1157 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1158 seq_printf(m, "RC6 residency since boot: %u\n",
1159 I915_READ(GEN6_GT_GFX_RC6));
1160 seq_printf(m, "RC6+ residency since boot: %u\n",
1161 I915_READ(GEN6_GT_GFX_RC6p));
1162 seq_printf(m, "RC6++ residency since boot: %u\n",
1163 I915_READ(GEN6_GT_GFX_RC6pp));
1164
Ben Widawskyecd8fae2012-09-26 10:34:02 -07001165 seq_printf(m, "RC6 voltage: %dmV\n",
1166 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
1167 seq_printf(m, "RC6+ voltage: %dmV\n",
1168 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
1169 seq_printf(m, "RC6++ voltage: %dmV\n",
1170 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
Ben Widawsky4d855292011-12-12 19:34:16 -08001171 return 0;
1172}
1173
1174static int i915_drpc_info(struct seq_file *m, void *unused)
1175{
1176 struct drm_info_node *node = (struct drm_info_node *) m->private;
1177 struct drm_device *dev = node->minor->dev;
1178
1179 if (IS_GEN6(dev) || IS_GEN7(dev))
1180 return gen6_drpc_info(m);
1181 else
1182 return ironlake_drpc_info(m);
1183}
1184
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001185static int i915_fbc_status(struct seq_file *m, void *unused)
1186{
1187 struct drm_info_node *node = (struct drm_info_node *) m->private;
1188 struct drm_device *dev = node->minor->dev;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001189 drm_i915_private_t *dev_priv = dev->dev_private;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001190
Adam Jacksonee5382a2010-04-23 11:17:39 -04001191 if (!I915_HAS_FBC(dev)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001192 seq_puts(m, "FBC unsupported on this chipset\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001193 return 0;
1194 }
1195
Adam Jacksonee5382a2010-04-23 11:17:39 -04001196 if (intel_fbc_enabled(dev)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001197 seq_puts(m, "FBC enabled\n");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001198 } else {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001199 seq_puts(m, "FBC disabled: ");
Ben Widawsky5c3fe8b2013-06-27 16:30:21 -07001200 switch (dev_priv->fbc.no_fbc_reason) {
Chris Wilson29ebf902013-07-27 17:23:55 +01001201 case FBC_OK:
1202 seq_puts(m, "FBC actived, but currently disabled in hardware");
1203 break;
1204 case FBC_UNSUPPORTED:
1205 seq_puts(m, "unsupported by this chipset");
1206 break;
Chris Wilsonbed4a672010-09-11 10:47:47 +01001207 case FBC_NO_OUTPUT:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001208 seq_puts(m, "no outputs");
Chris Wilsonbed4a672010-09-11 10:47:47 +01001209 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001210 case FBC_STOLEN_TOO_SMALL:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001211 seq_puts(m, "not enough stolen memory");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001212 break;
1213 case FBC_UNSUPPORTED_MODE:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001214 seq_puts(m, "mode not supported");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001215 break;
1216 case FBC_MODE_TOO_LARGE:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001217 seq_puts(m, "mode too large");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001218 break;
1219 case FBC_BAD_PLANE:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001220 seq_puts(m, "FBC unsupported on plane");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001221 break;
1222 case FBC_NOT_TILED:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001223 seq_puts(m, "scanout buffer not tiled");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001224 break;
Jesse Barnes9c928d12010-07-23 15:20:00 -07001225 case FBC_MULTIPLE_PIPES:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001226 seq_puts(m, "multiple pipes are enabled");
Jesse Barnes9c928d12010-07-23 15:20:00 -07001227 break;
Jesse Barnesc1a9f042011-05-05 15:24:21 -07001228 case FBC_MODULE_PARAM:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001229 seq_puts(m, "disabled per module param (default off)");
Jesse Barnesc1a9f042011-05-05 15:24:21 -07001230 break;
Damien Lespiau8a5729a2013-06-24 16:22:02 +01001231 case FBC_CHIP_DEFAULT:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001232 seq_puts(m, "disabled per chip default");
Damien Lespiau8a5729a2013-06-24 16:22:02 +01001233 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001234 default:
Damien Lespiau267f0c92013-06-24 22:59:48 +01001235 seq_puts(m, "unknown reason");
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001236 }
Damien Lespiau267f0c92013-06-24 22:59:48 +01001237 seq_putc(m, '\n');
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001238 }
1239 return 0;
1240}
1241
Paulo Zanoni92d44622013-05-31 16:33:24 -03001242static int i915_ips_status(struct seq_file *m, void *unused)
1243{
1244 struct drm_info_node *node = (struct drm_info_node *) m->private;
1245 struct drm_device *dev = node->minor->dev;
1246 struct drm_i915_private *dev_priv = dev->dev_private;
1247
Damien Lespiauf5adf942013-06-24 18:29:34 +01001248 if (!HAS_IPS(dev)) {
Paulo Zanoni92d44622013-05-31 16:33:24 -03001249 seq_puts(m, "not supported\n");
1250 return 0;
1251 }
1252
1253 if (I915_READ(IPS_CTL) & IPS_ENABLE)
1254 seq_puts(m, "enabled\n");
1255 else
1256 seq_puts(m, "disabled\n");
1257
1258 return 0;
1259}
1260
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001261static int i915_sr_status(struct seq_file *m, void *unused)
1262{
1263 struct drm_info_node *node = (struct drm_info_node *) m->private;
1264 struct drm_device *dev = node->minor->dev;
1265 drm_i915_private_t *dev_priv = dev->dev_private;
1266 bool sr_enabled = false;
1267
Yuanhan Liu13982612010-12-15 15:42:31 +08001268 if (HAS_PCH_SPLIT(dev))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001269 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Chris Wilsona6c45cf2010-09-17 00:32:17 +01001270 else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001271 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
1272 else if (IS_I915GM(dev))
1273 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
1274 else if (IS_PINEVIEW(dev))
1275 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
1276
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001277 seq_printf(m, "self-refresh: %s\n",
1278 sr_enabled ? "enabled" : "disabled");
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001279
1280 return 0;
1281}
1282
Jesse Barnes7648fa92010-05-20 14:28:11 -07001283static int i915_emon_status(struct seq_file *m, void *unused)
1284{
1285 struct drm_info_node *node = (struct drm_info_node *) m->private;
1286 struct drm_device *dev = node->minor->dev;
1287 drm_i915_private_t *dev_priv = dev->dev_private;
1288 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001289 int ret;
1290
Chris Wilson582be6b2012-04-30 19:35:02 +01001291 if (!IS_GEN5(dev))
1292 return -ENODEV;
1293
Chris Wilsonde227ef2010-07-03 07:58:38 +01001294 ret = mutex_lock_interruptible(&dev->struct_mutex);
1295 if (ret)
1296 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001297
1298 temp = i915_mch_val(dev_priv);
1299 chipset = i915_chipset_val(dev_priv);
1300 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001301 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001302
1303 seq_printf(m, "GMCH temp: %ld\n", temp);
1304 seq_printf(m, "Chipset power: %ld\n", chipset);
1305 seq_printf(m, "GFX power: %ld\n", gfx);
1306 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1307
1308 return 0;
1309}
1310
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001311static int i915_ring_freq_table(struct seq_file *m, void *unused)
1312{
1313 struct drm_info_node *node = (struct drm_info_node *) m->private;
1314 struct drm_device *dev = node->minor->dev;
1315 drm_i915_private_t *dev_priv = dev->dev_private;
1316 int ret;
1317 int gpu_freq, ia_freq;
1318
Jesse Barnes1c70c0c2011-06-29 13:34:36 -07001319 if (!(IS_GEN6(dev) || IS_GEN7(dev))) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001320 seq_puts(m, "unsupported on this chipset\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001321 return 0;
1322 }
1323
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001324 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001325 if (ret)
1326 return ret;
1327
Damien Lespiau267f0c92013-06-24 22:59:48 +01001328 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001329
Daniel Vetterc6a828d2012-08-08 23:35:35 +02001330 for (gpu_freq = dev_priv->rps.min_delay;
1331 gpu_freq <= dev_priv->rps.max_delay;
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001332 gpu_freq++) {
Ben Widawsky42c05262012-09-26 10:34:00 -07001333 ia_freq = gpu_freq;
1334 sandybridge_pcode_read(dev_priv,
1335 GEN6_PCODE_READ_MIN_FREQ_TABLE,
1336 &ia_freq);
Chris Wilson3ebecd02013-04-12 19:10:13 +01001337 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
1338 gpu_freq * GT_FREQUENCY_MULTIPLIER,
1339 ((ia_freq >> 0) & 0xff) * 100,
1340 ((ia_freq >> 8) & 0xff) * 100);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001341 }
1342
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001343 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001344
1345 return 0;
1346}
1347
Jesse Barnes7648fa92010-05-20 14:28:11 -07001348static int i915_gfxec(struct seq_file *m, void *unused)
1349{
1350 struct drm_info_node *node = (struct drm_info_node *) m->private;
1351 struct drm_device *dev = node->minor->dev;
1352 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001353 int ret;
1354
1355 ret = mutex_lock_interruptible(&dev->struct_mutex);
1356 if (ret)
1357 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001358
1359 seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1360
Ben Widawsky616fdb52011-10-05 11:44:54 -07001361 mutex_unlock(&dev->struct_mutex);
1362
Jesse Barnes7648fa92010-05-20 14:28:11 -07001363 return 0;
1364}
1365
Chris Wilson44834a62010-08-19 16:09:23 +01001366static int i915_opregion(struct seq_file *m, void *unused)
1367{
1368 struct drm_info_node *node = (struct drm_info_node *) m->private;
1369 struct drm_device *dev = node->minor->dev;
1370 drm_i915_private_t *dev_priv = dev->dev_private;
1371 struct intel_opregion *opregion = &dev_priv->opregion;
Daniel Vetter0d38f002012-04-21 22:49:10 +02001372 void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL);
Chris Wilson44834a62010-08-19 16:09:23 +01001373 int ret;
1374
Daniel Vetter0d38f002012-04-21 22:49:10 +02001375 if (data == NULL)
1376 return -ENOMEM;
1377
Chris Wilson44834a62010-08-19 16:09:23 +01001378 ret = mutex_lock_interruptible(&dev->struct_mutex);
1379 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001380 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001381
Daniel Vetter0d38f002012-04-21 22:49:10 +02001382 if (opregion->header) {
1383 memcpy_fromio(data, opregion->header, OPREGION_SIZE);
1384 seq_write(m, data, OPREGION_SIZE);
1385 }
Chris Wilson44834a62010-08-19 16:09:23 +01001386
1387 mutex_unlock(&dev->struct_mutex);
1388
Daniel Vetter0d38f002012-04-21 22:49:10 +02001389out:
1390 kfree(data);
Chris Wilson44834a62010-08-19 16:09:23 +01001391 return 0;
1392}
1393
Chris Wilson37811fc2010-08-25 22:45:57 +01001394static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1395{
1396 struct drm_info_node *node = (struct drm_info_node *) m->private;
1397 struct drm_device *dev = node->minor->dev;
1398 drm_i915_private_t *dev_priv = dev->dev_private;
1399 struct intel_fbdev *ifbdev;
1400 struct intel_framebuffer *fb;
1401 int ret;
1402
1403 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
1404 if (ret)
1405 return ret;
1406
1407 ifbdev = dev_priv->fbdev;
1408 fb = to_intel_framebuffer(ifbdev->helper.fb);
1409
Daniel Vetter623f9782012-12-11 16:21:38 +01001410 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
Chris Wilson37811fc2010-08-25 22:45:57 +01001411 fb->base.width,
1412 fb->base.height,
1413 fb->base.depth,
Daniel Vetter623f9782012-12-11 16:21:38 +01001414 fb->base.bits_per_pixel,
1415 atomic_read(&fb->base.refcount.refcount));
Chris Wilson05394f32010-11-08 19:18:58 +00001416 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001417 seq_putc(m, '\n');
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001418 mutex_unlock(&dev->mode_config.mutex);
Chris Wilson37811fc2010-08-25 22:45:57 +01001419
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001420 mutex_lock(&dev->mode_config.fb_lock);
Chris Wilson37811fc2010-08-25 22:45:57 +01001421 list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
1422 if (&fb->base == ifbdev->helper.fb)
1423 continue;
1424
Daniel Vetter623f9782012-12-11 16:21:38 +01001425 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
Chris Wilson37811fc2010-08-25 22:45:57 +01001426 fb->base.width,
1427 fb->base.height,
1428 fb->base.depth,
Daniel Vetter623f9782012-12-11 16:21:38 +01001429 fb->base.bits_per_pixel,
1430 atomic_read(&fb->base.refcount.refcount));
Chris Wilson05394f32010-11-08 19:18:58 +00001431 describe_obj(m, fb->obj);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001432 seq_putc(m, '\n');
Chris Wilson37811fc2010-08-25 22:45:57 +01001433 }
Daniel Vetter4b096ac2012-12-10 21:19:18 +01001434 mutex_unlock(&dev->mode_config.fb_lock);
Chris Wilson37811fc2010-08-25 22:45:57 +01001435
1436 return 0;
1437}
1438
Ben Widawskye76d3632011-03-19 18:14:29 -07001439static int i915_context_status(struct seq_file *m, void *unused)
1440{
1441 struct drm_info_node *node = (struct drm_info_node *) m->private;
1442 struct drm_device *dev = node->minor->dev;
1443 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawskya168c292013-02-14 15:05:12 -08001444 struct intel_ring_buffer *ring;
Ben Widawskya33afea2013-09-17 21:12:45 -07001445 struct i915_hw_context *ctx;
Ben Widawskya168c292013-02-14 15:05:12 -08001446 int ret, i;
Ben Widawskye76d3632011-03-19 18:14:29 -07001447
1448 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
1449 if (ret)
1450 return ret;
1451
Daniel Vetter3e373942012-11-02 19:55:04 +01001452 if (dev_priv->ips.pwrctx) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001453 seq_puts(m, "power context ");
Daniel Vetter3e373942012-11-02 19:55:04 +01001454 describe_obj(m, dev_priv->ips.pwrctx);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001455 seq_putc(m, '\n');
Ben Widawskydc501fb2011-06-29 11:41:51 -07001456 }
Ben Widawskye76d3632011-03-19 18:14:29 -07001457
Daniel Vetter3e373942012-11-02 19:55:04 +01001458 if (dev_priv->ips.renderctx) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001459 seq_puts(m, "render context ");
Daniel Vetter3e373942012-11-02 19:55:04 +01001460 describe_obj(m, dev_priv->ips.renderctx);
Damien Lespiau267f0c92013-06-24 22:59:48 +01001461 seq_putc(m, '\n');
Ben Widawskydc501fb2011-06-29 11:41:51 -07001462 }
Ben Widawskye76d3632011-03-19 18:14:29 -07001463
Ben Widawskya33afea2013-09-17 21:12:45 -07001464 list_for_each_entry(ctx, &dev_priv->context_list, link) {
1465 seq_puts(m, "HW context ");
1466 for_each_ring(ring, dev_priv, i)
1467 if (ring->default_context == ctx)
1468 seq_printf(m, "(default context %s) ", ring->name);
1469
1470 describe_obj(m, ctx->obj);
1471 seq_putc(m, '\n');
Ben Widawskya168c292013-02-14 15:05:12 -08001472 }
1473
Ben Widawskye76d3632011-03-19 18:14:29 -07001474 mutex_unlock(&dev->mode_config.mutex);
1475
1476 return 0;
1477}
1478
Ben Widawsky6d794d42011-04-25 11:25:56 -07001479static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
1480{
1481 struct drm_info_node *node = (struct drm_info_node *) m->private;
1482 struct drm_device *dev = node->minor->dev;
1483 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter9f1f46a2011-12-14 13:57:03 +01001484 unsigned forcewake_count;
Ben Widawsky6d794d42011-04-25 11:25:56 -07001485
Chris Wilson907b28c2013-07-19 20:36:52 +01001486 spin_lock_irq(&dev_priv->uncore.lock);
1487 forcewake_count = dev_priv->uncore.forcewake_count;
1488 spin_unlock_irq(&dev_priv->uncore.lock);
Daniel Vetter9f1f46a2011-12-14 13:57:03 +01001489
1490 seq_printf(m, "forcewake count = %u\n", forcewake_count);
Ben Widawsky6d794d42011-04-25 11:25:56 -07001491
1492 return 0;
1493}
1494
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001495static const char *swizzle_string(unsigned swizzle)
1496{
Damien Lespiauaee56cf2013-06-24 22:59:49 +01001497 switch (swizzle) {
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001498 case I915_BIT_6_SWIZZLE_NONE:
1499 return "none";
1500 case I915_BIT_6_SWIZZLE_9:
1501 return "bit9";
1502 case I915_BIT_6_SWIZZLE_9_10:
1503 return "bit9/bit10";
1504 case I915_BIT_6_SWIZZLE_9_11:
1505 return "bit9/bit11";
1506 case I915_BIT_6_SWIZZLE_9_10_11:
1507 return "bit9/bit10/bit11";
1508 case I915_BIT_6_SWIZZLE_9_17:
1509 return "bit9/bit17";
1510 case I915_BIT_6_SWIZZLE_9_10_17:
1511 return "bit9/bit10/bit17";
1512 case I915_BIT_6_SWIZZLE_UNKNOWN:
Masanari Iida8a168ca2012-12-29 02:00:09 +09001513 return "unknown";
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001514 }
1515
1516 return "bug";
1517}
1518
1519static int i915_swizzle_info(struct seq_file *m, void *data)
1520{
1521 struct drm_info_node *node = (struct drm_info_node *) m->private;
1522 struct drm_device *dev = node->minor->dev;
1523 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter22bcfc62012-08-09 15:07:02 +02001524 int ret;
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001525
Daniel Vetter22bcfc62012-08-09 15:07:02 +02001526 ret = mutex_lock_interruptible(&dev->struct_mutex);
1527 if (ret)
1528 return ret;
1529
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001530 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
1531 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
1532 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
1533 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
1534
1535 if (IS_GEN3(dev) || IS_GEN4(dev)) {
1536 seq_printf(m, "DDC = 0x%08x\n",
1537 I915_READ(DCC));
1538 seq_printf(m, "C0DRB3 = 0x%04x\n",
1539 I915_READ16(C0DRB3));
1540 seq_printf(m, "C1DRB3 = 0x%04x\n",
1541 I915_READ16(C1DRB3));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01001542 } else if (IS_GEN6(dev) || IS_GEN7(dev)) {
1543 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
1544 I915_READ(MAD_DIMM_C0));
1545 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
1546 I915_READ(MAD_DIMM_C1));
1547 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
1548 I915_READ(MAD_DIMM_C2));
1549 seq_printf(m, "TILECTL = 0x%08x\n",
1550 I915_READ(TILECTL));
1551 seq_printf(m, "ARB_MODE = 0x%08x\n",
1552 I915_READ(ARB_MODE));
1553 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
1554 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001555 }
1556 mutex_unlock(&dev->struct_mutex);
1557
1558 return 0;
1559}
1560
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001561static int i915_ppgtt_info(struct seq_file *m, void *data)
1562{
1563 struct drm_info_node *node = (struct drm_info_node *) m->private;
1564 struct drm_device *dev = node->minor->dev;
1565 struct drm_i915_private *dev_priv = dev->dev_private;
1566 struct intel_ring_buffer *ring;
1567 int i, ret;
1568
1569
1570 ret = mutex_lock_interruptible(&dev->struct_mutex);
1571 if (ret)
1572 return ret;
1573 if (INTEL_INFO(dev)->gen == 6)
1574 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
1575
Chris Wilsona2c7f6f2012-09-01 20:51:22 +01001576 for_each_ring(ring, dev_priv, i) {
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001577 seq_printf(m, "%s\n", ring->name);
1578 if (INTEL_INFO(dev)->gen == 7)
1579 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring)));
1580 seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring)));
1581 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring)));
1582 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring)));
1583 }
1584 if (dev_priv->mm.aliasing_ppgtt) {
1585 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
1586
Damien Lespiau267f0c92013-06-24 22:59:48 +01001587 seq_puts(m, "aliasing PPGTT:\n");
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001588 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset);
1589 }
1590 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
1591 mutex_unlock(&dev->struct_mutex);
1592
1593 return 0;
1594}
1595
Jesse Barnes57f350b2012-03-28 13:39:25 -07001596static int i915_dpio_info(struct seq_file *m, void *data)
1597{
1598 struct drm_info_node *node = (struct drm_info_node *) m->private;
1599 struct drm_device *dev = node->minor->dev;
1600 struct drm_i915_private *dev_priv = dev->dev_private;
1601 int ret;
1602
1603
1604 if (!IS_VALLEYVIEW(dev)) {
Damien Lespiau267f0c92013-06-24 22:59:48 +01001605 seq_puts(m, "unsupported\n");
Jesse Barnes57f350b2012-03-28 13:39:25 -07001606 return 0;
1607 }
1608
Daniel Vetter09153002012-12-12 14:06:44 +01001609 ret = mutex_lock_interruptible(&dev_priv->dpio_lock);
Jesse Barnes57f350b2012-03-28 13:39:25 -07001610 if (ret)
1611 return ret;
1612
1613 seq_printf(m, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL));
1614
1615 seq_printf(m, "DPIO_DIV_A: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001616 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_DIV_A));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001617 seq_printf(m, "DPIO_DIV_B: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001618 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_DIV_B));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001619
1620 seq_printf(m, "DPIO_REFSFR_A: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001621 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_REFSFR_A));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001622 seq_printf(m, "DPIO_REFSFR_B: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001623 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_REFSFR_B));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001624
1625 seq_printf(m, "DPIO_CORE_CLK_A: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001626 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_CORE_CLK_A));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001627 seq_printf(m, "DPIO_CORE_CLK_B: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001628 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_CORE_CLK_B));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001629
Ville Syrjälä4abb2c32013-06-14 14:02:53 +03001630 seq_printf(m, "DPIO_LPF_COEFF_A: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001631 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_LPF_COEFF_A));
Ville Syrjälä4abb2c32013-06-14 14:02:53 +03001632 seq_printf(m, "DPIO_LPF_COEFF_B: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001633 vlv_dpio_read(dev_priv, PIPE_A, _DPIO_LPF_COEFF_B));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001634
1635 seq_printf(m, "DPIO_FASTCLK_DISABLE: 0x%08x\n",
Chon Ming Lee5e69f972013-09-05 20:41:49 +08001636 vlv_dpio_read(dev_priv, PIPE_A, DPIO_FASTCLK_DISABLE));
Jesse Barnes57f350b2012-03-28 13:39:25 -07001637
Daniel Vetter09153002012-12-12 14:06:44 +01001638 mutex_unlock(&dev_priv->dpio_lock);
Jesse Barnes57f350b2012-03-28 13:39:25 -07001639
1640 return 0;
1641}
1642
Ben Widawsky63573eb2013-07-04 11:02:07 -07001643static int i915_llc(struct seq_file *m, void *data)
1644{
1645 struct drm_info_node *node = (struct drm_info_node *) m->private;
1646 struct drm_device *dev = node->minor->dev;
1647 struct drm_i915_private *dev_priv = dev->dev_private;
1648
1649 /* Size calculation for LLC is a bit of a pain. Ignore for now. */
1650 seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev)));
1651 seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size);
1652
1653 return 0;
1654}
1655
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001656static int i915_edp_psr_status(struct seq_file *m, void *data)
1657{
1658 struct drm_info_node *node = m->private;
1659 struct drm_device *dev = node->minor->dev;
1660 struct drm_i915_private *dev_priv = dev->dev_private;
Rodrigo Vivi3f51e472013-07-11 18:45:00 -03001661 u32 psrstat, psrperf;
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001662
1663 if (!IS_HASWELL(dev)) {
1664 seq_puts(m, "PSR not supported on this platform\n");
Rodrigo Vivi3f51e472013-07-11 18:45:00 -03001665 } else if (IS_HASWELL(dev) && I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE) {
1666 seq_puts(m, "PSR enabled\n");
1667 } else {
1668 seq_puts(m, "PSR disabled: ");
1669 switch (dev_priv->no_psr_reason) {
1670 case PSR_NO_SOURCE:
1671 seq_puts(m, "not supported on this platform");
1672 break;
1673 case PSR_NO_SINK:
1674 seq_puts(m, "not supported by panel");
1675 break;
Rodrigo Vivi105b7c12013-07-11 18:45:02 -03001676 case PSR_MODULE_PARAM:
1677 seq_puts(m, "disabled by flag");
1678 break;
Rodrigo Vivi3f51e472013-07-11 18:45:00 -03001679 case PSR_CRTC_NOT_ACTIVE:
1680 seq_puts(m, "crtc not active");
1681 break;
1682 case PSR_PWR_WELL_ENABLED:
1683 seq_puts(m, "power well enabled");
1684 break;
1685 case PSR_NOT_TILED:
1686 seq_puts(m, "not tiled");
1687 break;
1688 case PSR_SPRITE_ENABLED:
1689 seq_puts(m, "sprite enabled");
1690 break;
1691 case PSR_S3D_ENABLED:
1692 seq_puts(m, "stereo 3d enabled");
1693 break;
1694 case PSR_INTERLACED_ENABLED:
1695 seq_puts(m, "interlaced enabled");
1696 break;
1697 case PSR_HSW_NOT_DDIA:
1698 seq_puts(m, "HSW ties PSR to DDI A (eDP)");
1699 break;
1700 default:
1701 seq_puts(m, "unknown reason");
1702 }
1703 seq_puts(m, "\n");
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001704 return 0;
1705 }
1706
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03001707 psrstat = I915_READ(EDP_PSR_STATUS_CTL);
1708
1709 seq_puts(m, "PSR Current State: ");
1710 switch (psrstat & EDP_PSR_STATUS_STATE_MASK) {
1711 case EDP_PSR_STATUS_STATE_IDLE:
1712 seq_puts(m, "Reset state\n");
1713 break;
1714 case EDP_PSR_STATUS_STATE_SRDONACK:
1715 seq_puts(m, "Wait for TG/Stream to send on frame of data after SRD conditions are met\n");
1716 break;
1717 case EDP_PSR_STATUS_STATE_SRDENT:
1718 seq_puts(m, "SRD entry\n");
1719 break;
1720 case EDP_PSR_STATUS_STATE_BUFOFF:
1721 seq_puts(m, "Wait for buffer turn off\n");
1722 break;
1723 case EDP_PSR_STATUS_STATE_BUFON:
1724 seq_puts(m, "Wait for buffer turn on\n");
1725 break;
1726 case EDP_PSR_STATUS_STATE_AUXACK:
1727 seq_puts(m, "Wait for AUX to acknowledge on SRD exit\n");
1728 break;
1729 case EDP_PSR_STATUS_STATE_SRDOFFACK:
1730 seq_puts(m, "Wait for TG/Stream to acknowledge the SRD VDM exit\n");
1731 break;
1732 default:
1733 seq_puts(m, "Unknown\n");
1734 break;
1735 }
1736
1737 seq_puts(m, "Link Status: ");
1738 switch (psrstat & EDP_PSR_STATUS_LINK_MASK) {
1739 case EDP_PSR_STATUS_LINK_FULL_OFF:
1740 seq_puts(m, "Link is fully off\n");
1741 break;
1742 case EDP_PSR_STATUS_LINK_FULL_ON:
1743 seq_puts(m, "Link is fully on\n");
1744 break;
1745 case EDP_PSR_STATUS_LINK_STANDBY:
1746 seq_puts(m, "Link is in standby\n");
1747 break;
1748 default:
1749 seq_puts(m, "Unknown\n");
1750 break;
1751 }
1752
1753 seq_printf(m, "PSR Entry Count: %u\n",
1754 psrstat >> EDP_PSR_STATUS_COUNT_SHIFT &
1755 EDP_PSR_STATUS_COUNT_MASK);
1756
1757 seq_printf(m, "Max Sleep Timer Counter: %u\n",
1758 psrstat >> EDP_PSR_STATUS_MAX_SLEEP_TIMER_SHIFT &
1759 EDP_PSR_STATUS_MAX_SLEEP_TIMER_MASK);
1760
1761 seq_printf(m, "Had AUX error: %s\n",
1762 yesno(psrstat & EDP_PSR_STATUS_AUX_ERROR));
1763
1764 seq_printf(m, "Sending AUX: %s\n",
1765 yesno(psrstat & EDP_PSR_STATUS_AUX_SENDING));
1766
1767 seq_printf(m, "Sending Idle: %s\n",
1768 yesno(psrstat & EDP_PSR_STATUS_SENDING_IDLE));
1769
1770 seq_printf(m, "Sending TP2 TP3: %s\n",
1771 yesno(psrstat & EDP_PSR_STATUS_SENDING_TP2_TP3));
1772
1773 seq_printf(m, "Sending TP1: %s\n",
1774 yesno(psrstat & EDP_PSR_STATUS_SENDING_TP1));
1775
1776 seq_printf(m, "Idle Count: %u\n",
1777 psrstat & EDP_PSR_STATUS_IDLE_MASK);
1778
1779 psrperf = (I915_READ(EDP_PSR_PERF_CNT)) & EDP_PSR_PERF_CNT_MASK;
1780 seq_printf(m, "Performance Counter: %u\n", psrperf);
1781
1782 return 0;
1783}
1784
Jesse Barnesec013e72013-08-20 10:29:23 +01001785static int i915_energy_uJ(struct seq_file *m, void *data)
1786{
1787 struct drm_info_node *node = m->private;
1788 struct drm_device *dev = node->minor->dev;
1789 struct drm_i915_private *dev_priv = dev->dev_private;
1790 u64 power;
1791 u32 units;
1792
1793 if (INTEL_INFO(dev)->gen < 6)
1794 return -ENODEV;
1795
1796 rdmsrl(MSR_RAPL_POWER_UNIT, power);
1797 power = (power & 0x1f00) >> 8;
1798 units = 1000000 / (1 << power); /* convert to uJ */
1799 power = I915_READ(MCH_SECP_NRG_STTS);
1800 power *= units;
1801
1802 seq_printf(m, "%llu", (long long unsigned)power);
Paulo Zanoni371db662013-08-19 13:18:10 -03001803
1804 return 0;
1805}
1806
1807static int i915_pc8_status(struct seq_file *m, void *unused)
1808{
1809 struct drm_info_node *node = (struct drm_info_node *) m->private;
1810 struct drm_device *dev = node->minor->dev;
1811 struct drm_i915_private *dev_priv = dev->dev_private;
1812
1813 if (!IS_HASWELL(dev)) {
1814 seq_puts(m, "not supported\n");
1815 return 0;
1816 }
1817
1818 mutex_lock(&dev_priv->pc8.lock);
1819 seq_printf(m, "Requirements met: %s\n",
1820 yesno(dev_priv->pc8.requirements_met));
1821 seq_printf(m, "GPU idle: %s\n", yesno(dev_priv->pc8.gpu_idle));
1822 seq_printf(m, "Disable count: %d\n", dev_priv->pc8.disable_count);
1823 seq_printf(m, "IRQs disabled: %s\n",
1824 yesno(dev_priv->pc8.irqs_disabled));
1825 seq_printf(m, "Enabled: %s\n", yesno(dev_priv->pc8.enabled));
1826 mutex_unlock(&dev_priv->pc8.lock);
1827
Jesse Barnesec013e72013-08-20 10:29:23 +01001828 return 0;
1829}
1830
Kees Cook647416f2013-03-10 14:10:06 -07001831static int
1832i915_wedged_get(void *data, u64 *val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001833{
Kees Cook647416f2013-03-10 14:10:06 -07001834 struct drm_device *dev = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001835 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001836
Kees Cook647416f2013-03-10 14:10:06 -07001837 *val = atomic_read(&dev_priv->gpu_error.reset_counter);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001838
Kees Cook647416f2013-03-10 14:10:06 -07001839 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001840}
1841
Kees Cook647416f2013-03-10 14:10:06 -07001842static int
1843i915_wedged_set(void *data, u64 val)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001844{
Kees Cook647416f2013-03-10 14:10:06 -07001845 struct drm_device *dev = data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001846
Kees Cook647416f2013-03-10 14:10:06 -07001847 DRM_INFO("Manually setting wedged to %llu\n", val);
Chris Wilson527f9e92010-11-11 01:16:58 +00001848 i915_handle_error(dev, val);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001849
Kees Cook647416f2013-03-10 14:10:06 -07001850 return 0;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001851}
1852
Kees Cook647416f2013-03-10 14:10:06 -07001853DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
1854 i915_wedged_get, i915_wedged_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03001855 "%llu\n");
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001856
Kees Cook647416f2013-03-10 14:10:06 -07001857static int
1858i915_ring_stop_get(void *data, u64 *val)
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001859{
Kees Cook647416f2013-03-10 14:10:06 -07001860 struct drm_device *dev = data;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001861 drm_i915_private_t *dev_priv = dev->dev_private;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001862
Kees Cook647416f2013-03-10 14:10:06 -07001863 *val = dev_priv->gpu_error.stop_rings;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001864
Kees Cook647416f2013-03-10 14:10:06 -07001865 return 0;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001866}
1867
Kees Cook647416f2013-03-10 14:10:06 -07001868static int
1869i915_ring_stop_set(void *data, u64 val)
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001870{
Kees Cook647416f2013-03-10 14:10:06 -07001871 struct drm_device *dev = data;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001872 struct drm_i915_private *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07001873 int ret;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001874
Kees Cook647416f2013-03-10 14:10:06 -07001875 DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val);
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001876
Daniel Vetter22bcfc62012-08-09 15:07:02 +02001877 ret = mutex_lock_interruptible(&dev->struct_mutex);
1878 if (ret)
1879 return ret;
1880
Daniel Vetter99584db2012-11-14 17:14:04 +01001881 dev_priv->gpu_error.stop_rings = val;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001882 mutex_unlock(&dev->struct_mutex);
1883
Kees Cook647416f2013-03-10 14:10:06 -07001884 return 0;
Daniel Vettere5eb3d62012-05-03 14:48:16 +02001885}
1886
Kees Cook647416f2013-03-10 14:10:06 -07001887DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops,
1888 i915_ring_stop_get, i915_ring_stop_set,
1889 "0x%08llx\n");
Daniel Vetterd5442302012-04-27 15:17:40 +02001890
Chris Wilsondd624af2013-01-15 12:39:35 +00001891#define DROP_UNBOUND 0x1
1892#define DROP_BOUND 0x2
1893#define DROP_RETIRE 0x4
1894#define DROP_ACTIVE 0x8
1895#define DROP_ALL (DROP_UNBOUND | \
1896 DROP_BOUND | \
1897 DROP_RETIRE | \
1898 DROP_ACTIVE)
Kees Cook647416f2013-03-10 14:10:06 -07001899static int
1900i915_drop_caches_get(void *data, u64 *val)
Chris Wilsondd624af2013-01-15 12:39:35 +00001901{
Kees Cook647416f2013-03-10 14:10:06 -07001902 *val = DROP_ALL;
Chris Wilsondd624af2013-01-15 12:39:35 +00001903
Kees Cook647416f2013-03-10 14:10:06 -07001904 return 0;
Chris Wilsondd624af2013-01-15 12:39:35 +00001905}
1906
Kees Cook647416f2013-03-10 14:10:06 -07001907static int
1908i915_drop_caches_set(void *data, u64 val)
Chris Wilsondd624af2013-01-15 12:39:35 +00001909{
Kees Cook647416f2013-03-10 14:10:06 -07001910 struct drm_device *dev = data;
Chris Wilsondd624af2013-01-15 12:39:35 +00001911 struct drm_i915_private *dev_priv = dev->dev_private;
1912 struct drm_i915_gem_object *obj, *next;
Ben Widawskyca191b12013-07-31 17:00:14 -07001913 struct i915_address_space *vm;
1914 struct i915_vma *vma, *x;
Kees Cook647416f2013-03-10 14:10:06 -07001915 int ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00001916
Kees Cook647416f2013-03-10 14:10:06 -07001917 DRM_DEBUG_DRIVER("Dropping caches: 0x%08llx\n", val);
Chris Wilsondd624af2013-01-15 12:39:35 +00001918
1919 /* No need to check and wait for gpu resets, only libdrm auto-restarts
1920 * on ioctls on -EAGAIN. */
1921 ret = mutex_lock_interruptible(&dev->struct_mutex);
1922 if (ret)
1923 return ret;
1924
1925 if (val & DROP_ACTIVE) {
1926 ret = i915_gpu_idle(dev);
1927 if (ret)
1928 goto unlock;
1929 }
1930
1931 if (val & (DROP_RETIRE | DROP_ACTIVE))
1932 i915_gem_retire_requests(dev);
1933
1934 if (val & DROP_BOUND) {
Ben Widawskyca191b12013-07-31 17:00:14 -07001935 list_for_each_entry(vm, &dev_priv->vm_list, global_link) {
1936 list_for_each_entry_safe(vma, x, &vm->inactive_list,
1937 mm_list) {
1938 if (vma->obj->pin_count)
1939 continue;
Ben Widawsky31a46c92013-07-31 16:59:55 -07001940
Ben Widawskyca191b12013-07-31 17:00:14 -07001941 ret = i915_vma_unbind(vma);
1942 if (ret)
1943 goto unlock;
1944 }
Ben Widawsky31a46c92013-07-31 16:59:55 -07001945 }
Chris Wilsondd624af2013-01-15 12:39:35 +00001946 }
1947
1948 if (val & DROP_UNBOUND) {
Ben Widawsky35c20a62013-05-31 11:28:48 -07001949 list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list,
1950 global_list)
Chris Wilsondd624af2013-01-15 12:39:35 +00001951 if (obj->pages_pin_count == 0) {
1952 ret = i915_gem_object_put_pages(obj);
1953 if (ret)
1954 goto unlock;
1955 }
1956 }
1957
1958unlock:
1959 mutex_unlock(&dev->struct_mutex);
1960
Kees Cook647416f2013-03-10 14:10:06 -07001961 return ret;
Chris Wilsondd624af2013-01-15 12:39:35 +00001962}
1963
Kees Cook647416f2013-03-10 14:10:06 -07001964DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
1965 i915_drop_caches_get, i915_drop_caches_set,
1966 "0x%08llx\n");
Chris Wilsondd624af2013-01-15 12:39:35 +00001967
Kees Cook647416f2013-03-10 14:10:06 -07001968static int
1969i915_max_freq_get(void *data, u64 *val)
Jesse Barnes358733e2011-07-27 11:53:01 -07001970{
Kees Cook647416f2013-03-10 14:10:06 -07001971 struct drm_device *dev = data;
Jesse Barnes358733e2011-07-27 11:53:01 -07001972 drm_i915_private_t *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07001973 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02001974
1975 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
1976 return -ENODEV;
1977
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001978 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02001979 if (ret)
1980 return ret;
Jesse Barnes358733e2011-07-27 11:53:01 -07001981
Jesse Barnes0a073b82013-04-17 15:54:58 -07001982 if (IS_VALLEYVIEW(dev))
1983 *val = vlv_gpu_freq(dev_priv->mem_freq,
1984 dev_priv->rps.max_delay);
1985 else
1986 *val = dev_priv->rps.max_delay * GT_FREQUENCY_MULTIPLIER;
Jesse Barnes4fc688c2012-11-02 11:14:01 -07001987 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07001988
Kees Cook647416f2013-03-10 14:10:06 -07001989 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07001990}
1991
Kees Cook647416f2013-03-10 14:10:06 -07001992static int
1993i915_max_freq_set(void *data, u64 val)
Jesse Barnes358733e2011-07-27 11:53:01 -07001994{
Kees Cook647416f2013-03-10 14:10:06 -07001995 struct drm_device *dev = data;
Jesse Barnes358733e2011-07-27 11:53:01 -07001996 struct drm_i915_private *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07001997 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02001998
1999 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
2000 return -ENODEV;
Jesse Barnes358733e2011-07-27 11:53:01 -07002001
Kees Cook647416f2013-03-10 14:10:06 -07002002 DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
Jesse Barnes358733e2011-07-27 11:53:01 -07002003
Jesse Barnes4fc688c2012-11-02 11:14:01 -07002004 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02002005 if (ret)
2006 return ret;
2007
Jesse Barnes358733e2011-07-27 11:53:01 -07002008 /*
2009 * Turbo will still be enabled, but won't go above the set value.
2010 */
Jesse Barnes0a073b82013-04-17 15:54:58 -07002011 if (IS_VALLEYVIEW(dev)) {
2012 val = vlv_freq_opcode(dev_priv->mem_freq, val);
2013 dev_priv->rps.max_delay = val;
2014 gen6_set_rps(dev, val);
2015 } else {
2016 do_div(val, GT_FREQUENCY_MULTIPLIER);
2017 dev_priv->rps.max_delay = val;
2018 gen6_set_rps(dev, val);
2019 }
2020
Jesse Barnes4fc688c2012-11-02 11:14:01 -07002021 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes358733e2011-07-27 11:53:01 -07002022
Kees Cook647416f2013-03-10 14:10:06 -07002023 return 0;
Jesse Barnes358733e2011-07-27 11:53:01 -07002024}
2025
Kees Cook647416f2013-03-10 14:10:06 -07002026DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
2027 i915_max_freq_get, i915_max_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03002028 "%llu\n");
Jesse Barnes358733e2011-07-27 11:53:01 -07002029
Kees Cook647416f2013-03-10 14:10:06 -07002030static int
2031i915_min_freq_get(void *data, u64 *val)
Jesse Barnes1523c312012-05-25 12:34:54 -07002032{
Kees Cook647416f2013-03-10 14:10:06 -07002033 struct drm_device *dev = data;
Jesse Barnes1523c312012-05-25 12:34:54 -07002034 drm_i915_private_t *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07002035 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02002036
2037 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
2038 return -ENODEV;
2039
Jesse Barnes4fc688c2012-11-02 11:14:01 -07002040 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02002041 if (ret)
2042 return ret;
Jesse Barnes1523c312012-05-25 12:34:54 -07002043
Jesse Barnes0a073b82013-04-17 15:54:58 -07002044 if (IS_VALLEYVIEW(dev))
2045 *val = vlv_gpu_freq(dev_priv->mem_freq,
2046 dev_priv->rps.min_delay);
2047 else
2048 *val = dev_priv->rps.min_delay * GT_FREQUENCY_MULTIPLIER;
Jesse Barnes4fc688c2012-11-02 11:14:01 -07002049 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07002050
Kees Cook647416f2013-03-10 14:10:06 -07002051 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07002052}
2053
Kees Cook647416f2013-03-10 14:10:06 -07002054static int
2055i915_min_freq_set(void *data, u64 val)
Jesse Barnes1523c312012-05-25 12:34:54 -07002056{
Kees Cook647416f2013-03-10 14:10:06 -07002057 struct drm_device *dev = data;
Jesse Barnes1523c312012-05-25 12:34:54 -07002058 struct drm_i915_private *dev_priv = dev->dev_private;
Kees Cook647416f2013-03-10 14:10:06 -07002059 int ret;
Daniel Vetter004777c2012-08-09 15:07:01 +02002060
2061 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
2062 return -ENODEV;
Jesse Barnes1523c312012-05-25 12:34:54 -07002063
Kees Cook647416f2013-03-10 14:10:06 -07002064 DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
Jesse Barnes1523c312012-05-25 12:34:54 -07002065
Jesse Barnes4fc688c2012-11-02 11:14:01 -07002066 ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
Daniel Vetter004777c2012-08-09 15:07:01 +02002067 if (ret)
2068 return ret;
2069
Jesse Barnes1523c312012-05-25 12:34:54 -07002070 /*
2071 * Turbo will still be enabled, but won't go below the set value.
2072 */
Jesse Barnes0a073b82013-04-17 15:54:58 -07002073 if (IS_VALLEYVIEW(dev)) {
2074 val = vlv_freq_opcode(dev_priv->mem_freq, val);
2075 dev_priv->rps.min_delay = val;
2076 valleyview_set_rps(dev, val);
2077 } else {
2078 do_div(val, GT_FREQUENCY_MULTIPLIER);
2079 dev_priv->rps.min_delay = val;
2080 gen6_set_rps(dev, val);
2081 }
Jesse Barnes4fc688c2012-11-02 11:14:01 -07002082 mutex_unlock(&dev_priv->rps.hw_lock);
Jesse Barnes1523c312012-05-25 12:34:54 -07002083
Kees Cook647416f2013-03-10 14:10:06 -07002084 return 0;
Jesse Barnes1523c312012-05-25 12:34:54 -07002085}
2086
Kees Cook647416f2013-03-10 14:10:06 -07002087DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
2088 i915_min_freq_get, i915_min_freq_set,
Mika Kuoppala3a3b4f92013-04-12 12:10:05 +03002089 "%llu\n");
Jesse Barnes1523c312012-05-25 12:34:54 -07002090
Kees Cook647416f2013-03-10 14:10:06 -07002091static int
2092i915_cache_sharing_get(void *data, u64 *val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002093{
Kees Cook647416f2013-03-10 14:10:06 -07002094 struct drm_device *dev = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002095 drm_i915_private_t *dev_priv = dev->dev_private;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002096 u32 snpcr;
Kees Cook647416f2013-03-10 14:10:06 -07002097 int ret;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002098
Daniel Vetter004777c2012-08-09 15:07:01 +02002099 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
2100 return -ENODEV;
2101
Daniel Vetter22bcfc62012-08-09 15:07:02 +02002102 ret = mutex_lock_interruptible(&dev->struct_mutex);
2103 if (ret)
2104 return ret;
2105
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002106 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
2107 mutex_unlock(&dev_priv->dev->struct_mutex);
2108
Kees Cook647416f2013-03-10 14:10:06 -07002109 *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002110
Kees Cook647416f2013-03-10 14:10:06 -07002111 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002112}
2113
Kees Cook647416f2013-03-10 14:10:06 -07002114static int
2115i915_cache_sharing_set(void *data, u64 val)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002116{
Kees Cook647416f2013-03-10 14:10:06 -07002117 struct drm_device *dev = data;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002118 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002119 u32 snpcr;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002120
Daniel Vetter004777c2012-08-09 15:07:01 +02002121 if (!(IS_GEN6(dev) || IS_GEN7(dev)))
2122 return -ENODEV;
2123
Kees Cook647416f2013-03-10 14:10:06 -07002124 if (val > 3)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002125 return -EINVAL;
2126
Kees Cook647416f2013-03-10 14:10:06 -07002127 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002128
2129 /* Update the cache sharing policy here as well */
2130 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
2131 snpcr &= ~GEN6_MBC_SNPCR_MASK;
2132 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
2133 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
2134
Kees Cook647416f2013-03-10 14:10:06 -07002135 return 0;
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002136}
2137
Kees Cook647416f2013-03-10 14:10:06 -07002138DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
2139 i915_cache_sharing_get, i915_cache_sharing_set,
2140 "%llu\n");
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002141
Chris Wilsonf3cd4742009-10-13 22:20:20 +01002142/* As the drm_debugfs_init() routines are called before dev->dev_private is
2143 * allocated we need to hook into the minor for release. */
2144static int
2145drm_add_fake_info_node(struct drm_minor *minor,
2146 struct dentry *ent,
2147 const void *key)
2148{
2149 struct drm_info_node *node;
2150
2151 node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
2152 if (node == NULL) {
2153 debugfs_remove(ent);
2154 return -ENOMEM;
2155 }
2156
2157 node->minor = minor;
2158 node->dent = ent;
2159 node->info_ent = (void *) key;
Marcin Slusarzb3e067c2011-11-09 22:20:35 +01002160
2161 mutex_lock(&minor->debugfs_lock);
2162 list_add(&node->list, &minor->debugfs_list);
2163 mutex_unlock(&minor->debugfs_lock);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01002164
2165 return 0;
2166}
2167
Ben Widawsky6d794d42011-04-25 11:25:56 -07002168static int i915_forcewake_open(struct inode *inode, struct file *file)
2169{
2170 struct drm_device *dev = inode->i_private;
2171 struct drm_i915_private *dev_priv = dev->dev_private;
Ben Widawsky6d794d42011-04-25 11:25:56 -07002172
Daniel Vetter075edca2012-01-24 09:44:28 +01002173 if (INTEL_INFO(dev)->gen < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07002174 return 0;
2175
Ben Widawsky6d794d42011-04-25 11:25:56 -07002176 gen6_gt_force_wake_get(dev_priv);
Ben Widawsky6d794d42011-04-25 11:25:56 -07002177
2178 return 0;
2179}
2180
Ben Widawskyc43b5632012-04-16 14:07:40 -07002181static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07002182{
2183 struct drm_device *dev = inode->i_private;
2184 struct drm_i915_private *dev_priv = dev->dev_private;
2185
Daniel Vetter075edca2012-01-24 09:44:28 +01002186 if (INTEL_INFO(dev)->gen < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07002187 return 0;
2188
Ben Widawsky6d794d42011-04-25 11:25:56 -07002189 gen6_gt_force_wake_put(dev_priv);
Ben Widawsky6d794d42011-04-25 11:25:56 -07002190
2191 return 0;
2192}
2193
2194static const struct file_operations i915_forcewake_fops = {
2195 .owner = THIS_MODULE,
2196 .open = i915_forcewake_open,
2197 .release = i915_forcewake_release,
2198};
2199
2200static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
2201{
2202 struct drm_device *dev = minor->dev;
2203 struct dentry *ent;
2204
2205 ent = debugfs_create_file("i915_forcewake_user",
Ben Widawsky8eb57292011-05-11 15:10:58 -07002206 S_IRUSR,
Ben Widawsky6d794d42011-04-25 11:25:56 -07002207 root, dev,
2208 &i915_forcewake_fops);
2209 if (IS_ERR(ent))
2210 return PTR_ERR(ent);
2211
Ben Widawsky8eb57292011-05-11 15:10:58 -07002212 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
Ben Widawsky6d794d42011-04-25 11:25:56 -07002213}
2214
Daniel Vetter6a9c3082011-12-14 13:57:11 +01002215static int i915_debugfs_create(struct dentry *root,
2216 struct drm_minor *minor,
2217 const char *name,
2218 const struct file_operations *fops)
Jesse Barnes358733e2011-07-27 11:53:01 -07002219{
2220 struct drm_device *dev = minor->dev;
2221 struct dentry *ent;
2222
Daniel Vetter6a9c3082011-12-14 13:57:11 +01002223 ent = debugfs_create_file(name,
Jesse Barnes358733e2011-07-27 11:53:01 -07002224 S_IRUGO | S_IWUSR,
2225 root, dev,
Daniel Vetter6a9c3082011-12-14 13:57:11 +01002226 fops);
Jesse Barnes358733e2011-07-27 11:53:01 -07002227 if (IS_ERR(ent))
2228 return PTR_ERR(ent);
2229
Daniel Vetter6a9c3082011-12-14 13:57:11 +01002230 return drm_add_fake_info_node(minor, ent, fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07002231}
2232
Ben Gamari27c202a2009-07-01 22:26:52 -04002233static struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00002234 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01002235 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00002236 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson1b502472012-04-24 15:47:30 +01002237 {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05002238 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05002239 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
Chris Wilson6d2b88852013-08-07 18:30:54 +01002240 {"i915_gem_stolen", i915_gem_stolen_list_info },
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01002241 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05002242 {"i915_gem_request", i915_gem_request_info, 0},
2243 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00002244 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05002245 {"i915_gem_interrupt", i915_interrupt_info, 0},
Chris Wilson1ec14ad2010-12-04 11:30:53 +00002246 {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
2247 {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
2248 {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
Xiang, Haihao9010ebf2013-05-29 09:22:36 -07002249 {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS},
Jesse Barnesf97108d2010-01-29 11:27:07 -08002250 {"i915_rstdby_delays", i915_rstdby_delays, 0},
2251 {"i915_cur_delayinfo", i915_cur_delayinfo, 0},
2252 {"i915_delayfreq_table", i915_delayfreq_table, 0},
2253 {"i915_inttoext_table", i915_inttoext_table, 0},
2254 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07002255 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07002256 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07002257 {"i915_gfxec", i915_gfxec, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08002258 {"i915_fbc_status", i915_fbc_status, 0},
Paulo Zanoni92d44622013-05-31 16:33:24 -03002259 {"i915_ips_status", i915_ips_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08002260 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01002261 {"i915_opregion", i915_opregion, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01002262 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07002263 {"i915_context_status", i915_context_status, 0},
Ben Widawsky6d794d42011-04-25 11:25:56 -07002264 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01002265 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01002266 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Jesse Barnes57f350b2012-03-28 13:39:25 -07002267 {"i915_dpio", i915_dpio_info, 0},
Ben Widawsky63573eb2013-07-04 11:02:07 -07002268 {"i915_llc", i915_llc, 0},
Rodrigo Vivie91fd8c2013-07-11 18:44:59 -03002269 {"i915_edp_psr_status", i915_edp_psr_status, 0},
Jesse Barnesec013e72013-08-20 10:29:23 +01002270 {"i915_energy_uJ", i915_energy_uJ, 0},
Paulo Zanoni371db662013-08-19 13:18:10 -03002271 {"i915_pc8_status", i915_pc8_status, 0},
Ben Gamari20172632009-02-17 20:08:50 -05002272};
Ben Gamari27c202a2009-07-01 22:26:52 -04002273#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05002274
Ville Syrjälä2b4bd0e2013-08-07 15:11:52 +03002275static struct i915_debugfs_files {
Daniel Vetter34b96742013-07-04 20:49:44 +02002276 const char *name;
2277 const struct file_operations *fops;
2278} i915_debugfs_files[] = {
2279 {"i915_wedged", &i915_wedged_fops},
2280 {"i915_max_freq", &i915_max_freq_fops},
2281 {"i915_min_freq", &i915_min_freq_fops},
2282 {"i915_cache_sharing", &i915_cache_sharing_fops},
2283 {"i915_ring_stop", &i915_ring_stop_fops},
2284 {"i915_gem_drop_caches", &i915_drop_caches_fops},
2285 {"i915_error_state", &i915_error_state_fops},
2286 {"i915_next_seqno", &i915_next_seqno_fops},
2287};
2288
Ben Gamari27c202a2009-07-01 22:26:52 -04002289int i915_debugfs_init(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05002290{
Daniel Vetter34b96742013-07-04 20:49:44 +02002291 int ret, i;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01002292
Ben Widawsky6d794d42011-04-25 11:25:56 -07002293 ret = i915_forcewake_create(minor->debugfs_root, minor);
2294 if (ret)
2295 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01002296
Daniel Vetter34b96742013-07-04 20:49:44 +02002297 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
2298 ret = i915_debugfs_create(minor->debugfs_root, minor,
2299 i915_debugfs_files[i].name,
2300 i915_debugfs_files[i].fops);
2301 if (ret)
2302 return ret;
2303 }
Mika Kuoppala40633212012-12-04 15:12:00 +02002304
Ben Gamari27c202a2009-07-01 22:26:52 -04002305 return drm_debugfs_create_files(i915_debugfs_list,
2306 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05002307 minor->debugfs_root, minor);
2308}
2309
Ben Gamari27c202a2009-07-01 22:26:52 -04002310void i915_debugfs_cleanup(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05002311{
Daniel Vetter34b96742013-07-04 20:49:44 +02002312 int i;
2313
Ben Gamari27c202a2009-07-01 22:26:52 -04002314 drm_debugfs_remove_files(i915_debugfs_list,
2315 I915_DEBUGFS_ENTRIES, minor);
Ben Widawsky6d794d42011-04-25 11:25:56 -07002316 drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops,
2317 1, minor);
Daniel Vetter34b96742013-07-04 20:49:44 +02002318 for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
2319 struct drm_info_list *info_list =
2320 (struct drm_info_list *) i915_debugfs_files[i].fops;
2321
2322 drm_debugfs_remove_files(info_list, 1, minor);
2323 }
Ben Gamari20172632009-02-17 20:08:50 -05002324}
2325
2326#endif /* CONFIG_DEBUG_FS */