blob: ae68ac1c488e877afd42f1656dff8d676ccc3596 [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>
Ben Gamari20172632009-02-17 20:08:50 -050033#include "drmP.h"
34#include "drm.h"
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010035#include "intel_drv.h"
Chris Wilsone5c65262010-11-01 11:35:28 +000036#include "intel_ringbuffer.h"
Ben Gamari20172632009-02-17 20:08:50 -050037#include "i915_drm.h"
38#include "i915_drv.h"
39
40#define DRM_I915_RING_DEBUG 1
41
42
43#if defined(CONFIG_DEBUG_FS)
44
Chris Wilsonf13d3f72010-09-20 17:36:15 +010045enum {
Chris Wilson69dc4982010-10-19 10:36:51 +010046 ACTIVE_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010047 FLUSHING_LIST,
48 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));
Chris Wilson70d39fe2010-08-25 16:03:34 +010065#define B(x) seq_printf(m, #x ": %s\n", yesno(info->x))
66 B(is_mobile);
Chris Wilson70d39fe2010-08-25 16:03:34 +010067 B(is_i85x);
68 B(is_i915g);
Chris Wilson70d39fe2010-08-25 16:03:34 +010069 B(is_i945gm);
Chris Wilson70d39fe2010-08-25 16:03:34 +010070 B(is_g33);
71 B(need_gfx_hws);
72 B(is_g4x);
73 B(is_pineview);
74 B(is_broadwater);
75 B(is_crestline);
Chris Wilson70d39fe2010-08-25 16:03:34 +010076 B(has_fbc);
Chris Wilson70d39fe2010-08-25 16:03:34 +010077 B(has_pipe_cxsr);
78 B(has_hotplug);
79 B(cursor_needs_physical);
80 B(has_overlay);
81 B(overlay_needs_physical);
Chris Wilsona6c45cf2010-09-17 00:32:17 +010082 B(supports_tv);
Chris Wilson549f7362010-10-19 11:19:32 +010083 B(has_bsd_ring);
84 B(has_blt_ring);
Eugeni Dodonov3d29b842012-01-17 14:43:53 -020085 B(has_llc);
Chris Wilson70d39fe2010-08-25 16:03:34 +010086#undef B
87
88 return 0;
89}
Ben Gamari433e12f2009-02-17 20:08:51 -050090
Chris Wilson05394f32010-11-08 19:18:58 +000091static const char *get_pin_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +000092{
Chris Wilson05394f32010-11-08 19:18:58 +000093 if (obj->user_pin_count > 0)
Chris Wilsona6172a82009-02-11 14:26:38 +000094 return "P";
Chris Wilson05394f32010-11-08 19:18:58 +000095 else if (obj->pin_count > 0)
Chris Wilsona6172a82009-02-11 14:26:38 +000096 return "p";
97 else
98 return " ";
99}
100
Chris Wilson05394f32010-11-08 19:18:58 +0000101static const char *get_tiling_flag(struct drm_i915_gem_object *obj)
Chris Wilsona6172a82009-02-11 14:26:38 +0000102{
Akshay Joshi0206e352011-08-16 15:34:10 -0400103 switch (obj->tiling_mode) {
104 default:
105 case I915_TILING_NONE: return " ";
106 case I915_TILING_X: return "X";
107 case I915_TILING_Y: return "Y";
108 }
Chris Wilsona6172a82009-02-11 14:26:38 +0000109}
110
Chris Wilson93dfb402011-03-29 16:59:50 -0700111static const char *cache_level_str(int type)
Chris Wilson08c18322011-01-10 00:00:24 +0000112{
113 switch (type) {
Chris Wilson93dfb402011-03-29 16:59:50 -0700114 case I915_CACHE_NONE: return " uncached";
115 case I915_CACHE_LLC: return " snooped (LLC)";
116 case I915_CACHE_LLC_MLC: return " snooped (LLC+MLC)";
Chris Wilson08c18322011-01-10 00:00:24 +0000117 default: return "";
118 }
119}
120
Chris Wilson37811fc2010-08-25 22:45:57 +0100121static void
122describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
123{
Eric Anholta05a5862011-12-20 08:54:15 -0800124 seq_printf(m, "%p: %s%s %8zdKiB %04x %04x %d %d%s%s%s",
Chris Wilson37811fc2010-08-25 22:45:57 +0100125 &obj->base,
126 get_pin_flag(obj),
127 get_tiling_flag(obj),
Eric Anholta05a5862011-12-20 08:54:15 -0800128 obj->base.size / 1024,
Chris Wilson37811fc2010-08-25 22:45:57 +0100129 obj->base.read_domains,
130 obj->base.write_domain,
131 obj->last_rendering_seqno,
Chris Wilsoncaea7472010-11-12 13:53:37 +0000132 obj->last_fenced_seqno,
Chris Wilson93dfb402011-03-29 16:59:50 -0700133 cache_level_str(obj->cache_level),
Chris Wilson37811fc2010-08-25 22:45:57 +0100134 obj->dirty ? " dirty" : "",
135 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
136 if (obj->base.name)
137 seq_printf(m, " (name: %d)", obj->base.name);
138 if (obj->fence_reg != I915_FENCE_REG_NONE)
139 seq_printf(m, " (fence: %d)", obj->fence_reg);
140 if (obj->gtt_space != NULL)
Chris Wilsona00b10c2010-09-24 21:15:47 +0100141 seq_printf(m, " (gtt offset: %08x, size: %08x)",
142 obj->gtt_offset, (unsigned int)obj->gtt_space->size);
Chris Wilson6299f992010-11-24 12:23:44 +0000143 if (obj->pin_mappable || obj->fault_mappable) {
144 char s[3], *t = s;
145 if (obj->pin_mappable)
146 *t++ = 'p';
147 if (obj->fault_mappable)
148 *t++ = 'f';
149 *t = '\0';
150 seq_printf(m, " (%s mappable)", s);
151 }
Chris Wilson69dc4982010-10-19 10:36:51 +0100152 if (obj->ring != NULL)
153 seq_printf(m, " (%s)", obj->ring->name);
Chris Wilson37811fc2010-08-25 22:45:57 +0100154}
155
Ben Gamari433e12f2009-02-17 20:08:51 -0500156static int i915_gem_object_list_info(struct seq_file *m, void *data)
Ben Gamari20172632009-02-17 20:08:50 -0500157{
158 struct drm_info_node *node = (struct drm_info_node *) m->private;
Ben Gamari433e12f2009-02-17 20:08:51 -0500159 uintptr_t list = (uintptr_t) node->info_ent->data;
160 struct list_head *head;
Ben Gamari20172632009-02-17 20:08:50 -0500161 struct drm_device *dev = node->minor->dev;
162 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilson05394f32010-11-08 19:18:58 +0000163 struct drm_i915_gem_object *obj;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100164 size_t total_obj_size, total_gtt_size;
165 int count, ret;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100166
167 ret = mutex_lock_interruptible(&dev->struct_mutex);
168 if (ret)
169 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500170
Ben Gamari433e12f2009-02-17 20:08:51 -0500171 switch (list) {
172 case ACTIVE_LIST:
173 seq_printf(m, "Active:\n");
Chris Wilson69dc4982010-10-19 10:36:51 +0100174 head = &dev_priv->mm.active_list;
Ben Gamari433e12f2009-02-17 20:08:51 -0500175 break;
176 case INACTIVE_LIST:
Ben Gamaria17458f2009-07-01 15:01:36 -0400177 seq_printf(m, "Inactive:\n");
Ben Gamari433e12f2009-02-17 20:08:51 -0500178 head = &dev_priv->mm.inactive_list;
179 break;
180 case FLUSHING_LIST:
181 seq_printf(m, "Flushing:\n");
182 head = &dev_priv->mm.flushing_list;
183 break;
184 default:
Chris Wilsonde227ef2010-07-03 07:58:38 +0100185 mutex_unlock(&dev->struct_mutex);
186 return -EINVAL;
Ben Gamari433e12f2009-02-17 20:08:51 -0500187 }
188
Chris Wilson8f2480f2010-09-26 11:44:19 +0100189 total_obj_size = total_gtt_size = count = 0;
Chris Wilson05394f32010-11-08 19:18:58 +0000190 list_for_each_entry(obj, head, mm_list) {
Chris Wilson37811fc2010-08-25 22:45:57 +0100191 seq_printf(m, " ");
Chris Wilson05394f32010-11-08 19:18:58 +0000192 describe_obj(m, obj);
Eric Anholtf4ceda82009-02-17 23:53:41 -0800193 seq_printf(m, "\n");
Chris Wilson05394f32010-11-08 19:18:58 +0000194 total_obj_size += obj->base.size;
195 total_gtt_size += obj->gtt_space->size;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100196 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500197 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100198 mutex_unlock(&dev->struct_mutex);
Carl Worth5e118f42009-03-20 11:54:25 -0700199
Chris Wilson8f2480f2010-09-26 11:44:19 +0100200 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
201 count, total_obj_size, total_gtt_size);
Ben Gamari20172632009-02-17 20:08:50 -0500202 return 0;
203}
204
Chris Wilson6299f992010-11-24 12:23:44 +0000205#define count_objects(list, member) do { \
206 list_for_each_entry(obj, list, member) { \
207 size += obj->gtt_space->size; \
208 ++count; \
209 if (obj->map_and_fenceable) { \
210 mappable_size += obj->gtt_space->size; \
211 ++mappable_count; \
212 } \
213 } \
Akshay Joshi0206e352011-08-16 15:34:10 -0400214} while (0)
Chris Wilson6299f992010-11-24 12:23:44 +0000215
Chris Wilson73aa8082010-09-30 11:46:12 +0100216static int i915_gem_object_info(struct seq_file *m, void* data)
217{
218 struct drm_info_node *node = (struct drm_info_node *) m->private;
219 struct drm_device *dev = node->minor->dev;
220 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilson6299f992010-11-24 12:23:44 +0000221 u32 count, mappable_count;
222 size_t size, mappable_size;
223 struct drm_i915_gem_object *obj;
Chris Wilson73aa8082010-09-30 11:46:12 +0100224 int ret;
225
226 ret = mutex_lock_interruptible(&dev->struct_mutex);
227 if (ret)
228 return ret;
229
Chris Wilson6299f992010-11-24 12:23:44 +0000230 seq_printf(m, "%u objects, %zu bytes\n",
231 dev_priv->mm.object_count,
232 dev_priv->mm.object_memory);
233
234 size = count = mappable_size = mappable_count = 0;
235 count_objects(&dev_priv->mm.gtt_list, gtt_list);
236 seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
237 count, mappable_count, size, mappable_size);
238
239 size = count = mappable_size = mappable_count = 0;
240 count_objects(&dev_priv->mm.active_list, mm_list);
241 count_objects(&dev_priv->mm.flushing_list, mm_list);
242 seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n",
243 count, mappable_count, size, mappable_size);
244
245 size = count = mappable_size = mappable_count = 0;
Chris Wilson6299f992010-11-24 12:23:44 +0000246 count_objects(&dev_priv->mm.inactive_list, mm_list);
247 seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n",
248 count, mappable_count, size, mappable_size);
249
250 size = count = mappable_size = mappable_count = 0;
Chris Wilson6299f992010-11-24 12:23:44 +0000251 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
252 if (obj->fault_mappable) {
253 size += obj->gtt_space->size;
254 ++count;
255 }
256 if (obj->pin_mappable) {
257 mappable_size += obj->gtt_space->size;
258 ++mappable_count;
259 }
260 }
261 seq_printf(m, "%u pinned mappable objects, %zu bytes\n",
262 mappable_count, mappable_size);
263 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
264 count, size);
265
266 seq_printf(m, "%zu [%zu] gtt total\n",
267 dev_priv->mm.gtt_total, dev_priv->mm.mappable_gtt_total);
Chris Wilson73aa8082010-09-30 11:46:12 +0100268
269 mutex_unlock(&dev->struct_mutex);
270
271 return 0;
272}
273
Chris Wilson08c18322011-01-10 00:00:24 +0000274static int i915_gem_gtt_info(struct seq_file *m, void* data)
275{
276 struct drm_info_node *node = (struct drm_info_node *) m->private;
277 struct drm_device *dev = node->minor->dev;
Chris Wilson1b502472012-04-24 15:47:30 +0100278 uintptr_t list = (uintptr_t) node->info_ent->data;
Chris Wilson08c18322011-01-10 00:00:24 +0000279 struct drm_i915_private *dev_priv = dev->dev_private;
280 struct drm_i915_gem_object *obj;
281 size_t total_obj_size, total_gtt_size;
282 int count, ret;
283
284 ret = mutex_lock_interruptible(&dev->struct_mutex);
285 if (ret)
286 return ret;
287
288 total_obj_size = total_gtt_size = count = 0;
289 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
Chris Wilson1b502472012-04-24 15:47:30 +0100290 if (list == PINNED_LIST && obj->pin_count == 0)
291 continue;
292
Chris Wilson08c18322011-01-10 00:00:24 +0000293 seq_printf(m, " ");
294 describe_obj(m, obj);
295 seq_printf(m, "\n");
296 total_obj_size += obj->base.size;
297 total_gtt_size += obj->gtt_space->size;
298 count++;
299 }
300
301 mutex_unlock(&dev->struct_mutex);
302
303 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
304 count, total_obj_size, total_gtt_size);
305
306 return 0;
307}
308
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100309static int i915_gem_pageflip_info(struct seq_file *m, void *data)
310{
311 struct drm_info_node *node = (struct drm_info_node *) m->private;
312 struct drm_device *dev = node->minor->dev;
313 unsigned long flags;
314 struct intel_crtc *crtc;
315
316 list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800317 const char pipe = pipe_name(crtc->pipe);
318 const char plane = plane_name(crtc->plane);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100319 struct intel_unpin_work *work;
320
321 spin_lock_irqsave(&dev->event_lock, flags);
322 work = crtc->unpin_work;
323 if (work == NULL) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800324 seq_printf(m, "No flip due on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100325 pipe, plane);
326 } else {
327 if (!work->pending) {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800328 seq_printf(m, "Flip queued on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100329 pipe, plane);
330 } else {
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800331 seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100332 pipe, plane);
333 }
334 if (work->enable_stall_check)
335 seq_printf(m, "Stall check enabled, ");
336 else
337 seq_printf(m, "Stall check waiting for page flip ioctl, ");
338 seq_printf(m, "%d prepares\n", work->pending);
339
340 if (work->old_fb_obj) {
Chris Wilson05394f32010-11-08 19:18:58 +0000341 struct drm_i915_gem_object *obj = work->old_fb_obj;
342 if (obj)
343 seq_printf(m, "Old framebuffer gtt_offset 0x%08x\n", obj->gtt_offset);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100344 }
345 if (work->pending_flip_obj) {
Chris Wilson05394f32010-11-08 19:18:58 +0000346 struct drm_i915_gem_object *obj = work->pending_flip_obj;
347 if (obj)
348 seq_printf(m, "New framebuffer gtt_offset 0x%08x\n", obj->gtt_offset);
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100349 }
350 }
351 spin_unlock_irqrestore(&dev->event_lock, flags);
352 }
353
354 return 0;
355}
356
Ben Gamari20172632009-02-17 20:08:50 -0500357static int i915_gem_request_info(struct seq_file *m, void *data)
358{
359 struct drm_info_node *node = (struct drm_info_node *) m->private;
360 struct drm_device *dev = node->minor->dev;
361 drm_i915_private_t *dev_priv = dev->dev_private;
362 struct drm_i915_gem_request *gem_request;
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100363 int ret, count;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100364
365 ret = mutex_lock_interruptible(&dev->struct_mutex);
366 if (ret)
367 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500368
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100369 count = 0;
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000370 if (!list_empty(&dev_priv->ring[RCS].request_list)) {
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100371 seq_printf(m, "Render requests:\n");
372 list_for_each_entry(gem_request,
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000373 &dev_priv->ring[RCS].request_list,
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100374 list) {
375 seq_printf(m, " %d @ %d\n",
376 gem_request->seqno,
377 (int) (jiffies - gem_request->emitted_jiffies));
378 }
379 count++;
380 }
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000381 if (!list_empty(&dev_priv->ring[VCS].request_list)) {
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100382 seq_printf(m, "BSD requests:\n");
383 list_for_each_entry(gem_request,
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000384 &dev_priv->ring[VCS].request_list,
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100385 list) {
386 seq_printf(m, " %d @ %d\n",
387 gem_request->seqno,
388 (int) (jiffies - gem_request->emitted_jiffies));
389 }
390 count++;
391 }
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000392 if (!list_empty(&dev_priv->ring[BCS].request_list)) {
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100393 seq_printf(m, "BLT requests:\n");
394 list_for_each_entry(gem_request,
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000395 &dev_priv->ring[BCS].request_list,
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100396 list) {
397 seq_printf(m, " %d @ %d\n",
398 gem_request->seqno,
399 (int) (jiffies - gem_request->emitted_jiffies));
400 }
401 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500402 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100403 mutex_unlock(&dev->struct_mutex);
404
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100405 if (count == 0)
406 seq_printf(m, "No requests\n");
407
Ben Gamari20172632009-02-17 20:08:50 -0500408 return 0;
409}
410
Chris Wilsonb2223492010-10-27 15:27:33 +0100411static void i915_ring_seqno_info(struct seq_file *m,
412 struct intel_ring_buffer *ring)
413{
414 if (ring->get_seqno) {
415 seq_printf(m, "Current sequence (%s): %d\n",
416 ring->name, ring->get_seqno(ring));
Chris Wilsonb2223492010-10-27 15:27:33 +0100417 }
418}
419
Ben Gamari20172632009-02-17 20:08:50 -0500420static int i915_gem_seqno_info(struct seq_file *m, void *data)
421{
422 struct drm_info_node *node = (struct drm_info_node *) m->private;
423 struct drm_device *dev = node->minor->dev;
424 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000425 int ret, i;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100426
427 ret = mutex_lock_interruptible(&dev->struct_mutex);
428 if (ret)
429 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500430
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000431 for (i = 0; i < I915_NUM_RINGS; i++)
432 i915_ring_seqno_info(m, &dev_priv->ring[i]);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100433
434 mutex_unlock(&dev->struct_mutex);
435
Ben Gamari20172632009-02-17 20:08:50 -0500436 return 0;
437}
438
439
440static int i915_interrupt_info(struct seq_file *m, void *data)
441{
442 struct drm_info_node *node = (struct drm_info_node *) m->private;
443 struct drm_device *dev = node->minor->dev;
444 drm_i915_private_t *dev_priv = dev->dev_private;
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800445 int ret, i, pipe;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100446
447 ret = mutex_lock_interruptible(&dev->struct_mutex);
448 if (ret)
449 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500450
Jesse Barnes7e231dbe2012-03-28 13:39:38 -0700451 if (IS_VALLEYVIEW(dev)) {
452 seq_printf(m, "Display IER:\t%08x\n",
453 I915_READ(VLV_IER));
454 seq_printf(m, "Display IIR:\t%08x\n",
455 I915_READ(VLV_IIR));
456 seq_printf(m, "Display IIR_RW:\t%08x\n",
457 I915_READ(VLV_IIR_RW));
458 seq_printf(m, "Display IMR:\t%08x\n",
459 I915_READ(VLV_IMR));
460 for_each_pipe(pipe)
461 seq_printf(m, "Pipe %c stat:\t%08x\n",
462 pipe_name(pipe),
463 I915_READ(PIPESTAT(pipe)));
464
465 seq_printf(m, "Master IER:\t%08x\n",
466 I915_READ(VLV_MASTER_IER));
467
468 seq_printf(m, "Render IER:\t%08x\n",
469 I915_READ(GTIER));
470 seq_printf(m, "Render IIR:\t%08x\n",
471 I915_READ(GTIIR));
472 seq_printf(m, "Render IMR:\t%08x\n",
473 I915_READ(GTIMR));
474
475 seq_printf(m, "PM IER:\t\t%08x\n",
476 I915_READ(GEN6_PMIER));
477 seq_printf(m, "PM IIR:\t\t%08x\n",
478 I915_READ(GEN6_PMIIR));
479 seq_printf(m, "PM IMR:\t\t%08x\n",
480 I915_READ(GEN6_PMIMR));
481
482 seq_printf(m, "Port hotplug:\t%08x\n",
483 I915_READ(PORT_HOTPLUG_EN));
484 seq_printf(m, "DPFLIPSTAT:\t%08x\n",
485 I915_READ(VLV_DPFLIPSTAT));
486 seq_printf(m, "DPINVGTT:\t%08x\n",
487 I915_READ(DPINVGTT));
488
489 } else if (!HAS_PCH_SPLIT(dev)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800490 seq_printf(m, "Interrupt enable: %08x\n",
491 I915_READ(IER));
492 seq_printf(m, "Interrupt identity: %08x\n",
493 I915_READ(IIR));
494 seq_printf(m, "Interrupt mask: %08x\n",
495 I915_READ(IMR));
Jesse Barnes9db4a9c2011-02-07 12:26:52 -0800496 for_each_pipe(pipe)
497 seq_printf(m, "Pipe %c stat: %08x\n",
498 pipe_name(pipe),
499 I915_READ(PIPESTAT(pipe)));
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800500 } else {
501 seq_printf(m, "North Display Interrupt enable: %08x\n",
502 I915_READ(DEIER));
503 seq_printf(m, "North Display Interrupt identity: %08x\n",
504 I915_READ(DEIIR));
505 seq_printf(m, "North Display Interrupt mask: %08x\n",
506 I915_READ(DEIMR));
507 seq_printf(m, "South Display Interrupt enable: %08x\n",
508 I915_READ(SDEIER));
509 seq_printf(m, "South Display Interrupt identity: %08x\n",
510 I915_READ(SDEIIR));
511 seq_printf(m, "South Display Interrupt mask: %08x\n",
512 I915_READ(SDEIMR));
513 seq_printf(m, "Graphics Interrupt enable: %08x\n",
514 I915_READ(GTIER));
515 seq_printf(m, "Graphics Interrupt identity: %08x\n",
516 I915_READ(GTIIR));
517 seq_printf(m, "Graphics Interrupt mask: %08x\n",
518 I915_READ(GTIMR));
519 }
Ben Gamari20172632009-02-17 20:08:50 -0500520 seq_printf(m, "Interrupts received: %d\n",
521 atomic_read(&dev_priv->irq_received));
Chris Wilson9862e602011-01-04 22:22:17 +0000522 for (i = 0; i < I915_NUM_RINGS; i++) {
Jesse Barnesda64c6f2011-08-09 09:17:46 -0700523 if (IS_GEN6(dev) || IS_GEN7(dev)) {
Chris Wilson9862e602011-01-04 22:22:17 +0000524 seq_printf(m, "Graphics Interrupt mask (%s): %08x\n",
525 dev_priv->ring[i].name,
526 I915_READ_IMR(&dev_priv->ring[i]));
527 }
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000528 i915_ring_seqno_info(m, &dev_priv->ring[i]);
Chris Wilson9862e602011-01-04 22:22:17 +0000529 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100530 mutex_unlock(&dev->struct_mutex);
531
Ben Gamari20172632009-02-17 20:08:50 -0500532 return 0;
533}
534
Chris Wilsona6172a82009-02-11 14:26:38 +0000535static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
536{
537 struct drm_info_node *node = (struct drm_info_node *) m->private;
538 struct drm_device *dev = node->minor->dev;
539 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100540 int i, ret;
541
542 ret = mutex_lock_interruptible(&dev->struct_mutex);
543 if (ret)
544 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000545
546 seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
547 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
548 for (i = 0; i < dev_priv->num_fence_regs; i++) {
Chris Wilson05394f32010-11-08 19:18:58 +0000549 struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj;
Chris Wilsona6172a82009-02-11 14:26:38 +0000550
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100551 seq_printf(m, "Fenced object[%2d] = ", i);
552 if (obj == NULL)
553 seq_printf(m, "unused");
554 else
Chris Wilson05394f32010-11-08 19:18:58 +0000555 describe_obj(m, obj);
Chris Wilsonc2c347a92010-10-27 15:11:53 +0100556 seq_printf(m, "\n");
Chris Wilsona6172a82009-02-11 14:26:38 +0000557 }
558
Chris Wilson05394f32010-11-08 19:18:58 +0000559 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000560 return 0;
561}
562
Ben Gamari20172632009-02-17 20:08:50 -0500563static int i915_hws_info(struct seq_file *m, void *data)
564{
565 struct drm_info_node *node = (struct drm_info_node *) m->private;
566 struct drm_device *dev = node->minor->dev;
567 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilson4066c0a2010-10-29 21:00:54 +0100568 struct intel_ring_buffer *ring;
Chris Wilson311bd682011-01-13 19:06:50 +0000569 const volatile u32 __iomem *hws;
Chris Wilson4066c0a2010-10-29 21:00:54 +0100570 int i;
Ben Gamari20172632009-02-17 20:08:50 -0500571
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000572 ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
Chris Wilson311bd682011-01-13 19:06:50 +0000573 hws = (volatile u32 __iomem *)ring->status_page.page_addr;
Ben Gamari20172632009-02-17 20:08:50 -0500574 if (hws == NULL)
575 return 0;
576
577 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
578 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
579 i * 4,
580 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
581 }
582 return 0;
583}
584
Chris Wilsone5c65262010-11-01 11:35:28 +0000585static const char *ring_str(int ring)
586{
587 switch (ring) {
Daniel Vetter96154f22011-12-14 13:57:00 +0100588 case RCS: return "render";
589 case VCS: return "bsd";
590 case BCS: return "blt";
Chris Wilsone5c65262010-11-01 11:35:28 +0000591 default: return "";
592 }
593}
594
Chris Wilson9df30792010-02-18 10:24:56 +0000595static const char *pin_flag(int pinned)
596{
597 if (pinned > 0)
598 return " P";
599 else if (pinned < 0)
600 return " p";
601 else
602 return "";
603}
604
605static const char *tiling_flag(int tiling)
606{
607 switch (tiling) {
608 default:
609 case I915_TILING_NONE: return "";
610 case I915_TILING_X: return " X";
611 case I915_TILING_Y: return " Y";
612 }
613}
614
615static const char *dirty_flag(int dirty)
616{
617 return dirty ? " dirty" : "";
618}
619
620static const char *purgeable_flag(int purgeable)
621{
622 return purgeable ? " purgeable" : "";
623}
624
Chris Wilsonc724e8a2010-11-22 08:07:02 +0000625static void print_error_buffers(struct seq_file *m,
626 const char *name,
627 struct drm_i915_error_buffer *err,
628 int count)
629{
630 seq_printf(m, "%s [%d]:\n", name, count);
631
632 while (count--) {
Daniel Vetter96154f22011-12-14 13:57:00 +0100633 seq_printf(m, " %08x %8u %04x %04x %08x%s%s%s%s%s%s%s",
Chris Wilsonc724e8a2010-11-22 08:07:02 +0000634 err->gtt_offset,
635 err->size,
636 err->read_domains,
637 err->write_domain,
638 err->seqno,
639 pin_flag(err->pinned),
640 tiling_flag(err->tiling),
641 dirty_flag(err->dirty),
642 purgeable_flag(err->purgeable),
Daniel Vetter96154f22011-12-14 13:57:00 +0100643 err->ring != -1 ? " " : "",
Chris Wilsona779e5a2011-01-09 21:07:49 +0000644 ring_str(err->ring),
Chris Wilson93dfb402011-03-29 16:59:50 -0700645 cache_level_str(err->cache_level));
Chris Wilsonc724e8a2010-11-22 08:07:02 +0000646
647 if (err->name)
648 seq_printf(m, " (name: %d)", err->name);
649 if (err->fence_reg != I915_FENCE_REG_NONE)
650 seq_printf(m, " (fence: %d)", err->fence_reg);
651
652 seq_printf(m, "\n");
653 err++;
654 }
655}
656
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100657static void i915_ring_error_state(struct seq_file *m,
658 struct drm_device *dev,
659 struct drm_i915_error_state *error,
660 unsigned ring)
661{
Ben Widawskyec34a012012-04-03 23:03:00 -0700662 BUG_ON(ring >= I915_NUM_RINGS); /* shut up confused gcc */
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100663 seq_printf(m, "%s command stream:\n", ring_str(ring));
Daniel Vetterc1cd90e2011-12-14 13:57:02 +0100664 seq_printf(m, " HEAD: 0x%08x\n", error->head[ring]);
665 seq_printf(m, " TAIL: 0x%08x\n", error->tail[ring]);
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100666 seq_printf(m, " ACTHD: 0x%08x\n", error->acthd[ring]);
667 seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir[ring]);
668 seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr[ring]);
669 seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone[ring]);
Daniel Vetterc1cd90e2011-12-14 13:57:02 +0100670 if (ring == RCS && INTEL_INFO(dev)->gen >= 4) {
671 seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1);
672 seq_printf(m, " BBADDR: 0x%08llx\n", error->bbaddr);
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100673 }
Daniel Vetterc1cd90e2011-12-14 13:57:02 +0100674 if (INTEL_INFO(dev)->gen >= 4)
675 seq_printf(m, " INSTPS: 0x%08x\n", error->instps[ring]);
676 seq_printf(m, " INSTPM: 0x%08x\n", error->instpm[ring]);
Daniel Vetter9d2f41f2012-04-02 21:41:45 +0200677 seq_printf(m, " FADDR: 0x%08x\n", error->faddr[ring]);
Daniel Vetter33f3f512011-12-14 13:57:39 +0100678 if (INTEL_INFO(dev)->gen >= 6) {
Daniel Vetter33f3f512011-12-14 13:57:39 +0100679 seq_printf(m, " FAULT_REG: 0x%08x\n", error->fault_reg[ring]);
Daniel Vetter7e3b8732012-02-01 22:26:45 +0100680 seq_printf(m, " SYNC_0: 0x%08x\n",
681 error->semaphore_mboxes[ring][0]);
682 seq_printf(m, " SYNC_1: 0x%08x\n",
683 error->semaphore_mboxes[ring][1]);
Daniel Vetter33f3f512011-12-14 13:57:39 +0100684 }
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100685 seq_printf(m, " seqno: 0x%08x\n", error->seqno[ring]);
Ben Widawsky9574b3f2012-04-26 16:03:01 -0700686 seq_printf(m, " waiting: %s\n", yesno(error->waiting[ring]));
Daniel Vetter7e3b8732012-02-01 22:26:45 +0100687 seq_printf(m, " ring->head: 0x%08x\n", error->cpu_ring_head[ring]);
688 seq_printf(m, " ring->tail: 0x%08x\n", error->cpu_ring_tail[ring]);
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100689}
690
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700691static int i915_error_state(struct seq_file *m, void *unused)
692{
693 struct drm_info_node *node = (struct drm_info_node *) m->private;
694 struct drm_device *dev = node->minor->dev;
695 drm_i915_private_t *dev_priv = dev->dev_private;
696 struct drm_i915_error_state *error;
697 unsigned long flags;
Chris Wilson52d39a22012-02-15 11:25:37 +0000698 int i, j, page, offset, elt;
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700699
700 spin_lock_irqsave(&dev_priv->error_lock, flags);
701 if (!dev_priv->first_error) {
702 seq_printf(m, "no error state collected\n");
703 goto out;
704 }
705
706 error = dev_priv->first_error;
707
Jesse Barnes8a905232009-07-11 16:48:03 -0400708 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
709 error->time.tv_usec);
Chris Wilson9df30792010-02-18 10:24:56 +0000710 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
Chris Wilson1d8f38f2010-10-29 19:00:51 +0100711 seq_printf(m, "EIR: 0x%08x\n", error->eir);
Ben Widawskybe998e22012-04-26 16:03:00 -0700712 seq_printf(m, "IER: 0x%08x\n", error->ier);
Chris Wilson1d8f38f2010-10-29 19:00:51 +0100713 seq_printf(m, "PGTBL_ER: 0x%08x\n", error->pgtbl_er);
Chris Wilson9df30792010-02-18 10:24:56 +0000714
Daniel Vetterbf3301a2011-05-12 22:17:12 +0100715 for (i = 0; i < dev_priv->num_fence_regs; i++)
Chris Wilson748ebc62010-10-24 10:28:47 +0100716 seq_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]);
717
Daniel Vetter33f3f512011-12-14 13:57:39 +0100718 if (INTEL_INFO(dev)->gen >= 6) {
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100719 seq_printf(m, "ERROR: 0x%08x\n", error->error);
Daniel Vetter33f3f512011-12-14 13:57:39 +0100720 seq_printf(m, "DONE_REG: 0x%08x\n", error->done_reg);
721 }
Daniel Vetterd27b1e02011-12-14 13:57:01 +0100722
723 i915_ring_error_state(m, dev, error, RCS);
724 if (HAS_BLT(dev))
725 i915_ring_error_state(m, dev, error, BCS);
726 if (HAS_BSD(dev))
727 i915_ring_error_state(m, dev, error, VCS);
728
Chris Wilsonc724e8a2010-11-22 08:07:02 +0000729 if (error->active_bo)
730 print_error_buffers(m, "Active",
731 error->active_bo,
732 error->active_bo_count);
Chris Wilson9df30792010-02-18 10:24:56 +0000733
Chris Wilsonc724e8a2010-11-22 08:07:02 +0000734 if (error->pinned_bo)
735 print_error_buffers(m, "Pinned",
736 error->pinned_bo,
737 error->pinned_bo_count);
Chris Wilson9df30792010-02-18 10:24:56 +0000738
Chris Wilson52d39a22012-02-15 11:25:37 +0000739 for (i = 0; i < ARRAY_SIZE(error->ring); i++) {
740 struct drm_i915_error_object *obj;
Chris Wilson9df30792010-02-18 10:24:56 +0000741
Chris Wilson52d39a22012-02-15 11:25:37 +0000742 if ((obj = error->ring[i].batchbuffer)) {
Chris Wilsonbcfb2e22011-01-07 21:06:07 +0000743 seq_printf(m, "%s --- gtt_offset = 0x%08x\n",
744 dev_priv->ring[i].name,
745 obj->gtt_offset);
Chris Wilson9df30792010-02-18 10:24:56 +0000746 offset = 0;
747 for (page = 0; page < obj->page_count; page++) {
748 for (elt = 0; elt < PAGE_SIZE/4; elt++) {
749 seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]);
750 offset += 4;
751 }
752 }
753 }
Chris Wilson9df30792010-02-18 10:24:56 +0000754
Chris Wilson52d39a22012-02-15 11:25:37 +0000755 if (error->ring[i].num_requests) {
756 seq_printf(m, "%s --- %d requests\n",
757 dev_priv->ring[i].name,
758 error->ring[i].num_requests);
759 for (j = 0; j < error->ring[i].num_requests; j++) {
Chris Wilsonee4f42b2012-02-15 11:25:38 +0000760 seq_printf(m, " seqno 0x%08x, emitted %ld, tail 0x%08x\n",
Chris Wilson52d39a22012-02-15 11:25:37 +0000761 error->ring[i].requests[j].seqno,
Chris Wilsonee4f42b2012-02-15 11:25:38 +0000762 error->ring[i].requests[j].jiffies,
763 error->ring[i].requests[j].tail);
Chris Wilson52d39a22012-02-15 11:25:37 +0000764 }
765 }
766
767 if ((obj = error->ring[i].ringbuffer)) {
Chris Wilsone2f973d2011-01-27 19:15:11 +0000768 seq_printf(m, "%s --- ringbuffer = 0x%08x\n",
769 dev_priv->ring[i].name,
770 obj->gtt_offset);
771 offset = 0;
772 for (page = 0; page < obj->page_count; page++) {
773 for (elt = 0; elt < PAGE_SIZE/4; elt++) {
774 seq_printf(m, "%08x : %08x\n",
775 offset,
776 obj->pages[page][elt]);
777 offset += 4;
778 }
Chris Wilson9df30792010-02-18 10:24:56 +0000779 }
780 }
781 }
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700782
Chris Wilson6ef3d422010-08-04 20:26:07 +0100783 if (error->overlay)
784 intel_overlay_print_error_state(m, error->overlay);
785
Chris Wilsonc4a1d9e2010-11-21 13:12:35 +0000786 if (error->display)
787 intel_display_print_error_state(m, dev, error->display);
788
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700789out:
790 spin_unlock_irqrestore(&dev_priv->error_lock, flags);
791
792 return 0;
793}
Ben Gamari6911a9b2009-04-02 11:24:54 -0700794
Jesse Barnesf97108d2010-01-29 11:27:07 -0800795static int i915_rstdby_delays(struct seq_file *m, void *unused)
796{
797 struct drm_info_node *node = (struct drm_info_node *) m->private;
798 struct drm_device *dev = node->minor->dev;
799 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700800 u16 crstanddelay;
801 int ret;
802
803 ret = mutex_lock_interruptible(&dev->struct_mutex);
804 if (ret)
805 return ret;
806
807 crstanddelay = I915_READ16(CRSTANDVID);
808
809 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800810
811 seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
812
813 return 0;
814}
815
816static int i915_cur_delayinfo(struct seq_file *m, void *unused)
817{
818 struct drm_info_node *node = (struct drm_info_node *) m->private;
819 struct drm_device *dev = node->minor->dev;
820 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawskyd1ebd8162011-04-25 20:11:50 +0100821 int ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800822
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800823 if (IS_GEN5(dev)) {
824 u16 rgvswctl = I915_READ16(MEMSWCTL);
825 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
826
827 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
828 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
829 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
830 MEMSTAT_VID_SHIFT);
831 seq_printf(m, "Current P-state: %d\n",
832 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
Jesse Barnes1c70c0c2011-06-29 13:34:36 -0700833 } else if (IS_GEN6(dev) || IS_GEN7(dev)) {
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800834 u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
835 u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
836 u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
Jesse Barnesccab5c82011-01-18 15:49:25 -0800837 u32 rpstat;
838 u32 rpupei, rpcurup, rpprevup;
839 u32 rpdownei, rpcurdown, rpprevdown;
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800840 int max_freq;
841
842 /* RPSTAT1 is in the GT power well */
Ben Widawskyd1ebd8162011-04-25 20:11:50 +0100843 ret = mutex_lock_interruptible(&dev->struct_mutex);
844 if (ret)
845 return ret;
846
Ben Widawskyfcca7922011-04-25 11:23:07 -0700847 gen6_gt_force_wake_get(dev_priv);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800848
Jesse Barnesccab5c82011-01-18 15:49:25 -0800849 rpstat = I915_READ(GEN6_RPSTAT1);
850 rpupei = I915_READ(GEN6_RP_CUR_UP_EI);
851 rpcurup = I915_READ(GEN6_RP_CUR_UP);
852 rpprevup = I915_READ(GEN6_RP_PREV_UP);
853 rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI);
854 rpcurdown = I915_READ(GEN6_RP_CUR_DOWN);
855 rpprevdown = I915_READ(GEN6_RP_PREV_DOWN);
856
Ben Widawskyd1ebd8162011-04-25 20:11:50 +0100857 gen6_gt_force_wake_put(dev_priv);
858 mutex_unlock(&dev->struct_mutex);
859
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800860 seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
Jesse Barnesccab5c82011-01-18 15:49:25 -0800861 seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800862 seq_printf(m, "Render p-state ratio: %d\n",
863 (gt_perf_status & 0xff00) >> 8);
864 seq_printf(m, "Render p-state VID: %d\n",
865 gt_perf_status & 0xff);
866 seq_printf(m, "Render p-state limit: %d\n",
867 rp_state_limits & 0xff);
Jesse Barnesccab5c82011-01-18 15:49:25 -0800868 seq_printf(m, "CAGF: %dMHz\n", ((rpstat & GEN6_CAGF_MASK) >>
Jesse Barnese281fca2011-03-18 10:32:07 -0700869 GEN6_CAGF_SHIFT) * 50);
Jesse Barnesccab5c82011-01-18 15:49:25 -0800870 seq_printf(m, "RP CUR UP EI: %dus\n", rpupei &
871 GEN6_CURICONT_MASK);
872 seq_printf(m, "RP CUR UP: %dus\n", rpcurup &
873 GEN6_CURBSYTAVG_MASK);
874 seq_printf(m, "RP PREV UP: %dus\n", rpprevup &
875 GEN6_CURBSYTAVG_MASK);
876 seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei &
877 GEN6_CURIAVG_MASK);
878 seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown &
879 GEN6_CURBSYTAVG_MASK);
880 seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown &
881 GEN6_CURBSYTAVG_MASK);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800882
883 max_freq = (rp_state_cap & 0xff0000) >> 16;
884 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
Jesse Barnese281fca2011-03-18 10:32:07 -0700885 max_freq * 50);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800886
887 max_freq = (rp_state_cap & 0xff00) >> 8;
888 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
Jesse Barnese281fca2011-03-18 10:32:07 -0700889 max_freq * 50);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800890
891 max_freq = rp_state_cap & 0xff;
892 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
Jesse Barnese281fca2011-03-18 10:32:07 -0700893 max_freq * 50);
Jesse Barnes3b8d8d92010-12-17 14:19:02 -0800894 } else {
895 seq_printf(m, "no P-state info available\n");
896 }
Jesse Barnesf97108d2010-01-29 11:27:07 -0800897
898 return 0;
899}
900
901static int i915_delayfreq_table(struct seq_file *m, void *unused)
902{
903 struct drm_info_node *node = (struct drm_info_node *) m->private;
904 struct drm_device *dev = node->minor->dev;
905 drm_i915_private_t *dev_priv = dev->dev_private;
906 u32 delayfreq;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700907 int ret, i;
908
909 ret = mutex_lock_interruptible(&dev->struct_mutex);
910 if (ret)
911 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800912
913 for (i = 0; i < 16; i++) {
914 delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700915 seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
916 (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800917 }
918
Ben Widawsky616fdb52011-10-05 11:44:54 -0700919 mutex_unlock(&dev->struct_mutex);
920
Jesse Barnesf97108d2010-01-29 11:27:07 -0800921 return 0;
922}
923
924static inline int MAP_TO_MV(int map)
925{
926 return 1250 - (map * 25);
927}
928
929static int i915_inttoext_table(struct seq_file *m, void *unused)
930{
931 struct drm_info_node *node = (struct drm_info_node *) m->private;
932 struct drm_device *dev = node->minor->dev;
933 drm_i915_private_t *dev_priv = dev->dev_private;
934 u32 inttoext;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700935 int ret, i;
936
937 ret = mutex_lock_interruptible(&dev->struct_mutex);
938 if (ret)
939 return ret;
Jesse Barnesf97108d2010-01-29 11:27:07 -0800940
941 for (i = 1; i <= 32; i++) {
942 inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
943 seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
944 }
945
Ben Widawsky616fdb52011-10-05 11:44:54 -0700946 mutex_unlock(&dev->struct_mutex);
947
Jesse Barnesf97108d2010-01-29 11:27:07 -0800948 return 0;
949}
950
Ben Widawsky4d855292011-12-12 19:34:16 -0800951static int ironlake_drpc_info(struct seq_file *m)
Jesse Barnesf97108d2010-01-29 11:27:07 -0800952{
953 struct drm_info_node *node = (struct drm_info_node *) m->private;
954 struct drm_device *dev = node->minor->dev;
955 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -0700956 u32 rgvmodectl, rstdbyctl;
957 u16 crstandvid;
958 int ret;
959
960 ret = mutex_lock_interruptible(&dev->struct_mutex);
961 if (ret)
962 return ret;
963
964 rgvmodectl = I915_READ(MEMMODECTL);
965 rstdbyctl = I915_READ(RSTDBYCTL);
966 crstandvid = I915_READ16(CRSTANDVID);
967
968 mutex_unlock(&dev->struct_mutex);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800969
970 seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
971 "yes" : "no");
972 seq_printf(m, "Boost freq: %d\n",
973 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
974 MEMMODE_BOOST_FREQ_SHIFT);
975 seq_printf(m, "HW control enabled: %s\n",
976 rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
977 seq_printf(m, "SW control enabled: %s\n",
978 rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
979 seq_printf(m, "Gated voltage change: %s\n",
980 rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
981 seq_printf(m, "Starting frequency: P%d\n",
982 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700983 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -0800984 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700985 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
986 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
987 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
988 seq_printf(m, "Render standby enabled: %s\n",
989 (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
Jesse Barnes88271da2011-01-05 12:01:24 -0800990 seq_printf(m, "Current RS state: ");
991 switch (rstdbyctl & RSX_STATUS_MASK) {
992 case RSX_STATUS_ON:
993 seq_printf(m, "on\n");
994 break;
995 case RSX_STATUS_RC1:
996 seq_printf(m, "RC1\n");
997 break;
998 case RSX_STATUS_RC1E:
999 seq_printf(m, "RC1E\n");
1000 break;
1001 case RSX_STATUS_RS1:
1002 seq_printf(m, "RS1\n");
1003 break;
1004 case RSX_STATUS_RS2:
1005 seq_printf(m, "RS2 (RC6)\n");
1006 break;
1007 case RSX_STATUS_RS3:
1008 seq_printf(m, "RC3 (RC6+)\n");
1009 break;
1010 default:
1011 seq_printf(m, "unknown\n");
1012 break;
1013 }
Jesse Barnesf97108d2010-01-29 11:27:07 -08001014
1015 return 0;
1016}
1017
Ben Widawsky4d855292011-12-12 19:34:16 -08001018static int gen6_drpc_info(struct seq_file *m)
1019{
1020
1021 struct drm_info_node *node = (struct drm_info_node *) m->private;
1022 struct drm_device *dev = node->minor->dev;
1023 struct drm_i915_private *dev_priv = dev->dev_private;
1024 u32 rpmodectl1, gt_core_status, rcctl1;
Daniel Vetter93b525d2012-01-25 13:52:43 +01001025 unsigned forcewake_count;
Ben Widawsky4d855292011-12-12 19:34:16 -08001026 int count=0, ret;
1027
1028
1029 ret = mutex_lock_interruptible(&dev->struct_mutex);
1030 if (ret)
1031 return ret;
1032
Daniel Vetter93b525d2012-01-25 13:52:43 +01001033 spin_lock_irq(&dev_priv->gt_lock);
1034 forcewake_count = dev_priv->forcewake_count;
1035 spin_unlock_irq(&dev_priv->gt_lock);
1036
1037 if (forcewake_count) {
1038 seq_printf(m, "RC information inaccurate because somebody "
1039 "holds a forcewake reference \n");
Ben Widawsky4d855292011-12-12 19:34:16 -08001040 } else {
1041 /* NB: we cannot use forcewake, else we read the wrong values */
1042 while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
1043 udelay(10);
1044 seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
1045 }
1046
1047 gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS);
1048 trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4);
1049
1050 rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
1051 rcctl1 = I915_READ(GEN6_RC_CONTROL);
1052 mutex_unlock(&dev->struct_mutex);
1053
1054 seq_printf(m, "Video Turbo Mode: %s\n",
1055 yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
1056 seq_printf(m, "HW control enabled: %s\n",
1057 yesno(rpmodectl1 & GEN6_RP_ENABLE));
1058 seq_printf(m, "SW control enabled: %s\n",
1059 yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
1060 GEN6_RP_MEDIA_SW_MODE));
Eric Anholtfff24e22012-01-23 16:14:05 -08001061 seq_printf(m, "RC1e Enabled: %s\n",
Ben Widawsky4d855292011-12-12 19:34:16 -08001062 yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
1063 seq_printf(m, "RC6 Enabled: %s\n",
1064 yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
1065 seq_printf(m, "Deep RC6 Enabled: %s\n",
1066 yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
1067 seq_printf(m, "Deepest RC6 Enabled: %s\n",
1068 yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
1069 seq_printf(m, "Current RC state: ");
1070 switch (gt_core_status & GEN6_RCn_MASK) {
1071 case GEN6_RC0:
1072 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
1073 seq_printf(m, "Core Power Down\n");
1074 else
1075 seq_printf(m, "on\n");
1076 break;
1077 case GEN6_RC3:
1078 seq_printf(m, "RC3\n");
1079 break;
1080 case GEN6_RC6:
1081 seq_printf(m, "RC6\n");
1082 break;
1083 case GEN6_RC7:
1084 seq_printf(m, "RC7\n");
1085 break;
1086 default:
1087 seq_printf(m, "Unknown\n");
1088 break;
1089 }
1090
1091 seq_printf(m, "Core Power Down: %s\n",
1092 yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
Ben Widawskycce66a22012-03-27 18:59:38 -07001093
1094 /* Not exactly sure what this is */
1095 seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
1096 I915_READ(GEN6_GT_GFX_RC6_LOCKED));
1097 seq_printf(m, "RC6 residency since boot: %u\n",
1098 I915_READ(GEN6_GT_GFX_RC6));
1099 seq_printf(m, "RC6+ residency since boot: %u\n",
1100 I915_READ(GEN6_GT_GFX_RC6p));
1101 seq_printf(m, "RC6++ residency since boot: %u\n",
1102 I915_READ(GEN6_GT_GFX_RC6pp));
1103
Ben Widawsky4d855292011-12-12 19:34:16 -08001104 return 0;
1105}
1106
1107static int i915_drpc_info(struct seq_file *m, void *unused)
1108{
1109 struct drm_info_node *node = (struct drm_info_node *) m->private;
1110 struct drm_device *dev = node->minor->dev;
1111
1112 if (IS_GEN6(dev) || IS_GEN7(dev))
1113 return gen6_drpc_info(m);
1114 else
1115 return ironlake_drpc_info(m);
1116}
1117
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001118static int i915_fbc_status(struct seq_file *m, void *unused)
1119{
1120 struct drm_info_node *node = (struct drm_info_node *) m->private;
1121 struct drm_device *dev = node->minor->dev;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001122 drm_i915_private_t *dev_priv = dev->dev_private;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001123
Adam Jacksonee5382a2010-04-23 11:17:39 -04001124 if (!I915_HAS_FBC(dev)) {
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001125 seq_printf(m, "FBC unsupported on this chipset\n");
1126 return 0;
1127 }
1128
Adam Jacksonee5382a2010-04-23 11:17:39 -04001129 if (intel_fbc_enabled(dev)) {
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001130 seq_printf(m, "FBC enabled\n");
1131 } else {
1132 seq_printf(m, "FBC disabled: ");
1133 switch (dev_priv->no_fbc_reason) {
Chris Wilsonbed4a672010-09-11 10:47:47 +01001134 case FBC_NO_OUTPUT:
1135 seq_printf(m, "no outputs");
1136 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001137 case FBC_STOLEN_TOO_SMALL:
1138 seq_printf(m, "not enough stolen memory");
1139 break;
1140 case FBC_UNSUPPORTED_MODE:
1141 seq_printf(m, "mode not supported");
1142 break;
1143 case FBC_MODE_TOO_LARGE:
1144 seq_printf(m, "mode too large");
1145 break;
1146 case FBC_BAD_PLANE:
1147 seq_printf(m, "FBC unsupported on plane");
1148 break;
1149 case FBC_NOT_TILED:
1150 seq_printf(m, "scanout buffer not tiled");
1151 break;
Jesse Barnes9c928d12010-07-23 15:20:00 -07001152 case FBC_MULTIPLE_PIPES:
1153 seq_printf(m, "multiple pipes are enabled");
1154 break;
Jesse Barnesc1a9f042011-05-05 15:24:21 -07001155 case FBC_MODULE_PARAM:
1156 seq_printf(m, "disabled per module param (default off)");
1157 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001158 default:
1159 seq_printf(m, "unknown reason");
1160 }
1161 seq_printf(m, "\n");
1162 }
1163 return 0;
1164}
1165
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001166static int i915_sr_status(struct seq_file *m, void *unused)
1167{
1168 struct drm_info_node *node = (struct drm_info_node *) m->private;
1169 struct drm_device *dev = node->minor->dev;
1170 drm_i915_private_t *dev_priv = dev->dev_private;
1171 bool sr_enabled = false;
1172
Yuanhan Liu13982612010-12-15 15:42:31 +08001173 if (HAS_PCH_SPLIT(dev))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001174 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Chris Wilsona6c45cf2010-09-17 00:32:17 +01001175 else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001176 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
1177 else if (IS_I915GM(dev))
1178 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
1179 else if (IS_PINEVIEW(dev))
1180 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
1181
Chris Wilson5ba2aaa2010-08-19 18:04:08 +01001182 seq_printf(m, "self-refresh: %s\n",
1183 sr_enabled ? "enabled" : "disabled");
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001184
1185 return 0;
1186}
1187
Jesse Barnes7648fa92010-05-20 14:28:11 -07001188static int i915_emon_status(struct seq_file *m, void *unused)
1189{
1190 struct drm_info_node *node = (struct drm_info_node *) m->private;
1191 struct drm_device *dev = node->minor->dev;
1192 drm_i915_private_t *dev_priv = dev->dev_private;
1193 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +01001194 int ret;
1195
Chris Wilson582be6b2012-04-30 19:35:02 +01001196 if (!IS_GEN5(dev))
1197 return -ENODEV;
1198
Chris Wilsonde227ef2010-07-03 07:58:38 +01001199 ret = mutex_lock_interruptible(&dev->struct_mutex);
1200 if (ret)
1201 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001202
1203 temp = i915_mch_val(dev_priv);
1204 chipset = i915_chipset_val(dev_priv);
1205 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +01001206 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -07001207
1208 seq_printf(m, "GMCH temp: %ld\n", temp);
1209 seq_printf(m, "Chipset power: %ld\n", chipset);
1210 seq_printf(m, "GFX power: %ld\n", gfx);
1211 seq_printf(m, "Total power: %ld\n", chipset + gfx);
1212
1213 return 0;
1214}
1215
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001216static int i915_ring_freq_table(struct seq_file *m, void *unused)
1217{
1218 struct drm_info_node *node = (struct drm_info_node *) m->private;
1219 struct drm_device *dev = node->minor->dev;
1220 drm_i915_private_t *dev_priv = dev->dev_private;
1221 int ret;
1222 int gpu_freq, ia_freq;
1223
Jesse Barnes1c70c0c2011-06-29 13:34:36 -07001224 if (!(IS_GEN6(dev) || IS_GEN7(dev))) {
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001225 seq_printf(m, "unsupported on this chipset\n");
1226 return 0;
1227 }
1228
1229 ret = mutex_lock_interruptible(&dev->struct_mutex);
1230 if (ret)
1231 return ret;
1232
1233 seq_printf(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\n");
1234
1235 for (gpu_freq = dev_priv->min_delay; gpu_freq <= dev_priv->max_delay;
1236 gpu_freq++) {
1237 I915_WRITE(GEN6_PCODE_DATA, gpu_freq);
1238 I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY |
1239 GEN6_PCODE_READ_MIN_FREQ_TABLE);
1240 if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) &
1241 GEN6_PCODE_READY) == 0, 10)) {
1242 DRM_ERROR("pcode read of freq table timed out\n");
1243 continue;
1244 }
1245 ia_freq = I915_READ(GEN6_PCODE_DATA);
1246 seq_printf(m, "%d\t\t%d\n", gpu_freq * 50, ia_freq * 100);
1247 }
1248
1249 mutex_unlock(&dev->struct_mutex);
1250
1251 return 0;
1252}
1253
Jesse Barnes7648fa92010-05-20 14:28:11 -07001254static int i915_gfxec(struct seq_file *m, void *unused)
1255{
1256 struct drm_info_node *node = (struct drm_info_node *) m->private;
1257 struct drm_device *dev = node->minor->dev;
1258 drm_i915_private_t *dev_priv = dev->dev_private;
Ben Widawsky616fdb52011-10-05 11:44:54 -07001259 int ret;
1260
1261 ret = mutex_lock_interruptible(&dev->struct_mutex);
1262 if (ret)
1263 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -07001264
1265 seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
1266
Ben Widawsky616fdb52011-10-05 11:44:54 -07001267 mutex_unlock(&dev->struct_mutex);
1268
Jesse Barnes7648fa92010-05-20 14:28:11 -07001269 return 0;
1270}
1271
Chris Wilson44834a62010-08-19 16:09:23 +01001272static int i915_opregion(struct seq_file *m, void *unused)
1273{
1274 struct drm_info_node *node = (struct drm_info_node *) m->private;
1275 struct drm_device *dev = node->minor->dev;
1276 drm_i915_private_t *dev_priv = dev->dev_private;
1277 struct intel_opregion *opregion = &dev_priv->opregion;
Daniel Vetter0d38f002012-04-21 22:49:10 +02001278 void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL);
Chris Wilson44834a62010-08-19 16:09:23 +01001279 int ret;
1280
Daniel Vetter0d38f002012-04-21 22:49:10 +02001281 if (data == NULL)
1282 return -ENOMEM;
1283
Chris Wilson44834a62010-08-19 16:09:23 +01001284 ret = mutex_lock_interruptible(&dev->struct_mutex);
1285 if (ret)
Daniel Vetter0d38f002012-04-21 22:49:10 +02001286 goto out;
Chris Wilson44834a62010-08-19 16:09:23 +01001287
Daniel Vetter0d38f002012-04-21 22:49:10 +02001288 if (opregion->header) {
1289 memcpy_fromio(data, opregion->header, OPREGION_SIZE);
1290 seq_write(m, data, OPREGION_SIZE);
1291 }
Chris Wilson44834a62010-08-19 16:09:23 +01001292
1293 mutex_unlock(&dev->struct_mutex);
1294
Daniel Vetter0d38f002012-04-21 22:49:10 +02001295out:
1296 kfree(data);
Chris Wilson44834a62010-08-19 16:09:23 +01001297 return 0;
1298}
1299
Chris Wilson37811fc2010-08-25 22:45:57 +01001300static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
1301{
1302 struct drm_info_node *node = (struct drm_info_node *) m->private;
1303 struct drm_device *dev = node->minor->dev;
1304 drm_i915_private_t *dev_priv = dev->dev_private;
1305 struct intel_fbdev *ifbdev;
1306 struct intel_framebuffer *fb;
1307 int ret;
1308
1309 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
1310 if (ret)
1311 return ret;
1312
1313 ifbdev = dev_priv->fbdev;
1314 fb = to_intel_framebuffer(ifbdev->helper.fb);
1315
1316 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
1317 fb->base.width,
1318 fb->base.height,
1319 fb->base.depth,
1320 fb->base.bits_per_pixel);
Chris Wilson05394f32010-11-08 19:18:58 +00001321 describe_obj(m, fb->obj);
Chris Wilson37811fc2010-08-25 22:45:57 +01001322 seq_printf(m, "\n");
1323
1324 list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
1325 if (&fb->base == ifbdev->helper.fb)
1326 continue;
1327
1328 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ",
1329 fb->base.width,
1330 fb->base.height,
1331 fb->base.depth,
1332 fb->base.bits_per_pixel);
Chris Wilson05394f32010-11-08 19:18:58 +00001333 describe_obj(m, fb->obj);
Chris Wilson37811fc2010-08-25 22:45:57 +01001334 seq_printf(m, "\n");
1335 }
1336
1337 mutex_unlock(&dev->mode_config.mutex);
1338
1339 return 0;
1340}
1341
Ben Widawskye76d3632011-03-19 18:14:29 -07001342static int i915_context_status(struct seq_file *m, void *unused)
1343{
1344 struct drm_info_node *node = (struct drm_info_node *) m->private;
1345 struct drm_device *dev = node->minor->dev;
1346 drm_i915_private_t *dev_priv = dev->dev_private;
1347 int ret;
1348
1349 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
1350 if (ret)
1351 return ret;
1352
Ben Widawskydc501fb2011-06-29 11:41:51 -07001353 if (dev_priv->pwrctx) {
1354 seq_printf(m, "power context ");
1355 describe_obj(m, dev_priv->pwrctx);
1356 seq_printf(m, "\n");
1357 }
Ben Widawskye76d3632011-03-19 18:14:29 -07001358
Ben Widawskydc501fb2011-06-29 11:41:51 -07001359 if (dev_priv->renderctx) {
1360 seq_printf(m, "render context ");
1361 describe_obj(m, dev_priv->renderctx);
1362 seq_printf(m, "\n");
1363 }
Ben Widawskye76d3632011-03-19 18:14:29 -07001364
1365 mutex_unlock(&dev->mode_config.mutex);
1366
1367 return 0;
1368}
1369
Ben Widawsky6d794d42011-04-25 11:25:56 -07001370static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
1371{
1372 struct drm_info_node *node = (struct drm_info_node *) m->private;
1373 struct drm_device *dev = node->minor->dev;
1374 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter9f1f46a2011-12-14 13:57:03 +01001375 unsigned forcewake_count;
Ben Widawsky6d794d42011-04-25 11:25:56 -07001376
Daniel Vetter9f1f46a2011-12-14 13:57:03 +01001377 spin_lock_irq(&dev_priv->gt_lock);
1378 forcewake_count = dev_priv->forcewake_count;
1379 spin_unlock_irq(&dev_priv->gt_lock);
1380
1381 seq_printf(m, "forcewake count = %u\n", forcewake_count);
Ben Widawsky6d794d42011-04-25 11:25:56 -07001382
1383 return 0;
1384}
1385
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001386static const char *swizzle_string(unsigned swizzle)
1387{
1388 switch(swizzle) {
1389 case I915_BIT_6_SWIZZLE_NONE:
1390 return "none";
1391 case I915_BIT_6_SWIZZLE_9:
1392 return "bit9";
1393 case I915_BIT_6_SWIZZLE_9_10:
1394 return "bit9/bit10";
1395 case I915_BIT_6_SWIZZLE_9_11:
1396 return "bit9/bit11";
1397 case I915_BIT_6_SWIZZLE_9_10_11:
1398 return "bit9/bit10/bit11";
1399 case I915_BIT_6_SWIZZLE_9_17:
1400 return "bit9/bit17";
1401 case I915_BIT_6_SWIZZLE_9_10_17:
1402 return "bit9/bit10/bit17";
1403 case I915_BIT_6_SWIZZLE_UNKNOWN:
1404 return "unkown";
1405 }
1406
1407 return "bug";
1408}
1409
1410static int i915_swizzle_info(struct seq_file *m, void *data)
1411{
1412 struct drm_info_node *node = (struct drm_info_node *) m->private;
1413 struct drm_device *dev = node->minor->dev;
1414 struct drm_i915_private *dev_priv = dev->dev_private;
1415
1416 mutex_lock(&dev->struct_mutex);
1417 seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
1418 swizzle_string(dev_priv->mm.bit_6_swizzle_x));
1419 seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
1420 swizzle_string(dev_priv->mm.bit_6_swizzle_y));
1421
1422 if (IS_GEN3(dev) || IS_GEN4(dev)) {
1423 seq_printf(m, "DDC = 0x%08x\n",
1424 I915_READ(DCC));
1425 seq_printf(m, "C0DRB3 = 0x%04x\n",
1426 I915_READ16(C0DRB3));
1427 seq_printf(m, "C1DRB3 = 0x%04x\n",
1428 I915_READ16(C1DRB3));
Daniel Vetter3fa7d232012-01-31 16:47:56 +01001429 } else if (IS_GEN6(dev) || IS_GEN7(dev)) {
1430 seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
1431 I915_READ(MAD_DIMM_C0));
1432 seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
1433 I915_READ(MAD_DIMM_C1));
1434 seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
1435 I915_READ(MAD_DIMM_C2));
1436 seq_printf(m, "TILECTL = 0x%08x\n",
1437 I915_READ(TILECTL));
1438 seq_printf(m, "ARB_MODE = 0x%08x\n",
1439 I915_READ(ARB_MODE));
1440 seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
1441 I915_READ(DISP_ARB_CTL));
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001442 }
1443 mutex_unlock(&dev->struct_mutex);
1444
1445 return 0;
1446}
1447
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001448static int i915_ppgtt_info(struct seq_file *m, void *data)
1449{
1450 struct drm_info_node *node = (struct drm_info_node *) m->private;
1451 struct drm_device *dev = node->minor->dev;
1452 struct drm_i915_private *dev_priv = dev->dev_private;
1453 struct intel_ring_buffer *ring;
1454 int i, ret;
1455
1456
1457 ret = mutex_lock_interruptible(&dev->struct_mutex);
1458 if (ret)
1459 return ret;
1460 if (INTEL_INFO(dev)->gen == 6)
1461 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
1462
1463 for (i = 0; i < I915_NUM_RINGS; i++) {
1464 ring = &dev_priv->ring[i];
1465
1466 seq_printf(m, "%s\n", ring->name);
1467 if (INTEL_INFO(dev)->gen == 7)
1468 seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring)));
1469 seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring)));
1470 seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring)));
1471 seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring)));
1472 }
1473 if (dev_priv->mm.aliasing_ppgtt) {
1474 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
1475
1476 seq_printf(m, "aliasing PPGTT:\n");
1477 seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset);
1478 }
1479 seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
1480 mutex_unlock(&dev->struct_mutex);
1481
1482 return 0;
1483}
1484
Jesse Barnes57f350b2012-03-28 13:39:25 -07001485static int i915_dpio_info(struct seq_file *m, void *data)
1486{
1487 struct drm_info_node *node = (struct drm_info_node *) m->private;
1488 struct drm_device *dev = node->minor->dev;
1489 struct drm_i915_private *dev_priv = dev->dev_private;
1490 int ret;
1491
1492
1493 if (!IS_VALLEYVIEW(dev)) {
1494 seq_printf(m, "unsupported\n");
1495 return 0;
1496 }
1497
1498 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
1499 if (ret)
1500 return ret;
1501
1502 seq_printf(m, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL));
1503
1504 seq_printf(m, "DPIO_DIV_A: 0x%08x\n",
1505 intel_dpio_read(dev_priv, _DPIO_DIV_A));
1506 seq_printf(m, "DPIO_DIV_B: 0x%08x\n",
1507 intel_dpio_read(dev_priv, _DPIO_DIV_B));
1508
1509 seq_printf(m, "DPIO_REFSFR_A: 0x%08x\n",
1510 intel_dpio_read(dev_priv, _DPIO_REFSFR_A));
1511 seq_printf(m, "DPIO_REFSFR_B: 0x%08x\n",
1512 intel_dpio_read(dev_priv, _DPIO_REFSFR_B));
1513
1514 seq_printf(m, "DPIO_CORE_CLK_A: 0x%08x\n",
1515 intel_dpio_read(dev_priv, _DPIO_CORE_CLK_A));
1516 seq_printf(m, "DPIO_CORE_CLK_B: 0x%08x\n",
1517 intel_dpio_read(dev_priv, _DPIO_CORE_CLK_B));
1518
1519 seq_printf(m, "DPIO_LFP_COEFF_A: 0x%08x\n",
1520 intel_dpio_read(dev_priv, _DPIO_LFP_COEFF_A));
1521 seq_printf(m, "DPIO_LFP_COEFF_B: 0x%08x\n",
1522 intel_dpio_read(dev_priv, _DPIO_LFP_COEFF_B));
1523
1524 seq_printf(m, "DPIO_FASTCLK_DISABLE: 0x%08x\n",
1525 intel_dpio_read(dev_priv, DPIO_FASTCLK_DISABLE));
1526
1527 mutex_unlock(&dev->mode_config.mutex);
1528
1529 return 0;
1530}
1531
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001532static ssize_t
1533i915_wedged_read(struct file *filp,
1534 char __user *ubuf,
1535 size_t max,
1536 loff_t *ppos)
1537{
1538 struct drm_device *dev = filp->private_data;
1539 drm_i915_private_t *dev_priv = dev->dev_private;
1540 char buf[80];
1541 int len;
1542
Akshay Joshi0206e352011-08-16 15:34:10 -04001543 len = snprintf(buf, sizeof(buf),
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001544 "wedged : %d\n",
1545 atomic_read(&dev_priv->mm.wedged));
1546
Akshay Joshi0206e352011-08-16 15:34:10 -04001547 if (len > sizeof(buf))
1548 len = sizeof(buf);
Dan Carpenterf4433a82010-09-08 21:44:47 +02001549
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001550 return simple_read_from_buffer(ubuf, max, ppos, buf, len);
1551}
1552
1553static ssize_t
1554i915_wedged_write(struct file *filp,
1555 const char __user *ubuf,
1556 size_t cnt,
1557 loff_t *ppos)
1558{
1559 struct drm_device *dev = filp->private_data;
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001560 char buf[20];
1561 int val = 1;
1562
1563 if (cnt > 0) {
Akshay Joshi0206e352011-08-16 15:34:10 -04001564 if (cnt > sizeof(buf) - 1)
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001565 return -EINVAL;
1566
1567 if (copy_from_user(buf, ubuf, cnt))
1568 return -EFAULT;
1569 buf[cnt] = 0;
1570
1571 val = simple_strtoul(buf, NULL, 0);
1572 }
1573
1574 DRM_INFO("Manually setting wedged to %d\n", val);
Chris Wilson527f9e92010-11-11 01:16:58 +00001575 i915_handle_error(dev, val);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001576
1577 return cnt;
1578}
1579
1580static const struct file_operations i915_wedged_fops = {
1581 .owner = THIS_MODULE,
Stephen Boyd234e3402012-04-05 14:25:11 -07001582 .open = simple_open,
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001583 .read = i915_wedged_read,
1584 .write = i915_wedged_write,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001585 .llseek = default_llseek,
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001586};
1587
Jesse Barnes358733e2011-07-27 11:53:01 -07001588static ssize_t
1589i915_max_freq_read(struct file *filp,
1590 char __user *ubuf,
1591 size_t max,
1592 loff_t *ppos)
1593{
1594 struct drm_device *dev = filp->private_data;
1595 drm_i915_private_t *dev_priv = dev->dev_private;
1596 char buf[80];
1597 int len;
1598
Akshay Joshi0206e352011-08-16 15:34:10 -04001599 len = snprintf(buf, sizeof(buf),
Jesse Barnes358733e2011-07-27 11:53:01 -07001600 "max freq: %d\n", dev_priv->max_delay * 50);
1601
Akshay Joshi0206e352011-08-16 15:34:10 -04001602 if (len > sizeof(buf))
1603 len = sizeof(buf);
Jesse Barnes358733e2011-07-27 11:53:01 -07001604
1605 return simple_read_from_buffer(ubuf, max, ppos, buf, len);
1606}
1607
1608static ssize_t
1609i915_max_freq_write(struct file *filp,
1610 const char __user *ubuf,
1611 size_t cnt,
1612 loff_t *ppos)
1613{
1614 struct drm_device *dev = filp->private_data;
1615 struct drm_i915_private *dev_priv = dev->dev_private;
1616 char buf[20];
1617 int val = 1;
1618
1619 if (cnt > 0) {
Akshay Joshi0206e352011-08-16 15:34:10 -04001620 if (cnt > sizeof(buf) - 1)
Jesse Barnes358733e2011-07-27 11:53:01 -07001621 return -EINVAL;
1622
1623 if (copy_from_user(buf, ubuf, cnt))
1624 return -EFAULT;
1625 buf[cnt] = 0;
1626
1627 val = simple_strtoul(buf, NULL, 0);
1628 }
1629
1630 DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val);
1631
1632 /*
1633 * Turbo will still be enabled, but won't go above the set value.
1634 */
1635 dev_priv->max_delay = val / 50;
1636
1637 gen6_set_rps(dev, val / 50);
1638
1639 return cnt;
1640}
1641
1642static const struct file_operations i915_max_freq_fops = {
1643 .owner = THIS_MODULE,
Stephen Boyd234e3402012-04-05 14:25:11 -07001644 .open = simple_open,
Jesse Barnes358733e2011-07-27 11:53:01 -07001645 .read = i915_max_freq_read,
1646 .write = i915_max_freq_write,
1647 .llseek = default_llseek,
1648};
1649
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001650static ssize_t
1651i915_cache_sharing_read(struct file *filp,
1652 char __user *ubuf,
1653 size_t max,
1654 loff_t *ppos)
1655{
1656 struct drm_device *dev = filp->private_data;
1657 drm_i915_private_t *dev_priv = dev->dev_private;
1658 char buf[80];
1659 u32 snpcr;
1660 int len;
1661
1662 mutex_lock(&dev_priv->dev->struct_mutex);
1663 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
1664 mutex_unlock(&dev_priv->dev->struct_mutex);
1665
Akshay Joshi0206e352011-08-16 15:34:10 -04001666 len = snprintf(buf, sizeof(buf),
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001667 "%d\n", (snpcr & GEN6_MBC_SNPCR_MASK) >>
1668 GEN6_MBC_SNPCR_SHIFT);
1669
Akshay Joshi0206e352011-08-16 15:34:10 -04001670 if (len > sizeof(buf))
1671 len = sizeof(buf);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001672
1673 return simple_read_from_buffer(ubuf, max, ppos, buf, len);
1674}
1675
1676static ssize_t
1677i915_cache_sharing_write(struct file *filp,
1678 const char __user *ubuf,
1679 size_t cnt,
1680 loff_t *ppos)
1681{
1682 struct drm_device *dev = filp->private_data;
1683 struct drm_i915_private *dev_priv = dev->dev_private;
1684 char buf[20];
1685 u32 snpcr;
1686 int val = 1;
1687
1688 if (cnt > 0) {
Akshay Joshi0206e352011-08-16 15:34:10 -04001689 if (cnt > sizeof(buf) - 1)
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001690 return -EINVAL;
1691
1692 if (copy_from_user(buf, ubuf, cnt))
1693 return -EFAULT;
1694 buf[cnt] = 0;
1695
1696 val = simple_strtoul(buf, NULL, 0);
1697 }
1698
1699 if (val < 0 || val > 3)
1700 return -EINVAL;
1701
1702 DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val);
1703
1704 /* Update the cache sharing policy here as well */
1705 snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
1706 snpcr &= ~GEN6_MBC_SNPCR_MASK;
1707 snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
1708 I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
1709
1710 return cnt;
1711}
1712
1713static const struct file_operations i915_cache_sharing_fops = {
1714 .owner = THIS_MODULE,
Stephen Boyd234e3402012-04-05 14:25:11 -07001715 .open = simple_open,
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001716 .read = i915_cache_sharing_read,
1717 .write = i915_cache_sharing_write,
1718 .llseek = default_llseek,
1719};
1720
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001721/* As the drm_debugfs_init() routines are called before dev->dev_private is
1722 * allocated we need to hook into the minor for release. */
1723static int
1724drm_add_fake_info_node(struct drm_minor *minor,
1725 struct dentry *ent,
1726 const void *key)
1727{
1728 struct drm_info_node *node;
1729
1730 node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
1731 if (node == NULL) {
1732 debugfs_remove(ent);
1733 return -ENOMEM;
1734 }
1735
1736 node->minor = minor;
1737 node->dent = ent;
1738 node->info_ent = (void *) key;
Marcin Slusarzb3e067c2011-11-09 22:20:35 +01001739
1740 mutex_lock(&minor->debugfs_lock);
1741 list_add(&node->list, &minor->debugfs_list);
1742 mutex_unlock(&minor->debugfs_lock);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001743
1744 return 0;
1745}
1746
Ben Widawsky6d794d42011-04-25 11:25:56 -07001747static int i915_forcewake_open(struct inode *inode, struct file *file)
1748{
1749 struct drm_device *dev = inode->i_private;
1750 struct drm_i915_private *dev_priv = dev->dev_private;
1751 int ret;
1752
Daniel Vetter075edca2012-01-24 09:44:28 +01001753 if (INTEL_INFO(dev)->gen < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07001754 return 0;
1755
1756 ret = mutex_lock_interruptible(&dev->struct_mutex);
1757 if (ret)
1758 return ret;
1759 gen6_gt_force_wake_get(dev_priv);
1760 mutex_unlock(&dev->struct_mutex);
1761
1762 return 0;
1763}
1764
Ben Widawskyc43b5632012-04-16 14:07:40 -07001765static int i915_forcewake_release(struct inode *inode, struct file *file)
Ben Widawsky6d794d42011-04-25 11:25:56 -07001766{
1767 struct drm_device *dev = inode->i_private;
1768 struct drm_i915_private *dev_priv = dev->dev_private;
1769
Daniel Vetter075edca2012-01-24 09:44:28 +01001770 if (INTEL_INFO(dev)->gen < 6)
Ben Widawsky6d794d42011-04-25 11:25:56 -07001771 return 0;
1772
1773 /*
1774 * It's bad that we can potentially hang userspace if struct_mutex gets
1775 * forever stuck. However, if we cannot acquire this lock it means that
1776 * almost certainly the driver has hung, is not unload-able. Therefore
1777 * hanging here is probably a minor inconvenience not to be seen my
1778 * almost every user.
1779 */
1780 mutex_lock(&dev->struct_mutex);
1781 gen6_gt_force_wake_put(dev_priv);
1782 mutex_unlock(&dev->struct_mutex);
1783
1784 return 0;
1785}
1786
1787static const struct file_operations i915_forcewake_fops = {
1788 .owner = THIS_MODULE,
1789 .open = i915_forcewake_open,
1790 .release = i915_forcewake_release,
1791};
1792
1793static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
1794{
1795 struct drm_device *dev = minor->dev;
1796 struct dentry *ent;
1797
1798 ent = debugfs_create_file("i915_forcewake_user",
Ben Widawsky8eb57292011-05-11 15:10:58 -07001799 S_IRUSR,
Ben Widawsky6d794d42011-04-25 11:25:56 -07001800 root, dev,
1801 &i915_forcewake_fops);
1802 if (IS_ERR(ent))
1803 return PTR_ERR(ent);
1804
Ben Widawsky8eb57292011-05-11 15:10:58 -07001805 return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
Ben Widawsky6d794d42011-04-25 11:25:56 -07001806}
1807
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001808static int i915_debugfs_create(struct dentry *root,
1809 struct drm_minor *minor,
1810 const char *name,
1811 const struct file_operations *fops)
Jesse Barnes358733e2011-07-27 11:53:01 -07001812{
1813 struct drm_device *dev = minor->dev;
1814 struct dentry *ent;
1815
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001816 ent = debugfs_create_file(name,
Jesse Barnes358733e2011-07-27 11:53:01 -07001817 S_IRUGO | S_IWUSR,
1818 root, dev,
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001819 fops);
Jesse Barnes358733e2011-07-27 11:53:01 -07001820 if (IS_ERR(ent))
1821 return PTR_ERR(ent);
1822
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001823 return drm_add_fake_info_node(minor, ent, fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001824}
1825
Ben Gamari27c202a2009-07-01 22:26:52 -04001826static struct drm_info_list i915_debugfs_list[] = {
Chris Wilson311bd682011-01-13 19:06:50 +00001827 {"i915_capabilities", i915_capabilities, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01001828 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson08c18322011-01-10 00:00:24 +00001829 {"i915_gem_gtt", i915_gem_gtt_info, 0},
Chris Wilson1b502472012-04-24 15:47:30 +01001830 {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05001831 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
1832 {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
1833 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01001834 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001835 {"i915_gem_request", i915_gem_request_info, 0},
1836 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00001837 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001838 {"i915_gem_interrupt", i915_interrupt_info, 0},
Chris Wilson1ec14ad2010-12-04 11:30:53 +00001839 {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
1840 {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
1841 {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
Jesse Barnes63eeaf32009-06-18 16:56:52 -07001842 {"i915_error_state", i915_error_state, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08001843 {"i915_rstdby_delays", i915_rstdby_delays, 0},
1844 {"i915_cur_delayinfo", i915_cur_delayinfo, 0},
1845 {"i915_delayfreq_table", i915_delayfreq_table, 0},
1846 {"i915_inttoext_table", i915_inttoext_table, 0},
1847 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07001848 {"i915_emon_status", i915_emon_status, 0},
Jesse Barnes23b2f8b2011-06-28 13:04:16 -07001849 {"i915_ring_freq_table", i915_ring_freq_table, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07001850 {"i915_gfxec", i915_gfxec, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001851 {"i915_fbc_status", i915_fbc_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001852 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01001853 {"i915_opregion", i915_opregion, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01001854 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Widawskye76d3632011-03-19 18:14:29 -07001855 {"i915_context_status", i915_context_status, 0},
Ben Widawsky6d794d42011-04-25 11:25:56 -07001856 {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
Daniel Vetterea16a3c2011-12-14 13:57:16 +01001857 {"i915_swizzle_info", i915_swizzle_info, 0},
Daniel Vetter3cf17fc2012-02-09 17:15:49 +01001858 {"i915_ppgtt_info", i915_ppgtt_info, 0},
Jesse Barnes57f350b2012-03-28 13:39:25 -07001859 {"i915_dpio", i915_dpio_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001860};
Ben Gamari27c202a2009-07-01 22:26:52 -04001861#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05001862
Ben Gamari27c202a2009-07-01 22:26:52 -04001863int i915_debugfs_init(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05001864{
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001865 int ret;
1866
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001867 ret = i915_debugfs_create(minor->debugfs_root, minor,
1868 "i915_wedged",
1869 &i915_wedged_fops);
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001870 if (ret)
1871 return ret;
1872
Ben Widawsky6d794d42011-04-25 11:25:56 -07001873 ret = i915_forcewake_create(minor->debugfs_root, minor);
1874 if (ret)
1875 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001876
1877 ret = i915_debugfs_create(minor->debugfs_root, minor,
1878 "i915_max_freq",
1879 &i915_max_freq_fops);
Jesse Barnes358733e2011-07-27 11:53:01 -07001880 if (ret)
1881 return ret;
Daniel Vetter6a9c3082011-12-14 13:57:11 +01001882
1883 ret = i915_debugfs_create(minor->debugfs_root, minor,
1884 "i915_cache_sharing",
1885 &i915_cache_sharing_fops);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001886 if (ret)
1887 return ret;
Ben Widawsky6d794d42011-04-25 11:25:56 -07001888
Ben Gamari27c202a2009-07-01 22:26:52 -04001889 return drm_debugfs_create_files(i915_debugfs_list,
1890 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05001891 minor->debugfs_root, minor);
1892}
1893
Ben Gamari27c202a2009-07-01 22:26:52 -04001894void i915_debugfs_cleanup(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05001895{
Ben Gamari27c202a2009-07-01 22:26:52 -04001896 drm_debugfs_remove_files(i915_debugfs_list,
1897 I915_DEBUGFS_ENTRIES, minor);
Ben Widawsky6d794d42011-04-25 11:25:56 -07001898 drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops,
1899 1, minor);
Kristian Høgsberg33db6792009-11-11 12:19:16 -05001900 drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops,
1901 1, minor);
Jesse Barnes358733e2011-07-27 11:53:01 -07001902 drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops,
1903 1, minor);
Jesse Barnes07b7ddd2011-08-03 11:28:44 -07001904 drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops,
1905 1, minor);
Ben Gamari20172632009-02-17 20:08:50 -05001906}
1907
1908#endif /* CONFIG_DEBUG_FS */