blob: f9e3295f0457cd580f347982e863040d62bddf45 [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);
74 B(is_ironlake);
75 B(has_fbc);
76 B(has_rc6);
77 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 Wilson70d39fe2010-08-25 16:03:34 +010083#undef B
84
85 return 0;
86}
87
Chris Wilsona6172a82009-02-11 14:26:38 +000088static const char *get_pin_flag(struct drm_i915_gem_object *obj_priv)
89{
90 if (obj_priv->user_pin_count > 0)
91 return "P";
92 else if (obj_priv->pin_count > 0)
93 return "p";
94 else
95 return " ";
96}
97
98static const char *get_tiling_flag(struct drm_i915_gem_object *obj_priv)
99{
100 switch (obj_priv->tiling_mode) {
101 default:
102 case I915_TILING_NONE: return " ";
103 case I915_TILING_X: return "X";
104 case I915_TILING_Y: return "Y";
105 }
106}
107
Chris Wilson37811fc2010-08-25 22:45:57 +0100108static void
109describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
110{
111 seq_printf(m, "%p: %s%s %8zd %08x %08x %d%s%s",
112 &obj->base,
113 get_pin_flag(obj),
114 get_tiling_flag(obj),
115 obj->base.size,
116 obj->base.read_domains,
117 obj->base.write_domain,
118 obj->last_rendering_seqno,
119 obj->dirty ? " dirty" : "",
120 obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
121 if (obj->base.name)
122 seq_printf(m, " (name: %d)", obj->base.name);
123 if (obj->fence_reg != I915_FENCE_REG_NONE)
124 seq_printf(m, " (fence: %d)", obj->fence_reg);
125 if (obj->gtt_space != NULL)
126 seq_printf(m, " (gtt_offset: %08x)", obj->gtt_offset);
Chris Wilson69dc4982010-10-19 10:36:51 +0100127 if (obj->ring != NULL)
128 seq_printf(m, " (%s)", obj->ring->name);
Chris Wilson37811fc2010-08-25 22:45:57 +0100129}
130
Ben Gamari433e12f2009-02-17 20:08:51 -0500131static int i915_gem_object_list_info(struct seq_file *m, void *data)
Ben Gamari20172632009-02-17 20:08:50 -0500132{
133 struct drm_info_node *node = (struct drm_info_node *) m->private;
Ben Gamari433e12f2009-02-17 20:08:51 -0500134 uintptr_t list = (uintptr_t) node->info_ent->data;
135 struct list_head *head;
Ben Gamari20172632009-02-17 20:08:50 -0500136 struct drm_device *dev = node->minor->dev;
137 drm_i915_private_t *dev_priv = dev->dev_private;
138 struct drm_i915_gem_object *obj_priv;
Chris Wilson8f2480f2010-09-26 11:44:19 +0100139 size_t total_obj_size, total_gtt_size;
140 int count, ret;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100141
142 ret = mutex_lock_interruptible(&dev->struct_mutex);
143 if (ret)
144 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500145
Ben Gamari433e12f2009-02-17 20:08:51 -0500146 switch (list) {
Chris Wilson69dc4982010-10-19 10:36:51 +0100147 case ACTIVE_LIST:
148 seq_printf(m, "Active:\n");
149 head = &dev_priv->mm.active_list;
Chris Wilson82690bb2010-09-18 01:37:30 +0100150 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500151 case INACTIVE_LIST:
Ben Gamaria17458f2009-07-01 15:01:36 -0400152 seq_printf(m, "Inactive:\n");
Ben Gamari433e12f2009-02-17 20:08:51 -0500153 head = &dev_priv->mm.inactive_list;
154 break;
Chris Wilsonf13d3f72010-09-20 17:36:15 +0100155 case PINNED_LIST:
156 seq_printf(m, "Pinned:\n");
157 head = &dev_priv->mm.pinned_list;
158 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500159 case FLUSHING_LIST:
160 seq_printf(m, "Flushing:\n");
161 head = &dev_priv->mm.flushing_list;
162 break;
Chris Wilsond21d5972010-09-26 11:19:33 +0100163 case DEFERRED_FREE_LIST:
164 seq_printf(m, "Deferred free:\n");
165 head = &dev_priv->mm.deferred_free_list;
166 break;
Ben Gamari433e12f2009-02-17 20:08:51 -0500167 default:
Chris Wilsonde227ef2010-07-03 07:58:38 +0100168 mutex_unlock(&dev->struct_mutex);
169 return -EINVAL;
Ben Gamari433e12f2009-02-17 20:08:51 -0500170 }
171
Chris Wilson8f2480f2010-09-26 11:44:19 +0100172 total_obj_size = total_gtt_size = count = 0;
Chris Wilson69dc4982010-10-19 10:36:51 +0100173 list_for_each_entry(obj_priv, head, mm_list) {
Chris Wilson37811fc2010-08-25 22:45:57 +0100174 seq_printf(m, " ");
175 describe_obj(m, obj_priv);
Eric Anholtf4ceda82009-02-17 23:53:41 -0800176 seq_printf(m, "\n");
Chris Wilson8f2480f2010-09-26 11:44:19 +0100177 total_obj_size += obj_priv->base.size;
178 total_gtt_size += obj_priv->gtt_space->size;
179 count++;
Ben Gamari20172632009-02-17 20:08:50 -0500180 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100181 mutex_unlock(&dev->struct_mutex);
Chris Wilson8f2480f2010-09-26 11:44:19 +0100182
183 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
184 count, total_obj_size, total_gtt_size);
Ben Gamari20172632009-02-17 20:08:50 -0500185 return 0;
186}
187
Chris Wilson73aa8082010-09-30 11:46:12 +0100188static int i915_gem_object_info(struct seq_file *m, void* data)
189{
190 struct drm_info_node *node = (struct drm_info_node *) m->private;
191 struct drm_device *dev = node->minor->dev;
192 struct drm_i915_private *dev_priv = dev->dev_private;
193 int ret;
194
195 ret = mutex_lock_interruptible(&dev->struct_mutex);
196 if (ret)
197 return ret;
198
199 seq_printf(m, "%u objects\n", dev_priv->mm.object_count);
200 seq_printf(m, "%zu object bytes\n", dev_priv->mm.object_memory);
201 seq_printf(m, "%u pinned\n", dev_priv->mm.pin_count);
202 seq_printf(m, "%zu pin bytes\n", dev_priv->mm.pin_memory);
203 seq_printf(m, "%u objects in gtt\n", dev_priv->mm.gtt_count);
204 seq_printf(m, "%zu gtt bytes\n", dev_priv->mm.gtt_memory);
205 seq_printf(m, "%zu gtt total\n", dev_priv->mm.gtt_total);
206
207 mutex_unlock(&dev->struct_mutex);
208
209 return 0;
210}
211
212
Simon Farnsworth4e5359c2010-09-01 17:47:52 +0100213static int i915_gem_pageflip_info(struct seq_file *m, void *data)
214{
215 struct drm_info_node *node = (struct drm_info_node *) m->private;
216 struct drm_device *dev = node->minor->dev;
217 unsigned long flags;
218 struct intel_crtc *crtc;
219
220 list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
221 const char *pipe = crtc->pipe ? "B" : "A";
222 const char *plane = crtc->plane ? "B" : "A";
223 struct intel_unpin_work *work;
224
225 spin_lock_irqsave(&dev->event_lock, flags);
226 work = crtc->unpin_work;
227 if (work == NULL) {
228 seq_printf(m, "No flip due on pipe %s (plane %s)\n",
229 pipe, plane);
230 } else {
231 if (!work->pending) {
232 seq_printf(m, "Flip queued on pipe %s (plane %s)\n",
233 pipe, plane);
234 } else {
235 seq_printf(m, "Flip pending (waiting for vsync) on pipe %s (plane %s)\n",
236 pipe, plane);
237 }
238 if (work->enable_stall_check)
239 seq_printf(m, "Stall check enabled, ");
240 else
241 seq_printf(m, "Stall check waiting for page flip ioctl, ");
242 seq_printf(m, "%d prepares\n", work->pending);
243
244 if (work->old_fb_obj) {
245 struct drm_i915_gem_object *obj_priv = to_intel_bo(work->old_fb_obj);
246 if(obj_priv)
247 seq_printf(m, "Old framebuffer gtt_offset 0x%08x\n", obj_priv->gtt_offset );
248 }
249 if (work->pending_flip_obj) {
250 struct drm_i915_gem_object *obj_priv = to_intel_bo(work->pending_flip_obj);
251 if(obj_priv)
252 seq_printf(m, "New framebuffer gtt_offset 0x%08x\n", obj_priv->gtt_offset );
253 }
254 }
255 spin_unlock_irqrestore(&dev->event_lock, flags);
256 }
257
258 return 0;
259}
260
Ben Gamari20172632009-02-17 20:08:50 -0500261static int i915_gem_request_info(struct seq_file *m, void *data)
262{
263 struct drm_info_node *node = (struct drm_info_node *) m->private;
264 struct drm_device *dev = node->minor->dev;
265 drm_i915_private_t *dev_priv = dev->dev_private;
266 struct drm_i915_gem_request *gem_request;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100267 int ret;
268
269 ret = mutex_lock_interruptible(&dev->struct_mutex);
270 if (ret)
271 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500272
273 seq_printf(m, "Request:\n");
Zou Nan hai852835f2010-05-21 09:08:56 +0800274 list_for_each_entry(gem_request, &dev_priv->render_ring.request_list,
275 list) {
Ben Gamari20172632009-02-17 20:08:50 -0500276 seq_printf(m, " %d @ %d\n",
277 gem_request->seqno,
278 (int) (jiffies - gem_request->emitted_jiffies));
279 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100280 mutex_unlock(&dev->struct_mutex);
281
Ben Gamari20172632009-02-17 20:08:50 -0500282 return 0;
283}
284
285static int i915_gem_seqno_info(struct seq_file *m, void *data)
286{
287 struct drm_info_node *node = (struct drm_info_node *) m->private;
288 struct drm_device *dev = node->minor->dev;
289 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100290 int ret;
291
292 ret = mutex_lock_interruptible(&dev->struct_mutex);
293 if (ret)
294 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500295
Eric Anholte20f9c62010-05-26 14:51:06 -0700296 if (dev_priv->render_ring.status_page.page_addr != NULL) {
Ben Gamari20172632009-02-17 20:08:50 -0500297 seq_printf(m, "Current sequence: %d\n",
Chris Wilsonf787a5f2010-09-24 16:02:42 +0100298 dev_priv->render_ring.get_seqno(dev, &dev_priv->render_ring));
Ben Gamari20172632009-02-17 20:08:50 -0500299 } else {
300 seq_printf(m, "Current sequence: hws uninitialized\n");
301 }
302 seq_printf(m, "Waiter sequence: %d\n",
303 dev_priv->mm.waiting_gem_seqno);
304 seq_printf(m, "IRQ sequence: %d\n", dev_priv->mm.irq_gem_seqno);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100305
306 mutex_unlock(&dev->struct_mutex);
307
Ben Gamari20172632009-02-17 20:08:50 -0500308 return 0;
309}
310
311
312static int i915_interrupt_info(struct seq_file *m, void *data)
313{
314 struct drm_info_node *node = (struct drm_info_node *) m->private;
315 struct drm_device *dev = node->minor->dev;
316 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100317 int ret;
318
319 ret = mutex_lock_interruptible(&dev->struct_mutex);
320 if (ret)
321 return ret;
Ben Gamari20172632009-02-17 20:08:50 -0500322
Eric Anholtbad720f2009-10-22 16:11:14 -0700323 if (!HAS_PCH_SPLIT(dev)) {
Zhenyu Wang5f6a1692009-08-10 21:37:24 +0800324 seq_printf(m, "Interrupt enable: %08x\n",
325 I915_READ(IER));
326 seq_printf(m, "Interrupt identity: %08x\n",
327 I915_READ(IIR));
328 seq_printf(m, "Interrupt mask: %08x\n",
329 I915_READ(IMR));
330 seq_printf(m, "Pipe A stat: %08x\n",
331 I915_READ(PIPEASTAT));
332 seq_printf(m, "Pipe B stat: %08x\n",
333 I915_READ(PIPEBSTAT));
334 } else {
335 seq_printf(m, "North Display Interrupt enable: %08x\n",
336 I915_READ(DEIER));
337 seq_printf(m, "North Display Interrupt identity: %08x\n",
338 I915_READ(DEIIR));
339 seq_printf(m, "North Display Interrupt mask: %08x\n",
340 I915_READ(DEIMR));
341 seq_printf(m, "South Display Interrupt enable: %08x\n",
342 I915_READ(SDEIER));
343 seq_printf(m, "South Display Interrupt identity: %08x\n",
344 I915_READ(SDEIIR));
345 seq_printf(m, "South Display Interrupt mask: %08x\n",
346 I915_READ(SDEIMR));
347 seq_printf(m, "Graphics Interrupt enable: %08x\n",
348 I915_READ(GTIER));
349 seq_printf(m, "Graphics Interrupt identity: %08x\n",
350 I915_READ(GTIIR));
351 seq_printf(m, "Graphics Interrupt mask: %08x\n",
352 I915_READ(GTIMR));
353 }
Ben Gamari20172632009-02-17 20:08:50 -0500354 seq_printf(m, "Interrupts received: %d\n",
355 atomic_read(&dev_priv->irq_received));
Eric Anholte20f9c62010-05-26 14:51:06 -0700356 if (dev_priv->render_ring.status_page.page_addr != NULL) {
Ben Gamari20172632009-02-17 20:08:50 -0500357 seq_printf(m, "Current sequence: %d\n",
Chris Wilsonf787a5f2010-09-24 16:02:42 +0100358 dev_priv->render_ring.get_seqno(dev, &dev_priv->render_ring));
Ben Gamari20172632009-02-17 20:08:50 -0500359 } else {
360 seq_printf(m, "Current sequence: hws uninitialized\n");
361 }
362 seq_printf(m, "Waiter sequence: %d\n",
363 dev_priv->mm.waiting_gem_seqno);
364 seq_printf(m, "IRQ sequence: %d\n",
365 dev_priv->mm.irq_gem_seqno);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100366 mutex_unlock(&dev->struct_mutex);
367
Ben Gamari20172632009-02-17 20:08:50 -0500368 return 0;
369}
370
Chris Wilsona6172a82009-02-11 14:26:38 +0000371static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
372{
373 struct drm_info_node *node = (struct drm_info_node *) m->private;
374 struct drm_device *dev = node->minor->dev;
375 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100376 int i, ret;
377
378 ret = mutex_lock_interruptible(&dev->struct_mutex);
379 if (ret)
380 return ret;
Chris Wilsona6172a82009-02-11 14:26:38 +0000381
382 seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
383 seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
384 for (i = 0; i < dev_priv->num_fence_regs; i++) {
385 struct drm_gem_object *obj = dev_priv->fence_regs[i].obj;
386
387 if (obj == NULL) {
388 seq_printf(m, "Fenced object[%2d] = unused\n", i);
389 } else {
390 struct drm_i915_gem_object *obj_priv;
391
Daniel Vetter23010e42010-03-08 13:35:02 +0100392 obj_priv = to_intel_bo(obj);
Chris Wilsona6172a82009-02-11 14:26:38 +0000393 seq_printf(m, "Fenced object[%2d] = %p: %s "
Linus Torvalds0b4d5692009-03-27 17:02:09 -0700394 "%08x %08zx %08x %s %08x %08x %d",
Chris Wilsona6172a82009-02-11 14:26:38 +0000395 i, obj, get_pin_flag(obj_priv),
396 obj_priv->gtt_offset,
397 obj->size, obj_priv->stride,
398 get_tiling_flag(obj_priv),
399 obj->read_domains, obj->write_domain,
400 obj_priv->last_rendering_seqno);
401 if (obj->name)
402 seq_printf(m, " (name: %d)", obj->name);
403 seq_printf(m, "\n");
404 }
405 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100406 mutex_unlock(&dev->struct_mutex);
Chris Wilsona6172a82009-02-11 14:26:38 +0000407
408 return 0;
409}
410
Ben Gamari20172632009-02-17 20:08:50 -0500411static int i915_hws_info(struct seq_file *m, void *data)
412{
413 struct drm_info_node *node = (struct drm_info_node *) m->private;
414 struct drm_device *dev = node->minor->dev;
415 drm_i915_private_t *dev_priv = dev->dev_private;
416 int i;
417 volatile u32 *hws;
418
Eric Anholte20f9c62010-05-26 14:51:06 -0700419 hws = (volatile u32 *)dev_priv->render_ring.status_page.page_addr;
Ben Gamari20172632009-02-17 20:08:50 -0500420 if (hws == NULL)
421 return 0;
422
423 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
424 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
425 i * 4,
426 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
427 }
428 return 0;
429}
430
Chris Wilson5cdf5882010-09-27 15:51:07 +0100431static void i915_dump_object(struct seq_file *m,
432 struct io_mapping *mapping,
433 struct drm_i915_gem_object *obj_priv)
Ben Gamari6911a9b2009-04-02 11:24:54 -0700434{
Chris Wilson5cdf5882010-09-27 15:51:07 +0100435 int page, page_count, i;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700436
Chris Wilson5cdf5882010-09-27 15:51:07 +0100437 page_count = obj_priv->base.size / PAGE_SIZE;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700438 for (page = 0; page < page_count; page++) {
Chris Wilson5cdf5882010-09-27 15:51:07 +0100439 u32 *mem = io_mapping_map_wc(mapping,
440 obj_priv->gtt_offset + page * PAGE_SIZE);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700441 for (i = 0; i < PAGE_SIZE; i += 4)
442 seq_printf(m, "%08x : %08x\n", i, mem[i / 4]);
Chris Wilson5cdf5882010-09-27 15:51:07 +0100443 io_mapping_unmap(mem);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700444 }
445}
446
447static int i915_batchbuffer_info(struct seq_file *m, void *data)
448{
449 struct drm_info_node *node = (struct drm_info_node *) m->private;
450 struct drm_device *dev = node->minor->dev;
451 drm_i915_private_t *dev_priv = dev->dev_private;
452 struct drm_gem_object *obj;
453 struct drm_i915_gem_object *obj_priv;
454 int ret;
455
Chris Wilsonde227ef2010-07-03 07:58:38 +0100456 ret = mutex_lock_interruptible(&dev->struct_mutex);
457 if (ret)
458 return ret;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700459
Chris Wilson69dc4982010-10-19 10:36:51 +0100460 list_for_each_entry(obj_priv, &dev_priv->mm.active_list, mm_list) {
Daniel Vettera8089e82010-04-09 19:05:09 +0000461 obj = &obj_priv->base;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700462 if (obj->read_domains & I915_GEM_DOMAIN_COMMAND) {
Chris Wilson5cdf5882010-09-27 15:51:07 +0100463 seq_printf(m, "--- gtt_offset = 0x%08x\n",
464 obj_priv->gtt_offset);
465 i915_dump_object(m, dev_priv->mm.gtt_mapping, obj_priv);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700466 }
467 }
468
Chris Wilsonde227ef2010-07-03 07:58:38 +0100469 mutex_unlock(&dev->struct_mutex);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700470
471 return 0;
472}
473
474static int i915_ringbuffer_data(struct seq_file *m, void *data)
475{
476 struct drm_info_node *node = (struct drm_info_node *) m->private;
477 struct drm_device *dev = node->minor->dev;
478 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100479 int ret;
480
481 ret = mutex_lock_interruptible(&dev->struct_mutex);
482 if (ret)
483 return ret;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700484
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800485 if (!dev_priv->render_ring.gem_object) {
Ben Gamari6911a9b2009-04-02 11:24:54 -0700486 seq_printf(m, "No ringbuffer setup\n");
Chris Wilsonde227ef2010-07-03 07:58:38 +0100487 } else {
488 u8 *virt = dev_priv->render_ring.virtual_start;
489 uint32_t off;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700490
Chris Wilsonde227ef2010-07-03 07:58:38 +0100491 for (off = 0; off < dev_priv->render_ring.size; off += 4) {
492 uint32_t *ptr = (uint32_t *)(virt + off);
493 seq_printf(m, "%08x : %08x\n", off, *ptr);
494 }
Ben Gamari6911a9b2009-04-02 11:24:54 -0700495 }
Chris Wilsonde227ef2010-07-03 07:58:38 +0100496 mutex_unlock(&dev->struct_mutex);
Ben Gamari6911a9b2009-04-02 11:24:54 -0700497
498 return 0;
499}
500
501static int i915_ringbuffer_info(struct seq_file *m, void *data)
502{
503 struct drm_info_node *node = (struct drm_info_node *) m->private;
504 struct drm_device *dev = node->minor->dev;
505 drm_i915_private_t *dev_priv = dev->dev_private;
Chris Wilson0ef82af2009-09-05 18:07:06 +0100506 unsigned int head, tail;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700507
508 head = I915_READ(PRB0_HEAD) & HEAD_ADDR;
509 tail = I915_READ(PRB0_TAIL) & TAIL_ADDR;
Ben Gamari6911a9b2009-04-02 11:24:54 -0700510
511 seq_printf(m, "RingHead : %08x\n", head);
512 seq_printf(m, "RingTail : %08x\n", tail);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800513 seq_printf(m, "RingSize : %08lx\n", dev_priv->render_ring.size);
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100514 seq_printf(m, "Acthd : %08x\n", I915_READ(INTEL_INFO(dev)->gen >= 4 ? ACTHD_I965 : ACTHD));
Ben Gamari6911a9b2009-04-02 11:24:54 -0700515
516 return 0;
517}
518
Chris Wilson9df30792010-02-18 10:24:56 +0000519static const char *pin_flag(int pinned)
520{
521 if (pinned > 0)
522 return " P";
523 else if (pinned < 0)
524 return " p";
525 else
526 return "";
527}
528
529static const char *tiling_flag(int tiling)
530{
531 switch (tiling) {
532 default:
533 case I915_TILING_NONE: return "";
534 case I915_TILING_X: return " X";
535 case I915_TILING_Y: return " Y";
536 }
537}
538
539static const char *dirty_flag(int dirty)
540{
541 return dirty ? " dirty" : "";
542}
543
544static const char *purgeable_flag(int purgeable)
545{
546 return purgeable ? " purgeable" : "";
547}
548
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700549static int i915_error_state(struct seq_file *m, void *unused)
550{
551 struct drm_info_node *node = (struct drm_info_node *) m->private;
552 struct drm_device *dev = node->minor->dev;
553 drm_i915_private_t *dev_priv = dev->dev_private;
554 struct drm_i915_error_state *error;
555 unsigned long flags;
Chris Wilson9df30792010-02-18 10:24:56 +0000556 int i, page, offset, elt;
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700557
558 spin_lock_irqsave(&dev_priv->error_lock, flags);
559 if (!dev_priv->first_error) {
560 seq_printf(m, "no error state collected\n");
561 goto out;
562 }
563
564 error = dev_priv->first_error;
565
Jesse Barnes8a905232009-07-11 16:48:03 -0400566 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
567 error->time.tv_usec);
Chris Wilson9df30792010-02-18 10:24:56 +0000568 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700569 seq_printf(m, "EIR: 0x%08x\n", error->eir);
570 seq_printf(m, " PGTBL_ER: 0x%08x\n", error->pgtbl_er);
571 seq_printf(m, " INSTPM: 0x%08x\n", error->instpm);
572 seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir);
573 seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr);
574 seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone);
575 seq_printf(m, " ACTHD: 0x%08x\n", error->acthd);
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100576 if (INTEL_INFO(dev)->gen >= 4) {
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700577 seq_printf(m, " INSTPS: 0x%08x\n", error->instps);
578 seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1);
579 }
Chris Wilson9df30792010-02-18 10:24:56 +0000580 seq_printf(m, "seqno: 0x%08x\n", error->seqno);
581
582 if (error->active_bo_count) {
583 seq_printf(m, "Buffers [%d]:\n", error->active_bo_count);
584
585 for (i = 0; i < error->active_bo_count; i++) {
586 seq_printf(m, " %08x %8zd %08x %08x %08x%s%s%s%s",
587 error->active_bo[i].gtt_offset,
588 error->active_bo[i].size,
589 error->active_bo[i].read_domains,
590 error->active_bo[i].write_domain,
591 error->active_bo[i].seqno,
592 pin_flag(error->active_bo[i].pinned),
593 tiling_flag(error->active_bo[i].tiling),
594 dirty_flag(error->active_bo[i].dirty),
595 purgeable_flag(error->active_bo[i].purgeable));
596
597 if (error->active_bo[i].name)
598 seq_printf(m, " (name: %d)", error->active_bo[i].name);
599 if (error->active_bo[i].fence_reg != I915_FENCE_REG_NONE)
600 seq_printf(m, " (fence: %d)", error->active_bo[i].fence_reg);
601
602 seq_printf(m, "\n");
603 }
604 }
605
606 for (i = 0; i < ARRAY_SIZE(error->batchbuffer); i++) {
607 if (error->batchbuffer[i]) {
608 struct drm_i915_error_object *obj = error->batchbuffer[i];
609
610 seq_printf(m, "--- gtt_offset = 0x%08x\n", obj->gtt_offset);
611 offset = 0;
612 for (page = 0; page < obj->page_count; page++) {
613 for (elt = 0; elt < PAGE_SIZE/4; elt++) {
614 seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]);
615 offset += 4;
616 }
617 }
618 }
619 }
620
621 if (error->ringbuffer) {
622 struct drm_i915_error_object *obj = error->ringbuffer;
623
624 seq_printf(m, "--- ringbuffer = 0x%08x\n", obj->gtt_offset);
625 offset = 0;
626 for (page = 0; page < obj->page_count; page++) {
627 for (elt = 0; elt < PAGE_SIZE/4; elt++) {
628 seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]);
629 offset += 4;
630 }
631 }
632 }
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700633
Chris Wilson6ef3d422010-08-04 20:26:07 +0100634 if (error->overlay)
635 intel_overlay_print_error_state(m, error->overlay);
636
Jesse Barnes63eeaf32009-06-18 16:56:52 -0700637out:
638 spin_unlock_irqrestore(&dev_priv->error_lock, flags);
639
640 return 0;
641}
Ben Gamari6911a9b2009-04-02 11:24:54 -0700642
Jesse Barnesf97108d2010-01-29 11:27:07 -0800643static int i915_rstdby_delays(struct seq_file *m, void *unused)
644{
645 struct drm_info_node *node = (struct drm_info_node *) m->private;
646 struct drm_device *dev = node->minor->dev;
647 drm_i915_private_t *dev_priv = dev->dev_private;
648 u16 crstanddelay = I915_READ16(CRSTANDVID);
649
650 seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
651
652 return 0;
653}
654
655static int i915_cur_delayinfo(struct seq_file *m, void *unused)
656{
657 struct drm_info_node *node = (struct drm_info_node *) m->private;
658 struct drm_device *dev = node->minor->dev;
659 drm_i915_private_t *dev_priv = dev->dev_private;
660 u16 rgvswctl = I915_READ16(MEMSWCTL);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700661 u16 rgvstat = I915_READ16(MEMSTAT_ILK);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800662
Jesse Barnes7648fa92010-05-20 14:28:11 -0700663 seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
664 seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
665 seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
666 MEMSTAT_VID_SHIFT);
667 seq_printf(m, "Current P-state: %d\n",
668 (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800669
670 return 0;
671}
672
673static int i915_delayfreq_table(struct seq_file *m, void *unused)
674{
675 struct drm_info_node *node = (struct drm_info_node *) m->private;
676 struct drm_device *dev = node->minor->dev;
677 drm_i915_private_t *dev_priv = dev->dev_private;
678 u32 delayfreq;
679 int i;
680
681 for (i = 0; i < 16; i++) {
682 delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700683 seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
684 (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800685 }
686
687 return 0;
688}
689
690static inline int MAP_TO_MV(int map)
691{
692 return 1250 - (map * 25);
693}
694
695static int i915_inttoext_table(struct seq_file *m, void *unused)
696{
697 struct drm_info_node *node = (struct drm_info_node *) m->private;
698 struct drm_device *dev = node->minor->dev;
699 drm_i915_private_t *dev_priv = dev->dev_private;
700 u32 inttoext;
701 int i;
702
703 for (i = 1; i <= 32; i++) {
704 inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
705 seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
706 }
707
708 return 0;
709}
710
711static int i915_drpc_info(struct seq_file *m, void *unused)
712{
713 struct drm_info_node *node = (struct drm_info_node *) m->private;
714 struct drm_device *dev = node->minor->dev;
715 drm_i915_private_t *dev_priv = dev->dev_private;
716 u32 rgvmodectl = I915_READ(MEMMODECTL);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700717 u32 rstdbyctl = I915_READ(MCHBAR_RENDER_STANDBY);
718 u16 crstandvid = I915_READ16(CRSTANDVID);
Jesse Barnesf97108d2010-01-29 11:27:07 -0800719
720 seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
721 "yes" : "no");
722 seq_printf(m, "Boost freq: %d\n",
723 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
724 MEMMODE_BOOST_FREQ_SHIFT);
725 seq_printf(m, "HW control enabled: %s\n",
726 rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
727 seq_printf(m, "SW control enabled: %s\n",
728 rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
729 seq_printf(m, "Gated voltage change: %s\n",
730 rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
731 seq_printf(m, "Starting frequency: P%d\n",
732 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700733 seq_printf(m, "Max P-state: P%d\n",
Jesse Barnesf97108d2010-01-29 11:27:07 -0800734 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700735 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
736 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
737 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
738 seq_printf(m, "Render standby enabled: %s\n",
739 (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
Jesse Barnesf97108d2010-01-29 11:27:07 -0800740
741 return 0;
742}
743
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800744static int i915_fbc_status(struct seq_file *m, void *unused)
745{
746 struct drm_info_node *node = (struct drm_info_node *) m->private;
747 struct drm_device *dev = node->minor->dev;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800748 drm_i915_private_t *dev_priv = dev->dev_private;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800749
Adam Jacksonee5382a2010-04-23 11:17:39 -0400750 if (!I915_HAS_FBC(dev)) {
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800751 seq_printf(m, "FBC unsupported on this chipset\n");
752 return 0;
753 }
754
Adam Jacksonee5382a2010-04-23 11:17:39 -0400755 if (intel_fbc_enabled(dev)) {
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800756 seq_printf(m, "FBC enabled\n");
757 } else {
758 seq_printf(m, "FBC disabled: ");
759 switch (dev_priv->no_fbc_reason) {
Chris Wilsonbed4a672010-09-11 10:47:47 +0100760 case FBC_NO_OUTPUT:
761 seq_printf(m, "no outputs");
762 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800763 case FBC_STOLEN_TOO_SMALL:
764 seq_printf(m, "not enough stolen memory");
765 break;
766 case FBC_UNSUPPORTED_MODE:
767 seq_printf(m, "mode not supported");
768 break;
769 case FBC_MODE_TOO_LARGE:
770 seq_printf(m, "mode too large");
771 break;
772 case FBC_BAD_PLANE:
773 seq_printf(m, "FBC unsupported on plane");
774 break;
775 case FBC_NOT_TILED:
776 seq_printf(m, "scanout buffer not tiled");
777 break;
Jesse Barnes9c928d12010-07-23 15:20:00 -0700778 case FBC_MULTIPLE_PIPES:
779 seq_printf(m, "multiple pipes are enabled");
780 break;
Jesse Barnesb5e50c32010-02-05 12:42:41 -0800781 default:
782 seq_printf(m, "unknown reason");
783 }
784 seq_printf(m, "\n");
785 }
786 return 0;
787}
788
Jesse Barnes4a9bef32010-02-05 12:47:35 -0800789static int i915_sr_status(struct seq_file *m, void *unused)
790{
791 struct drm_info_node *node = (struct drm_info_node *) m->private;
792 struct drm_device *dev = node->minor->dev;
793 drm_i915_private_t *dev_priv = dev->dev_private;
794 bool sr_enabled = false;
795
Chris Wilson5ba2aaa2010-08-19 18:04:08 +0100796 if (IS_IRONLAKE(dev))
797 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100798 else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
Jesse Barnes4a9bef32010-02-05 12:47:35 -0800799 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
800 else if (IS_I915GM(dev))
801 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
802 else if (IS_PINEVIEW(dev))
803 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
804
Chris Wilson5ba2aaa2010-08-19 18:04:08 +0100805 seq_printf(m, "self-refresh: %s\n",
806 sr_enabled ? "enabled" : "disabled");
Jesse Barnes4a9bef32010-02-05 12:47:35 -0800807
808 return 0;
809}
810
Jesse Barnes7648fa92010-05-20 14:28:11 -0700811static int i915_emon_status(struct seq_file *m, void *unused)
812{
813 struct drm_info_node *node = (struct drm_info_node *) m->private;
814 struct drm_device *dev = node->minor->dev;
815 drm_i915_private_t *dev_priv = dev->dev_private;
816 unsigned long temp, chipset, gfx;
Chris Wilsonde227ef2010-07-03 07:58:38 +0100817 int ret;
818
819 ret = mutex_lock_interruptible(&dev->struct_mutex);
820 if (ret)
821 return ret;
Jesse Barnes7648fa92010-05-20 14:28:11 -0700822
823 temp = i915_mch_val(dev_priv);
824 chipset = i915_chipset_val(dev_priv);
825 gfx = i915_gfx_val(dev_priv);
Chris Wilsonde227ef2010-07-03 07:58:38 +0100826 mutex_unlock(&dev->struct_mutex);
Jesse Barnes7648fa92010-05-20 14:28:11 -0700827
828 seq_printf(m, "GMCH temp: %ld\n", temp);
829 seq_printf(m, "Chipset power: %ld\n", chipset);
830 seq_printf(m, "GFX power: %ld\n", gfx);
831 seq_printf(m, "Total power: %ld\n", chipset + gfx);
832
833 return 0;
834}
835
836static int i915_gfxec(struct seq_file *m, void *unused)
837{
838 struct drm_info_node *node = (struct drm_info_node *) m->private;
839 struct drm_device *dev = node->minor->dev;
840 drm_i915_private_t *dev_priv = dev->dev_private;
841
842 seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
843
844 return 0;
845}
846
Chris Wilson44834a62010-08-19 16:09:23 +0100847static int i915_opregion(struct seq_file *m, void *unused)
848{
849 struct drm_info_node *node = (struct drm_info_node *) m->private;
850 struct drm_device *dev = node->minor->dev;
851 drm_i915_private_t *dev_priv = dev->dev_private;
852 struct intel_opregion *opregion = &dev_priv->opregion;
853 int ret;
854
855 ret = mutex_lock_interruptible(&dev->struct_mutex);
856 if (ret)
857 return ret;
858
859 if (opregion->header)
860 seq_write(m, opregion->header, OPREGION_SIZE);
861
862 mutex_unlock(&dev->struct_mutex);
863
864 return 0;
865}
866
Chris Wilson37811fc2010-08-25 22:45:57 +0100867static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
868{
869 struct drm_info_node *node = (struct drm_info_node *) m->private;
870 struct drm_device *dev = node->minor->dev;
871 drm_i915_private_t *dev_priv = dev->dev_private;
872 struct intel_fbdev *ifbdev;
873 struct intel_framebuffer *fb;
874 int ret;
875
876 ret = mutex_lock_interruptible(&dev->mode_config.mutex);
877 if (ret)
878 return ret;
879
880 ifbdev = dev_priv->fbdev;
881 fb = to_intel_framebuffer(ifbdev->helper.fb);
882
883 seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
884 fb->base.width,
885 fb->base.height,
886 fb->base.depth,
887 fb->base.bits_per_pixel);
888 describe_obj(m, to_intel_bo(fb->obj));
889 seq_printf(m, "\n");
890
891 list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
892 if (&fb->base == ifbdev->helper.fb)
893 continue;
894
895 seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ",
896 fb->base.width,
897 fb->base.height,
898 fb->base.depth,
899 fb->base.bits_per_pixel);
900 describe_obj(m, to_intel_bo(fb->obj));
901 seq_printf(m, "\n");
902 }
903
904 mutex_unlock(&dev->mode_config.mutex);
905
906 return 0;
907}
908
Chris Wilsonf3cd4742009-10-13 22:20:20 +0100909static int
910i915_wedged_open(struct inode *inode,
911 struct file *filp)
912{
913 filp->private_data = inode->i_private;
914 return 0;
915}
916
917static ssize_t
918i915_wedged_read(struct file *filp,
919 char __user *ubuf,
920 size_t max,
921 loff_t *ppos)
922{
923 struct drm_device *dev = filp->private_data;
924 drm_i915_private_t *dev_priv = dev->dev_private;
925 char buf[80];
926 int len;
927
928 len = snprintf(buf, sizeof (buf),
929 "wedged : %d\n",
930 atomic_read(&dev_priv->mm.wedged));
931
Dan Carpenterf4433a82010-09-08 21:44:47 +0200932 if (len > sizeof (buf))
933 len = sizeof (buf);
934
Chris Wilsonf3cd4742009-10-13 22:20:20 +0100935 return simple_read_from_buffer(ubuf, max, ppos, buf, len);
936}
937
938static ssize_t
939i915_wedged_write(struct file *filp,
940 const char __user *ubuf,
941 size_t cnt,
942 loff_t *ppos)
943{
944 struct drm_device *dev = filp->private_data;
945 drm_i915_private_t *dev_priv = dev->dev_private;
946 char buf[20];
947 int val = 1;
948
949 if (cnt > 0) {
950 if (cnt > sizeof (buf) - 1)
951 return -EINVAL;
952
953 if (copy_from_user(buf, ubuf, cnt))
954 return -EFAULT;
955 buf[cnt] = 0;
956
957 val = simple_strtoul(buf, NULL, 0);
958 }
959
960 DRM_INFO("Manually setting wedged to %d\n", val);
961
962 atomic_set(&dev_priv->mm.wedged, val);
963 if (val) {
Chris Wilsonf787a5f2010-09-24 16:02:42 +0100964 wake_up_all(&dev_priv->irq_queue);
Chris Wilsonf3cd4742009-10-13 22:20:20 +0100965 queue_work(dev_priv->wq, &dev_priv->error_work);
966 }
967
968 return cnt;
969}
970
971static const struct file_operations i915_wedged_fops = {
972 .owner = THIS_MODULE,
973 .open = i915_wedged_open,
974 .read = i915_wedged_read,
975 .write = i915_wedged_write,
976};
977
978/* As the drm_debugfs_init() routines are called before dev->dev_private is
979 * allocated we need to hook into the minor for release. */
980static int
981drm_add_fake_info_node(struct drm_minor *minor,
982 struct dentry *ent,
983 const void *key)
984{
985 struct drm_info_node *node;
986
987 node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
988 if (node == NULL) {
989 debugfs_remove(ent);
990 return -ENOMEM;
991 }
992
993 node->minor = minor;
994 node->dent = ent;
995 node->info_ent = (void *) key;
996 list_add(&node->list, &minor->debugfs_nodes.list);
997
998 return 0;
999}
1000
1001static int i915_wedged_create(struct dentry *root, struct drm_minor *minor)
1002{
1003 struct drm_device *dev = minor->dev;
1004 struct dentry *ent;
1005
1006 ent = debugfs_create_file("i915_wedged",
1007 S_IRUGO | S_IWUSR,
1008 root, dev,
1009 &i915_wedged_fops);
1010 if (IS_ERR(ent))
1011 return PTR_ERR(ent);
1012
1013 return drm_add_fake_info_node(minor, ent, &i915_wedged_fops);
1014}
Ben Gamari9e3a6d12009-07-01 22:26:53 -04001015
Ben Gamari27c202a2009-07-01 22:26:52 -04001016static struct drm_info_list i915_debugfs_list[] = {
Chris Wilson70d39fe2010-08-25 16:03:34 +01001017 {"i915_capabilities", i915_capabilities, 0, 0},
Chris Wilson73aa8082010-09-30 11:46:12 +01001018 {"i915_gem_objects", i915_gem_object_info, 0},
Chris Wilson69dc4982010-10-19 10:36:51 +01001019 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
Ben Gamari433e12f2009-02-17 20:08:51 -05001020 {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
1021 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
Chris Wilsonf13d3f72010-09-20 17:36:15 +01001022 {"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST},
Chris Wilsond21d5972010-09-26 11:19:33 +01001023 {"i915_gem_deferred_free", i915_gem_object_list_info, 0, (void *) DEFERRED_FREE_LIST},
Simon Farnsworth4e5359c2010-09-01 17:47:52 +01001024 {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001025 {"i915_gem_request", i915_gem_request_info, 0},
1026 {"i915_gem_seqno", i915_gem_seqno_info, 0},
Chris Wilsona6172a82009-02-11 14:26:38 +00001027 {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001028 {"i915_gem_interrupt", i915_interrupt_info, 0},
1029 {"i915_gem_hws", i915_hws_info, 0},
Ben Gamari6911a9b2009-04-02 11:24:54 -07001030 {"i915_ringbuffer_data", i915_ringbuffer_data, 0},
1031 {"i915_ringbuffer_info", i915_ringbuffer_info, 0},
1032 {"i915_batchbuffers", i915_batchbuffer_info, 0},
Jesse Barnes63eeaf32009-06-18 16:56:52 -07001033 {"i915_error_state", i915_error_state, 0},
Jesse Barnesf97108d2010-01-29 11:27:07 -08001034 {"i915_rstdby_delays", i915_rstdby_delays, 0},
1035 {"i915_cur_delayinfo", i915_cur_delayinfo, 0},
1036 {"i915_delayfreq_table", i915_delayfreq_table, 0},
1037 {"i915_inttoext_table", i915_inttoext_table, 0},
1038 {"i915_drpc_info", i915_drpc_info, 0},
Jesse Barnes7648fa92010-05-20 14:28:11 -07001039 {"i915_emon_status", i915_emon_status, 0},
1040 {"i915_gfxec", i915_gfxec, 0},
Jesse Barnesb5e50c32010-02-05 12:42:41 -08001041 {"i915_fbc_status", i915_fbc_status, 0},
Jesse Barnes4a9bef32010-02-05 12:47:35 -08001042 {"i915_sr_status", i915_sr_status, 0},
Chris Wilson44834a62010-08-19 16:09:23 +01001043 {"i915_opregion", i915_opregion, 0},
Chris Wilson37811fc2010-08-25 22:45:57 +01001044 {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
Ben Gamari20172632009-02-17 20:08:50 -05001045};
Ben Gamari27c202a2009-07-01 22:26:52 -04001046#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
Ben Gamari20172632009-02-17 20:08:50 -05001047
Ben Gamari27c202a2009-07-01 22:26:52 -04001048int i915_debugfs_init(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05001049{
Chris Wilsonf3cd4742009-10-13 22:20:20 +01001050 int ret;
1051
1052 ret = i915_wedged_create(minor->debugfs_root, minor);
1053 if (ret)
1054 return ret;
1055
Ben Gamari27c202a2009-07-01 22:26:52 -04001056 return drm_debugfs_create_files(i915_debugfs_list,
1057 I915_DEBUGFS_ENTRIES,
Ben Gamari20172632009-02-17 20:08:50 -05001058 minor->debugfs_root, minor);
1059}
1060
Ben Gamari27c202a2009-07-01 22:26:52 -04001061void i915_debugfs_cleanup(struct drm_minor *minor)
Ben Gamari20172632009-02-17 20:08:50 -05001062{
Ben Gamari27c202a2009-07-01 22:26:52 -04001063 drm_debugfs_remove_files(i915_debugfs_list,
1064 I915_DEBUGFS_ENTRIES, minor);
Kristian Høgsberg33db6792009-11-11 12:19:16 -05001065 drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops,
1066 1, minor);
Ben Gamari20172632009-02-17 20:08:50 -05001067}
1068
1069#endif /* CONFIG_DEBUG_FS */