drm/i915: Add information on pinning and fencing to the i915 list debug.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / gpu / drm / i915 / i915_gem_debugfs.c
blobf7e7d3750f8f01fc8061446d3f2beed5befcda0f
1 /*
2 * Copyright © 2008 Intel Corporation
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:
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.
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.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
29 #include <linux/seq_file.h>
30 #include "drmP.h"
31 #include "drm.h"
32 #include "i915_drm.h"
33 #include "i915_drv.h"
35 #define DRM_I915_RING_DEBUG 1
38 #if defined(CONFIG_DEBUG_FS)
40 #define ACTIVE_LIST 1
41 #define FLUSHING_LIST 2
42 #define INACTIVE_LIST 3
44 static int i915_gem_object_list_info(struct seq_file *m, void *data)
46 struct drm_info_node *node = (struct drm_info_node *) m->private;
47 uintptr_t list = (uintptr_t) node->info_ent->data;
48 struct list_head *head;
49 struct drm_device *dev = node->minor->dev;
50 drm_i915_private_t *dev_priv = dev->dev_private;
51 struct drm_i915_gem_object *obj_priv;
53 switch (list) {
54 case ACTIVE_LIST:
55 seq_printf(m, "Active:\n");
56 head = &dev_priv->mm.active_list;
57 break;
58 case INACTIVE_LIST:
59 seq_printf(m, "Inctive:\n");
60 head = &dev_priv->mm.inactive_list;
61 break;
62 case FLUSHING_LIST:
63 seq_printf(m, "Flushing:\n");
64 head = &dev_priv->mm.flushing_list;
65 break;
66 default:
67 DRM_INFO("Ooops, unexpected list\n");
68 return 0;
71 list_for_each_entry(obj_priv, head, list)
73 char *pin_description;
74 struct drm_gem_object *obj = obj_priv->obj;
76 if (obj_priv->user_pin_count > 0)
77 pin_description = "P";
78 else if (obj_priv->pin_count > 0)
79 pin_description = "p";
80 else
81 pin_description = " ";
83 seq_printf(m, " %p: %s %08x %08x %d",
84 obj,
85 pin_description,
86 obj->read_domains, obj->write_domain,
87 obj_priv->last_rendering_seqno);
89 if (obj->name)
90 seq_printf(m, " (name: %d)", obj->name);
91 if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
92 seq_printf(m, " (fence: %d\n", obj_priv->fence_reg);
93 seq_printf(m, "\n");
95 return 0;
98 static int i915_gem_request_info(struct seq_file *m, void *data)
100 struct drm_info_node *node = (struct drm_info_node *) m->private;
101 struct drm_device *dev = node->minor->dev;
102 drm_i915_private_t *dev_priv = dev->dev_private;
103 struct drm_i915_gem_request *gem_request;
105 seq_printf(m, "Request:\n");
106 list_for_each_entry(gem_request, &dev_priv->mm.request_list, list) {
107 seq_printf(m, " %d @ %d\n",
108 gem_request->seqno,
109 (int) (jiffies - gem_request->emitted_jiffies));
111 return 0;
114 static int i915_gem_seqno_info(struct seq_file *m, void *data)
116 struct drm_info_node *node = (struct drm_info_node *) m->private;
117 struct drm_device *dev = node->minor->dev;
118 drm_i915_private_t *dev_priv = dev->dev_private;
120 if (dev_priv->hw_status_page != NULL) {
121 seq_printf(m, "Current sequence: %d\n",
122 i915_get_gem_seqno(dev));
123 } else {
124 seq_printf(m, "Current sequence: hws uninitialized\n");
126 seq_printf(m, "Waiter sequence: %d\n",
127 dev_priv->mm.waiting_gem_seqno);
128 seq_printf(m, "IRQ sequence: %d\n", dev_priv->mm.irq_gem_seqno);
129 return 0;
133 static int i915_interrupt_info(struct seq_file *m, void *data)
135 struct drm_info_node *node = (struct drm_info_node *) m->private;
136 struct drm_device *dev = node->minor->dev;
137 drm_i915_private_t *dev_priv = dev->dev_private;
139 seq_printf(m, "Interrupt enable: %08x\n",
140 I915_READ(IER));
141 seq_printf(m, "Interrupt identity: %08x\n",
142 I915_READ(IIR));
143 seq_printf(m, "Interrupt mask: %08x\n",
144 I915_READ(IMR));
145 seq_printf(m, "Pipe A stat: %08x\n",
146 I915_READ(PIPEASTAT));
147 seq_printf(m, "Pipe B stat: %08x\n",
148 I915_READ(PIPEBSTAT));
149 seq_printf(m, "Interrupts received: %d\n",
150 atomic_read(&dev_priv->irq_received));
151 if (dev_priv->hw_status_page != NULL) {
152 seq_printf(m, "Current sequence: %d\n",
153 i915_get_gem_seqno(dev));
154 } else {
155 seq_printf(m, "Current sequence: hws uninitialized\n");
157 seq_printf(m, "Waiter sequence: %d\n",
158 dev_priv->mm.waiting_gem_seqno);
159 seq_printf(m, "IRQ sequence: %d\n",
160 dev_priv->mm.irq_gem_seqno);
161 return 0;
164 static int i915_hws_info(struct seq_file *m, void *data)
166 struct drm_info_node *node = (struct drm_info_node *) m->private;
167 struct drm_device *dev = node->minor->dev;
168 drm_i915_private_t *dev_priv = dev->dev_private;
169 int i;
170 volatile u32 *hws;
172 hws = (volatile u32 *)dev_priv->hw_status_page;
173 if (hws == NULL)
174 return 0;
176 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
177 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
178 i * 4,
179 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
181 return 0;
184 static struct drm_info_list i915_gem_debugfs_list[] = {
185 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
186 {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
187 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
188 {"i915_gem_request", i915_gem_request_info, 0},
189 {"i915_gem_seqno", i915_gem_seqno_info, 0},
190 {"i915_gem_interrupt", i915_interrupt_info, 0},
191 {"i915_gem_hws", i915_hws_info, 0},
193 #define I915_GEM_DEBUGFS_ENTRIES ARRAY_SIZE(i915_gem_debugfs_list)
195 int i915_gem_debugfs_init(struct drm_minor *minor)
197 return drm_debugfs_create_files(i915_gem_debugfs_list,
198 I915_GEM_DEBUGFS_ENTRIES,
199 minor->debugfs_root, minor);
202 void i915_gem_debugfs_cleanup(struct drm_minor *minor)
204 drm_debugfs_remove_files(i915_gem_debugfs_list,
205 I915_GEM_DEBUGFS_ENTRIES, minor);
208 #endif /* CONFIG_DEBUG_FS */