blob: 7698983577d1f1cca4db51cdd8b0f3b06a7f3c7f [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>
Ben Gamari20172632009-02-17 20:08:50 -050032#include "drmP.h"
33#include "drm.h"
Simon Farnsworth4e5359c2010-09-01 17:47:52 +010034#include "intel_drv.h"
Ben Gamari20172632009-02-17 20:08:50 -050035#include "i915_drm.h"
36#include "i915_drv.h"
37
38#define DRM_I915_RING_DEBUG 1
39
40
41#if defined(CONFIG_DEBUG_FS)
42
Chris Wilsonf13d3f72010-09-20 17:36:15 +010043enum {
Chris Wilson69dc4982010-10-19 10:36:51 +010044 ACTIVE_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010045 FLUSHING_LIST,
46 INACTIVE_LIST,
Chris Wilsond21d5972010-09-26 11:19:33 +010047 PINNED_LIST,
48 DEFERRED_FREE_LIST,
Chris Wilsonf13d3f72010-09-20 17:36:15 +010049};
Ben Gamari433e12f2009-02-17 20:08:51 -050050
Chris Wilson70d39fe2010-08-25 16:03:34 +010051static const char *yesno(int v)
52{
53 return v ? "yes" : "no";
54}
55
56static int i915_capabilities(struct seq_file *m, void *data)
57{
58 struct drm_info_node *node = (struct drm_info_node *) m->private;
59 struct drm_device *dev = node->minor->dev;
60 const struct intel_device_info *info = INTEL_INFO(dev);
61
62 seq_printf(m, "gen: %d\n", info->gen);
63#define B(x) seq_printf(m, #x ": %s\n", yesno(info->x))
64 B(is_mobile);
Chris Wilson70d39fe2010-08-25 16:03:34 +010065 B(is_i85x);
66 B(is_i915g);
Chris Wilson70d39fe2010-08-25 16:03:34 +010067 B(is_i945gm);
Chris Wilson70d39fe2010-08-25 16:03:34 +010068 B(is_g33);
69 B(need_gfx_hws);
70 B(is_g4x);
71 B(is_pineview);
72 B(is_broadwater);
73 B(is_crestline);
Chris Wilson70d39fe2010-08-25 16:03:34 +010074 B(has_fbc);
75 B(has_rc6);
76 B(has_pipe_cxsr);
77 B(has_hotplug);
78 B(cursor_needs_physical);
79 B(has_overlay);
80 B(overlay_needs_physical);
Chris Wilsona6c45cf2010-09-17 00:32:17 +010081 B(supports_tv);
Chris Wilson549f7362010-10-19 11:19:32 +010082 B(has_bsd_ring);
83 B(has_blt_ring);
Chris Wilson70d39fe2010-08-25 16:03:34 +010084#undef B
85
86 return 0;
87}
88
Chris Wilsona6172a82009-02-11 14:26:38 +000089static const char *get_pin_flag(struct drm_i915_gem_object *obj_priv)
90{
91 if (obj_priv->user_pin_count > 0)
92 return "P";
93 else if (obj_priv->pin_count > 0)
94 return "p";
95 else
96 return " ";
97}
98
99static const char *get_tiling_flag(struct drm_i915_gem_object *obj_priv)
100{
101 switch (obj_priv->tiling_mode) {
102 default:
103 case I915_TILING_NONE: return " ";
104 case I915_TILING_X: return "X";
105 case I915_TILING_Y: return "Y";
106 }
107}
108
Chris Wilson37811fc2010-08-25 22:45:57 +0100109static void
110describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
111{
112 seq_printf(m, "%p: %s%s %8zd %08x %08x %d%s%s",
113 &obj->base,
114 get_pin_flag(obj),
115 get_tiling_flag(obj),
116 obj->base.size,
117 obj->base.read_domains,
118 obj->base.write_domain,
119 obj->last_rendering_seqno,
120 obj->dirty ? " dirty" : "",
121 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
122 if (obj->base.name)
123 seq_printf(m, " (name: %d)", obj->base.name);
124 if (obj->fence_reg != I915_FENCE_REG_NONE)
125 seq_printf(m, " (fence: %d)", obj->fence_reg);
126 if (obj->gtt_space != NULL)
127 seq_printf(m, " (gtt_offset: %08x)", obj->gtt_offset);
Chris Wilson69dc4982010-10-19 10:36:51 +0100128 if (obj->ring != NULL)
129 seq_printf(m, " (%s)", obj->ring->name);
Chris Wilson37811fc2010-08-25 22:45:57 +0100130}
131
Ben Gamari433e12f2009-02-17 20:08:51 -0500132static int i915_gem_object_list_info(struct seq_file *m, void *data)
Ben Gamari20172632009-02-17 20:08:50 -0500133{
134 struct drm_info_node *node = (struct drm_info_node *) m->private;
Ben Gamari433e12f2009-02-17 20:08:51 -0500135 uintptr_t list = (uintptr_t) node->info_ent->data;
136 struct list_head *head;
Ben Gamari20172632009-02-17 20:08:50 -0500137 struct drm_device *dev = node->minor->dev;
138 drm_i915_private_t *dev_priv = dev->dev_private;
139 struct drm_i915_gem_object *obj_priv;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100140 size_t total_obj_size, total_gtt_size;
141 int count, ret;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100142
143 ret = mutex_lock_interruptible(&dev->struct_mutex);
144 if (ret)
145 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500146
Ben Gamari433e12f2009-02-17 20:08:51 -0500147 switch (list) {
Chris Wilson69dc4982010-10-19 10:36:51 +0100148 case ACTIVE_LIST:
149 seq_printf(m, "Active:\n");
150 head = &dev_priv->mm.active_list;
Chris Wilson82690bb2010-09-18 01:37:30 +0100151 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500152 case INACTIVE_LIST:
Ben Gamaria17458f2009-07-01 15:01:36 -0400153 seq_printf(m, "Inactive:\n");
Ben Gamari433e12f2009-02-17 20:08:51 -0500154 head = &dev_priv->mm.inactive_list;
155 break;
Chris Wilsonf13d3f72010-09-20 17:36:15 +0100156 case PINNED_LIST:
157 seq_printf(m, "Pinned:\n");
158 head = &dev_priv->mm.pinned_list;
159 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500160 case FLUSHING_LIST:
161 seq_printf(m, "Flushing:\n");
162 head = &dev_priv->mm.flushing_list;
163 break;
Chris Wilsond21d5972010-09-26 11:19:33 +0100164 case DEFERRED_FREE_LIST:
165 seq_printf(m, "Deferred free:\n");
166 head = &dev_priv->mm.deferred_free_list;
167 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500168 default:
Chris Wilsonde227ef2010-07-03 07:58:38 +0100169 mutex_unlock(&dev->struct_mutex);
170 return -EINVAL;
Ben Gamari433e12f2009-02-17 20:08:51 -0500171 }
172
Chris Wilson8f2480f2010-09-26 11:44:19 +0100173 total_obj_size = total_gtt_size = count = 0;
Chris Wilson69dc4982010-10-19 10:36:51 +0100174 list_for_each_entry(obj_priv, head, mm_list) {
Chris Wilson37811fc2010-08-25 22:45:57 +0100175 seq_printf(m, " ");
176 describe_obj(m, obj_priv);
Eric Anholtf4ceda82009-02-17 23:53:41 -0800177 seq_printf(m, "\n");
Chris Wilson8f2480f2010-09-26 11:44:19 +0100178 total_obj_size += obj_priv->base.size;
179 total_gtt_size += obj_priv->gtt_space->size;
180 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500181 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100182 mutex_unlock(&dev->struct_mutex);
Chris Wilson8f2480f2010-09-26 11:44:19 +0100183
184 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
185 count, total_obj_size, total_gtt_size);
Ben Gamari20172632009-02-17 20:08:50 -0500186 return 0;
187}
188
Chris Wilson73aa8082010-09-30 11:46:12 +0100189static int i915_gem_object_info(struct seq_file *m, void* data)
190{
191 struct drm_info_node *node = (struct drm_info_node *) m->private;
192 struct drm_device *dev = node->minor->dev;
193 struct drm_i915_private *dev_priv = dev->dev_private;
194 int ret;
195
196 ret = mutex_lock_interruptible(&dev->struct_mutex);
197 if (ret)
198 return ret;
199
200 seq_printf(m, "%u objects\n", dev_priv->mm.object_count);
201 seq_printf(m, "%zu object bytes\n", dev_priv->mm.object_memory);
202 seq_printf(m, "%u pinned\n", dev_priv->mm.pin_count);
203 seq_printf(m, "%zu pin bytes\n", dev_priv->mm.pin_memory);
204 seq_printf(m, "%u objects in gtt\n", dev_priv->mm.gtt_count);
205 seq_printf(m, "%zu gtt bytes\n", dev_priv->mm.gtt_memory);
206 seq_printf(m, "%zu gtt total\n", dev_priv->mm.gtt_total);
207
208 mutex_unlock(&dev->struct_mutex);
209
210 return 0;
211}
212
213
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100214static int i915_gem_pageflip_info(struct seq_file *m, void *data)
215{
216 struct drm_info_node *node = (struct drm_info_node *) m->private;
217 struct drm_device *dev = node->minor->dev;
218 unsigned long flags;
219 struct intel_crtc *crtc;
220
221 list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
222 const char *pipe = crtc->pipe ? "B" : "A";
223 const char *plane = crtc->plane ? "B" : "A";
224 struct intel_unpin_work *work;
225
226 spin_lock_irqsave(&dev->event_lock, flags);
227 work = crtc->unpin_work;
228 if (work == NULL) {
229 seq_printf(m, "No flip due on pipe %s (plane %s)\n",
230 pipe, plane);
231 } else {
232 if (!work->pending) {
233 seq_printf(m, "Flip queued on pipe %s (plane %s)\n",
234 pipe, plane);
235 } else {
236 seq_printf(m, "Flip pending (waiting for vsync) on pipe %s (plane %s)\n",
237 pipe, plane);
238 }
239 if (work->enable_stall_check)
240 seq_printf(m, "Stall check enabled, ");
241 else
242 seq_printf(m, "Stall check waiting for page flip ioctl, ");
243 seq_printf(m, "%d prepares\n", work->pending);
244
245 if (work->old_fb_obj) {
246 struct drm_i915_gem_object *obj_priv = to_intel_bo(work->old_fb_obj);
247 if(obj_priv)
248 seq_printf(m, "Old framebuffer gtt_offset 0x%08x\n", obj_priv->gtt_offset );
249 }
250 if (work->pending_flip_obj) {
251 struct drm_i915_gem_object *obj_priv = to_intel_bo(work->pending_flip_obj);
252 if(obj_priv)
253 seq_printf(m, "New framebuffer gtt_offset 0x%08x\n", obj_priv->gtt_offset );
254 }
255 }
256 spin_unlock_irqrestore(&dev->event_lock, flags);
257 }
258
259 return 0;
260}
261
Ben Gamari20172632009-02-17 20:08:50 -0500262static int i915_gem_request_info(struct seq_file *m, void *data)
263{
264 struct drm_info_node *node = (struct drm_info_node *) m->private;
265 struct drm_device *dev = node->minor->dev;
266 drm_i915_private_t *dev_priv = dev->dev_private;
267 struct drm_i915_gem_request *gem_request;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100268 int ret;
269
270 ret = mutex_lock_interruptible(&dev->struct_mutex);
271 if (ret)
272 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500273
274 seq_printf(m, "Request:\n");
Zou Nan hai852835f2010-05-21 09:08:56 +0800275 list_for_each_entry(gem_request, &dev_priv->render_ring.request_list,
276 list) {
Ben Gamari20172632009-02-17 20:08:50 -0500277 seq_printf(m, " %d @ %d\n",
278 gem_request->seqno,
279 (int) (jiffies - gem_request->emitted_jiffies));
280 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100281 mutex_unlock(&dev->struct_mutex);
282
Ben Gamari20172632009-02-17 20:08:50 -0500283 return 0;
284}
285
286static int i915_gem_seqno_info(struct seq_file *m, void *data)
287{
288 struct drm_info_node *node = (struct drm_info_node *) m->private;
289 struct drm_device *dev = node->minor->dev;
290 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100291 int ret;
292
293 ret = mutex_lock_interruptible(&dev->struct_mutex);
294 if (ret)
295 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500296
Eric Anholte20f9c62010-05-26 14:51:06 -0700297 if (dev_priv->render_ring.status_page.page_addr != NULL) {
Ben Gamari20172632009-02-17 20:08:50 -0500298 seq_printf(m, "Current sequence: %d\n",
Chris Wilsonf787a5f2010-09-24 16:02:42 +0100299 dev_priv->render_ring.get_seqno(dev, &dev_priv->render_ring));
Ben Gamari20172632009-02-17 20:08:50 -0500300 } else {
301 seq_printf(m, "Current sequence: hws uninitialized\n");
302 }
303 seq_printf(m, "Waiter sequence: %d\n",
304 dev_priv->mm.waiting_gem_seqno);
305 seq_printf(m, "IRQ sequence: %d\n", dev_priv->mm.irq_gem_seqno);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100306
307 mutex_unlock(&dev->struct_mutex);
308
Ben Gamari20172632009-02-17 20:08:50 -0500309 return 0;
310}
311
312
313static int i915_interrupt_info(struct seq_file *m, void *data)
314{
315 struct drm_info_node *node = (struct drm_info_node *) m->private;
316 struct drm_device *dev = node->minor->dev;
317 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100318 int ret;
319
320 ret = mutex_lock_interruptible(&dev->struct_mutex);
321 if (ret)
322 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500323
Eric Anholtbad720f2009-10-22 16:11:14 -0700324 if (!HAS_PCH_SPLIT(dev)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800325 seq_printf(m, "Interrupt enable: %08x\n",
326 I915_READ(IER));
327 seq_printf(m, "Interrupt identity: %08x\n",
328 I915_READ(IIR));
329 seq_printf(m, "Interrupt mask: %08x\n",
330 I915_READ(IMR));
331 seq_printf(m, "Pipe A stat: %08x\n",
332 I915_READ(PIPEASTAT));
333 seq_printf(m, "Pipe B stat: %08x\n",
334 I915_READ(PIPEBSTAT));
335 } else {
336 seq_printf(m, "North Display Interrupt enable: %08x\n",
337 I915_READ(DEIER));
338 seq_printf(m, "North Display Interrupt identity: %08x\n",
339 I915_READ(DEIIR));
340 seq_printf(m, "North Display Interrupt mask: %08x\n",
341 I915_READ(DEIMR));
342 seq_printf(m, "South Display Interrupt enable: %08x\n",
343 I915_READ(SDEIER));
344 seq_printf(m, "South Display Interrupt identity: %08x\n",
345 I915_READ(SDEIIR));
346 seq_printf(m, "South Display Interrupt mask: %08x\n",
347 I915_READ(SDEIMR));
348 seq_printf(m, "Graphics Interrupt enable: %08x\n",
349 I915_READ(GTIER));
350 seq_printf(m, "Graphics Interrupt identity: %08x\n",
351 I915_READ(GTIIR));
352 seq_printf(m, "Graphics Interrupt mask: %08x\n",
353 I915_READ(GTIMR));
354 }
Ben Gamari20172632009-02-17 20:08:50 -0500355 seq_printf(m, "Interrupts received: %d\n",
356 atomic_read(&dev_priv->irq_received));
Eric Anholte20f9c62010-05-26 14:51:06 -0700357 if (dev_priv->render_ring.status_page.page_addr != NULL) {
Ben Gamari20172632009-02-17 20:08:50 -0500358 seq_printf(m, "Current sequence: %d\n",
Chris Wilsonf787a5f2010-09-24 16:02:42 +0100359 dev_priv->render_ring.get_seqno(dev, &dev_priv->render_ring));
Ben Gamari20172632009-02-17 20:08:50 -0500360 } else {
361 seq_printf(m, "Current sequence: hws uninitialized\n");
362 }
363 seq_printf(m, "Waiter sequence: %d\n",
364 dev_priv->mm.waiting_gem_seqno);
365 seq_printf(m, "IRQ sequence: %d\n",
366 dev_priv->mm.irq_gem_seqno);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100367 mutex_unlock(&dev->struct_mutex);
368
Ben Gamari20172632009-02-17 20:08:50 -0500369 return 0;
370}
371
Chris Wilsona6172a82009-02-11 14:26:38 +0000372static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
373{
374 struct drm_info_node *node = (struct drm_info_node *) m->private;
375 struct drm_device *dev = node->minor->dev;
376 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100377 int i, ret;
378
379 ret = mutex_lock_interruptible(&dev->struct_mutex);
380 if (ret)
381 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000382
383 seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
384 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
385 for (i = 0; i < dev_priv->num_fence_regs; i++) {
386 struct drm_gem_object *obj = dev_priv->fence_regs[i].obj;
387
388 if (obj == NULL) {
389 seq_printf(m, "Fenced object[%2d] = unused\n", i);
390 } else {
391 struct drm_i915_gem_object *obj_priv;
392
Daniel Vetter23010e42010-03-08 13:35:02 +0100393 obj_priv = to_intel_bo(obj);
Chris Wilsona6172a82009-02-11 14:26:38 +0000394 seq_printf(m, "Fenced object[%2d] = %p: %s "
Linus Torvalds0b4d5692009-03-27 17:02:09 -0700395 "%08x %08zx %08x %s %08x %08x %d",
Chris Wilsona6172a82009-02-11 14:26:38 +0000396 i, obj, get_pin_flag(obj_priv),
397 obj_priv->gtt_offset,
398 obj->size, obj_priv->stride,
399 get_tiling_flag(obj_priv),
400 obj->read_domains, obj->write_domain,
401 obj_priv->last_rendering_seqno);
402 if (obj->name)
403 seq_printf(m, " (name: %d)", obj->name);
404 seq_printf(m, "\n");
405 }
406 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100407 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000408
409 return 0;
410}
411
Ben Gamari20172632009-02-17 20:08:50 -0500412static int i915_hws_info(struct seq_file *m, void *data)
413{
414 struct drm_info_node *node = (struct drm_info_node *) m->private;
415 struct drm_device *dev = node->minor->dev;
416 drm_i915_private_t *dev_priv = dev->dev_private;
417 int i;
418 volatile u32 *hws;
419
Eric Anholte20f9c62010-05-26 14:51:06 -0700420 hws = (volatile u32 *)dev_priv->render_ring.status_page.page_addr;
Ben Gamari20172632009-02-17 20:08:50 -0500421 if (hws == NULL)
422 return 0;
423
424 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
425 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
426 i * 4,
427 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
428 }
429 return 0;
430}
431
Chris Wilson5cdf5882010-09-27 15:51:07 +0100432static void i915_dump_object(struct seq_file *m,
433 struct io_mapping *mapping,
434 struct drm_i915_gem_object *obj_priv)
Ben Gamari6911a9b2009-04-02 11:24:54 -0700435{
Chris Wilson5cdf5882010-09-27 15:51:07 +0100436 int page, page_count, i;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700437
Chris Wilson5cdf5882010-09-27 15:51:07 +0100438 page_count = obj_priv->base.size / PAGE_SIZE;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700439 for (page = 0; page < page_count; page++) {
Chris Wilson5cdf5882010-09-27 15:51:07 +0100440 u32 *mem = io_mapping_map_wc(mapping,
441 obj_priv->gtt_offset + page * PAGE_SIZE);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700442 for (i = 0; i < PAGE_SIZE; i += 4)
443 seq_printf(m, "%08x : %08x\n", i, mem[i / 4]);
Chris Wilson5cdf5882010-09-27 15:51:07 +0100444 io_mapping_unmap(mem);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700445 }
446}
447
448static int i915_batchbuffer_info(struct seq_file *m, void *data)
449{
450 struct drm_info_node *node = (struct drm_info_node *) m->private;
451 struct drm_device *dev = node->minor->dev;
452 drm_i915_private_t *dev_priv = dev->dev_private;
453 struct drm_gem_object *obj;
454 struct drm_i915_gem_object *obj_priv;
455 int ret;
456
Chris Wilsonde227ef2010-07-03 07:58:38 +0100457 ret = mutex_lock_interruptible(&dev->struct_mutex);
458 if (ret)
459 return ret;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700460
Chris Wilson69dc4982010-10-19 10:36:51 +0100461 list_for_each_entry(obj_priv, &dev_priv->mm.active_list, mm_list) {
Daniel Vettera8089e82010-04-09 19:05:09 +0000462 obj = &obj_priv->base;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700463 if (obj->read_domains & I915_GEM_DOMAIN_COMMAND) {
Chris Wilson5cdf5882010-09-27 15:51:07 +0100464 seq_printf(m, "--- gtt_offset = 0x%08x\n",
465 obj_priv->gtt_offset);
466 i915_dump_object(m, dev_priv->mm.gtt_mapping, obj_priv);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700467 }
468 }
469
Chris Wilsonde227ef2010-07-03 07:58:38 +0100470 mutex_unlock(&dev->struct_mutex);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700471
472 return 0;
473}
474
475static int i915_ringbuffer_data(struct seq_file *m, void *data)
476{
477 struct drm_info_node *node = (struct drm_info_node *) m->private;
478 struct drm_device *dev = node->minor->dev;
479 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100480 int ret;
481
482 ret = mutex_lock_interruptible(&dev->struct_mutex);
483 if (ret)
484 return ret;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700485
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800486 if (!dev_priv->render_ring.gem_object) {
Ben Gamari6911a9b2009-04-02 11:24:54 -0700487 seq_printf(m, "No ringbuffer setup\n");
Chris Wilsonde227ef2010-07-03 07:58:38 +0100488 } else {
489 u8 *virt = dev_priv->render_ring.virtual_start;
490 uint32_t off;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700491
Chris Wilsonde227ef2010-07-03 07:58:38 +0100492 for (off = 0; off < dev_priv->render_ring.size; off += 4) {
493 uint32_t *ptr = (uint32_t *)(virt + off);
494 seq_printf(m, "%08x : %08x\n", off, *ptr);
495 }
Ben Gamari6911a9b2009-04-02 11:24:54 -0700496 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100497 mutex_unlock(&dev->struct_mutex);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700498
499 return 0;
500}
501
502static int i915_ringbuffer_info(struct seq_file *m, void *data)
503{
504 struct drm_info_node *node = (struct drm_info_node *) m->private;
505 struct drm_device *dev = node->minor->dev;
506 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilson0ef82af2009-09-05 18:07:06 +0100507 unsigned int head, tail;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700508
509 head = I915_READ(PRB0_HEAD) & HEAD_ADDR;
510 tail = I915_READ(PRB0_TAIL) & TAIL_ADDR;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700511
512 seq_printf(m, "RingHead : %08x\n", head);
513 seq_printf(m, "RingTail : %08x\n", tail);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800514 seq_printf(m, "RingSize : %08lx\n", dev_priv->render_ring.size);
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100515 seq_printf(m, "Acthd : %08x\n", I915_READ(INTEL_INFO(dev)->gen >= 4 ? ACTHD_I965 : ACTHD));
Ben Gamari6911a9b2009-04-02 11:24:54 -0700516
517 return 0;
518}
519
Chris Wilson9df30792010-02-18 10:24:56 +0000520static const char *pin_flag(int pinned)
521{
522 if (pinned > 0)
523 return " P";
524 else if (pinned < 0)
525 return " p";
526 else
527 return "";
528}
529
530static const char *tiling_flag(int tiling)
531{
532 switch (tiling) {
533 default:
534 case I915_TILING_NONE: return "";
535 case I915_TILING_X: return " X";
536 case I915_TILING_Y: return " Y";
537 }
538}
539
540static const char *dirty_flag(int dirty)
541{
542 return dirty ? " dirty" : "";
543}
544
545static const char *purgeable_flag(int purgeable)
546{
547 return purgeable ? " purgeable" : "";
548}
549
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700550static int i915_error_state(struct seq_file *m, void *unused)
551{
552 struct drm_info_node *node = (struct drm_info_node *) m->private;
553 struct drm_device *dev = node->minor->dev;
554 drm_i915_private_t *dev_priv = dev->dev_private;
555 struct drm_i915_error_state *error;
556 unsigned long flags;
Chris Wilson9df30792010-02-18 10:24:56 +0000557 int i, page, offset, elt;
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700558
559 spin_lock_irqsave(&dev_priv->error_lock, flags);
560 if (!dev_priv->first_error) {
561 seq_printf(m, "no error state collected\n");
562 goto out;
563 }
564
565 error = dev_priv->first_error;
566
Jesse Barnes8a905232009-07-11 16:48:03 -0400567 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
568 error->time.tv_usec);
Chris Wilson9df30792010-02-18 10:24:56 +0000569 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700570 seq_printf(m, "EIR: 0x%08x\n", error->eir);
571 seq_printf(m, " PGTBL_ER: 0x%08x\n", error->pgtbl_er);
572 seq_printf(m, " INSTPM: 0x%08x\n", error->instpm);
573 seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir);
574 seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr);
575 seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone);
576 seq_printf(m, " ACTHD: 0x%08x\n", error->acthd);
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100577 if (INTEL_INFO(dev)->gen >= 4) {
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700578 seq_printf(m, " INSTPS: 0x%08x\n", error->instps);
579 seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1);
580 }
Chris Wilson9df30792010-02-18 10:24:56 +0000581 seq_printf(m, "seqno: 0x%08x\n", error->seqno);
582
583 if (error->active_bo_count) {
584 seq_printf(m, "Buffers [%d]:\n", error->active_bo_count);
585
586 for (i = 0; i < error->active_bo_count; i++) {
587 seq_printf(m, " %08x %8zd %08x %08x %08x%s%s%s%s",
588 error->active_bo[i].gtt_offset,
589 error->active_bo[i].size,
590 error->active_bo[i].read_domains,
591 error->active_bo[i].write_domain,
592 error->active_bo[i].seqno,
593 pin_flag(error->active_bo[i].pinned),
594 tiling_flag(error->active_bo[i].tiling),
595 dirty_flag(error->active_bo[i].dirty),
596 purgeable_flag(error->active_bo[i].purgeable));
597
598 if (error->active_bo[i].name)
599 seq_printf(m, " (name: %d)", error->active_bo[i].name);
600 if (error->active_bo[i].fence_reg != I915_FENCE_REG_NONE)
601 seq_printf(m, " (fence: %d)", error->active_bo[i].fence_reg);
602
603 seq_printf(m, "\n");
604 }
605 }
606
607 for (i = 0; i < ARRAY_SIZE(error->batchbuffer); i++) {
608 if (error->batchbuffer[i]) {
609 struct drm_i915_error_object *obj = error->batchbuffer[i];
610
611 seq_printf(m, "--- gtt_offset = 0x%08x\n", obj->gtt_offset);
612 offset = 0;
613 for (page = 0; page < obj->page_count; page++) {
614 for (elt = 0; elt < PAGE_SIZE/4; elt++) {
615 seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]);
616 offset += 4;
617 }
618 }
619 }
620 }
621
622 if (error->ringbuffer) {
623 struct drm_i915_error_object *obj = error->ringbuffer;
624
625 seq_printf(m, "--- ringbuffer = 0x%08x\n", obj->gtt_offset);
626 offset = 0;
627 for (page = 0; page < obj->page_count; page++) {
628 for (elt = 0; elt < PAGE_SIZE/4; elt++) {
629 seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]);
630 offset += 4;
631 }
632 }
633 }
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700634
Chris Wilson6ef3d422010-08-04 20:26:07 +0100635 if (error->overlay)
636 intel_overlay_print_error_state(m, error->overlay);
637
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700638out:
639 spin_unlock_irqrestore(&dev_priv->error_lock, flags);
640
641 return 0;
642}
Ben Gamari6911a9b2009-04-02 11:24:54 -0700643
Jesse Barnesf97108d2010-01-29 11:27:07 -0800644static int i915_rstdby_delays(struct seq_file *m, void *unused)
645{
646 struct drm_info_node *node = (struct drm_info_node *) m->private;
647 struct drm_device *dev = node->minor->dev;
648 drm_i915_private_t *dev_priv = dev->dev_private;
649 u16 crstanddelay = I915_READ16(CRSTANDVID);
650
651 seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
652
653 return 0;
654}
655
656static int i915_cur_delayinfo(struct seq_file *m, void *unused)
657{
658 struct drm_info_node *node = (struct drm_info_node *) m->private;
659 struct drm_device *dev = node->minor->dev;
660 drm_i915_private_t *dev_priv = dev->dev_private;
661 u16 rgvswctl = I915_READ16(MEMSWCTL);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700662 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800663
Jesse Barnes7648fa92010-05-20 14:28:11 -0700664 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
665 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
666 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
667 MEMSTAT_VID_SHIFT);
668 seq_printf(m, "Current P-state: %d\n",
669 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800670
671 return 0;
672}
673
674static int i915_delayfreq_table(struct seq_file *m, void *unused)
675{
676 struct drm_info_node *node = (struct drm_info_node *) m->private;
677 struct drm_device *dev = node->minor->dev;
678 drm_i915_private_t *dev_priv = dev->dev_private;
679 u32 delayfreq;
680 int i;
681
682 for (i = 0; i < 16; i++) {
683 delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700684 seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
685 (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800686 }
687
688 return 0;
689}
690
691static inline int MAP_TO_MV(int map)
692{
693 return 1250 - (map * 25);
694}
695
696static int i915_inttoext_table(struct seq_file *m, void *unused)
697{
698 struct drm_info_node *node = (struct drm_info_node *) m->private;
699 struct drm_device *dev = node->minor->dev;
700 drm_i915_private_t *dev_priv = dev->dev_private;
701 u32 inttoext;
702 int i;
703
704 for (i = 1; i <= 32; i++) {
705 inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
706 seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
707 }
708
709 return 0;
710}
711
712static int i915_drpc_info(struct seq_file *m, void *unused)
713{
714 struct drm_info_node *node = (struct drm_info_node *) m->private;
715 struct drm_device *dev = node->minor->dev;
716 drm_i915_private_t *dev_priv = dev->dev_private;
717 u32 rgvmodectl = I915_READ(MEMMODECTL);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700718 u32 rstdbyctl = I915_READ(MCHBAR_RENDER_STANDBY);
719 u16 crstandvid = I915_READ16(CRSTANDVID);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800720
721 seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
722 "yes" : "no");
723 seq_printf(m, "Boost freq: %d\n",
724 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
725 MEMMODE_BOOST_FREQ_SHIFT);
726 seq_printf(m, "HW control enabled: %s\n",
727 rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
728 seq_printf(m, "SW control enabled: %s\n",
729 rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
730 seq_printf(m, "Gated voltage change: %s\n",
731 rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
732 seq_printf(m, "Starting frequency: P%d\n",
733 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700734 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -0800735 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700736 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
737 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
738 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
739 seq_printf(m, "Render standby enabled: %s\n",
740 (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
Jesse Barnesf97108d2010-01-29 11:27:07 -0800741
742 return 0;
743}
744
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800745static int i915_fbc_status(struct seq_file *m, void *unused)
746{
747 struct drm_info_node *node = (struct drm_info_node *) m->private;
748 struct drm_device *dev = node->minor->dev;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800749 drm_i915_private_t *dev_priv = dev->dev_private;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800750
Adam Jacksonee5382a2010-04-23 11:17:39 -0400751 if (!I915_HAS_FBC(dev)) {
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800752 seq_printf(m, "FBC unsupported on this chipset\n");
753 return 0;
754 }
755
Adam Jacksonee5382a2010-04-23 11:17:39 -0400756 if (intel_fbc_enabled(dev)) {
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800757 seq_printf(m, "FBC enabled\n");
758 } else {
759 seq_printf(m, "FBC disabled: ");
760 switch (dev_priv->no_fbc_reason) {
Chris Wilsonbed4a672010-09-11 10:47:47 +0100761 case FBC_NO_OUTPUT:
762 seq_printf(m, "no outputs");
763 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800764 case FBC_STOLEN_TOO_SMALL:
765 seq_printf(m, "not enough stolen memory");
766 break;
767 case FBC_UNSUPPORTED_MODE:
768 seq_printf(m, "mode not supported");
769 break;
770 case FBC_MODE_TOO_LARGE:
771 seq_printf(m, "mode too large");
772 break;
773 case FBC_BAD_PLANE:
774 seq_printf(m, "FBC unsupported on plane");
775 break;
776 case FBC_NOT_TILED:
777 seq_printf(m, "scanout buffer not tiled");
778 break;
Jesse Barnes9c928d12010-07-23 15:20:00 -0700779 case FBC_MULTIPLE_PIPES:
780 seq_printf(m, "multiple pipes are enabled");
781 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800782 default:
783 seq_printf(m, "unknown reason");
784 }
785 seq_printf(m, "\n");
786 }
787 return 0;
788}
789
Jesse Barnes4a9bef32010-02-05 12:47:35 -0800790static int i915_sr_status(struct seq_file *m, void *unused)
791{
792 struct drm_info_node *node = (struct drm_info_node *) m->private;
793 struct drm_device *dev = node->minor->dev;
794 drm_i915_private_t *dev_priv = dev->dev_private;
795 bool sr_enabled = false;
796
Chris Wilsonf00a3dd2010-10-21 14:57:17 +0100797 if (IS_GEN5(dev))
Chris Wilson5ba2aaa2010-08-19 18:04:08 +0100798 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100799 else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
Jesse Barnes4a9bef32010-02-05 12:47:35 -0800800 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
801 else if (IS_I915GM(dev))
802 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
803 else if (IS_PINEVIEW(dev))
804 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
805
Chris Wilson5ba2aaa2010-08-19 18:04:08 +0100806 seq_printf(m, "self-refresh: %s\n",
807 sr_enabled ? "enabled" : "disabled");
Jesse Barnes4a9bef32010-02-05 12:47:35 -0800808
809 return 0;
810}
811
Jesse Barnes7648fa92010-05-20 14:28:11 -0700812static int i915_emon_status(struct seq_file *m, void *unused)
813{
814 struct drm_info_node *node = (struct drm_info_node *) m->private;
815 struct drm_device *dev = node->minor->dev;
816 drm_i915_private_t *dev_priv = dev->dev_private;
817 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100818 int ret;
819
820 ret = mutex_lock_interruptible(&dev->struct_mutex);
821 if (ret)
822 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -0700823
824 temp = i915_mch_val(dev_priv);
825 chipset = i915_chipset_val(dev_priv);
826 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100827 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700828
829 seq_printf(m, "GMCH temp: %ld\n", temp);
830 seq_printf(m, "Chipset power: %ld\n", chipset);
831 seq_printf(m, "GFX power: %ld\n", gfx);
832 seq_printf(m, "Total power: %ld\n", chipset + gfx);
833
834 return 0;
835}
836
837static int i915_gfxec(struct seq_file *m, void *unused)
838{
839 struct drm_info_node *node = (struct drm_info_node *) m->private;
840 struct drm_device *dev = node->minor->dev;
841 drm_i915_private_t *dev_priv = dev->dev_private;
842
843 seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
844
845 return 0;
846}
847
Chris Wilson44834a62010-08-19 16:09:23 +0100848static int i915_opregion(struct seq_file *m, void *unused)
849{
850 struct drm_info_node *node = (struct drm_info_node *) m->private;
851 struct drm_device *dev = node->minor->dev;
852 drm_i915_private_t *dev_priv = dev->dev_private;
853 struct intel_opregion *opregion = &dev_priv->opregion;
854 int ret;
855
856 ret = mutex_lock_interruptible(&dev->struct_mutex);
857 if (ret)
858 return ret;
859
860 if (opregion->header)
861 seq_write(m, opregion->header, OPREGION_SIZE);
862
863 mutex_unlock(&dev->struct_mutex);
864
865 return 0;
866}
867
Chris Wilson37811fc2010-08-25 22:45:57 +0100868static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
869{
870 struct drm_info_node *node = (struct drm_info_node *) m->private;
871 struct drm_device *dev = node->minor->dev;
872 drm_i915_private_t *dev_priv = dev->dev_private;
873 struct intel_fbdev *ifbdev;
874 struct intel_framebuffer *fb;
875 int ret;
876
877 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
878 if (ret)
879 return ret;
880
881 ifbdev = dev_priv->fbdev;
882 fb = to_intel_framebuffer(ifbdev->helper.fb);
883
884 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
885 fb->base.width,
886 fb->base.height,
887 fb->base.depth,
888 fb->base.bits_per_pixel);
889 describe_obj(m, to_intel_bo(fb->obj));
890 seq_printf(m, "\n");
891
892 list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
893 if (&fb->base == ifbdev->helper.fb)
894 continue;
895
896 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ",
897 fb->base.width,
898 fb->base.height,
899 fb->base.depth,
900 fb->base.bits_per_pixel);
901 describe_obj(m, to_intel_bo(fb->obj));
902 seq_printf(m, "\n");
903 }
904
905 mutex_unlock(&dev->mode_config.mutex);
906
907 return 0;
908}
909
Chris Wilsonf3cd4742009-10-13 22:20:20 +0100910static int
911i915_wedged_open(struct inode *inode,
912 struct file *filp)
913{
914 filp->private_data = inode->i_private;
915 return 0;
916}
917
918static ssize_t
919i915_wedged_read(struct file *filp,
920 char __user *ubuf,
921 size_t max,
922 loff_t *ppos)
923{
924 struct drm_device *dev = filp->private_data;
925 drm_i915_private_t *dev_priv = dev->dev_private;
926 char buf[80];
927 int len;
928
929 len = snprintf(buf, sizeof (buf),
930 "wedged : %d\n",
931 atomic_read(&dev_priv->mm.wedged));
932
Dan Carpenterf4433a82010-09-08 21:44:47 +0200933 if (len > sizeof (buf))
934 len = sizeof (buf);
935
Chris Wilsonf3cd4742009-10-13 22:20:20 +0100936 return simple_read_from_buffer(ubuf, max, ppos, buf, len);
937}
938
939static ssize_t
940i915_wedged_write(struct file *filp,
941 const char __user *ubuf,
942 size_t cnt,
943 loff_t *ppos)
944{
945 struct drm_device *dev = filp->private_data;
946 drm_i915_private_t *dev_priv = dev->dev_private;
947 char buf[20];
948 int val = 1;
949
950 if (cnt > 0) {
951 if (cnt > sizeof (buf) - 1)
952 return -EINVAL;
953
954 if (copy_from_user(buf, ubuf, cnt))
955 return -EFAULT;
956 buf[cnt] = 0;
957
958 val = simple_strtoul(buf, NULL, 0);
959 }
960
961 DRM_INFO("Manually setting wedged to %d\n", val);
962
963 atomic_set(&dev_priv->mm.wedged, val);
964 if (val) {
Chris Wilsonf787a5f2010-09-24 16:02:42 +0100965 wake_up_all(&dev_priv->irq_queue);
Chris Wilsonf3cd4742009-10-13 22:20:20 +0100966 queue_work(dev_priv->wq, &dev_priv->error_work);
967 }
968
969 return cnt;
970}
971
972static const struct file_operations i915_wedged_fops = {
973 .owner = THIS_MODULE,
974 .open = i915_wedged_open,
975 .read = i915_wedged_read,
976 .write = i915_wedged_write,
977};
978
979/* As the drm_debugfs_init() routines are called before dev->dev_private is
980 * allocated we need to hook into the minor for release. */
981static int
982drm_add_fake_info_node(struct drm_minor *minor,
983 struct dentry *ent,
984 const void *key)
985{
986 struct drm_info_node *node;
987
988 node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
989 if (node == NULL) {
990 debugfs_remove(ent);
991 return -ENOMEM;
992 }
993
994 node->minor = minor;
995 node->dent = ent;
996 node->info_ent = (void *) key;
997 list_add(&node->list, &minor->debugfs_nodes.list);
998
999 return 0;
1000}
1001
1002static int i915_wedged_create(struct dentry *root, struct drm_minor *minor)
1003{
1004 struct drm_device *dev = minor->dev;
1005 struct dentry *ent;
1006
1007 ent = debugfs_create_file("i915_wedged",
1008 S_IRUGO | S_IWUSR,
1009 root, dev,
1010 &i915_wedged_fops);
1011 if (IS_ERR(ent))
1012 return PTR_ERR(ent);
1013
1014 return drm_add_fake_info_node(minor, ent, &i915_wedged_fops);
1015}
Ben Gamari9e3a6d12009-07-01 22:26:53 -04001016
Ben Gamari27c202a2009-07-01 22:26:52 -04001017static struct drm_info_list i915_debugfs_list[] = {
Chris Wilson70d39fe2010-08-25 16:03:34 +01001018 {"i915_capabilities", i915_capabilities, 0, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01001019 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson69dc4982010-10-19 10:36:51 +01001020 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05001021 {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
1022 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
Chris Wilsonf13d3f72010-09-20 17:36:15 +01001023 {"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST},
Chris Wilsond21d5972010-09-26 11:19:33 +01001024 {"i915_gem_deferred_free", i915_gem_object_list_info, 0, (void *) DEFERRED_FREE_LIST},
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01001025 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001026 {"i915_gem_request", i915_gem_request_info, 0},
1027 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00001028 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001029 {"i915_gem_interrupt", i915_interrupt_info, 0},
1030 {"i915_gem_hws", i915_hws_info, 0},
Ben Gamari6911a9b2009-04-02 11:24:54 -07001031 {"i915_ringbuffer_data", i915_ringbuffer_data, 0},
1032 {"i915_ringbuffer_info", i915_ringbuffer_info, 0},
1033 {"i915_batchbuffers", i915_batchbuffer_info, 0},
Jesse Barnes63eeaf32009-06-18 16:56:52 -07001034 {"i915_error_state", i915_error_state, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08001035 {"i915_rstdby_delays", i915_rstdby_delays, 0},
1036 {"i915_cur_delayinfo", i915_cur_delayinfo, 0},
1037 {"i915_delayfreq_table", i915_delayfreq_table, 0},
1038 {"i915_inttoext_table", i915_inttoext_table, 0},
1039 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07001040 {"i915_emon_status", i915_emon_status, 0},
1041 {"i915_gfxec", i915_gfxec, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001042 {"i915_fbc_status", i915_fbc_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001043 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01001044 {"i915_opregion", i915_opregion, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01001045 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001046};
Ben Gamari27c202a2009-07-01 22:26:52 -04001047#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05001048
Ben Gamari27c202a2009-07-01 22:26:52 -04001049int i915_debugfs_init(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05001050{
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001051 int ret;
1052
1053 ret = i915_wedged_create(minor->debugfs_root, minor);
1054 if (ret)
1055 return ret;
1056
Ben Gamari27c202a2009-07-01 22:26:52 -04001057 return drm_debugfs_create_files(i915_debugfs_list,
1058 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05001059 minor->debugfs_root, minor);
1060}
1061
Ben Gamari27c202a2009-07-01 22:26:52 -04001062void i915_debugfs_cleanup(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05001063{
Ben Gamari27c202a2009-07-01 22:26:52 -04001064 drm_debugfs_remove_files(i915_debugfs_list,
1065 I915_DEBUGFS_ENTRIES, minor);
Kristian Høgsberg33db6792009-11-11 12:19:16 -05001066 drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops,
1067 1, minor);
Ben Gamari20172632009-02-17 20:08:50 -05001068}
1069
1070#endif /* CONFIG_DEBUG_FS */