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
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
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
29 #include <linux/seq_file.h>
35 #define DRM_I915_RING_DEBUG 1
38 #if defined(CONFIG_DEBUG_FS)
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;
55 seq_printf(m, "Active:\n");
56 head = &dev_priv->mm.active_list;
59 seq_printf(m, "Inctive:\n");
60 head = &dev_priv->mm.inactive_list;
63 seq_printf(m, "Flushing:\n");
64 head = &dev_priv->mm.flushing_list;
67 DRM_INFO("Ooops, unexpected list\n");
71 list_for_each_entry(obj_priv, head, list)
73 struct drm_gem_object *obj = obj_priv->obj;
75 seq_printf(m, " %p(%d): %08x %08x %d\n",
77 obj->read_domains, obj->write_domain,
78 obj_priv->last_rendering_seqno);
80 seq_printf(m, " %p: %08x %08x %d\n",
82 obj->read_domains, obj->write_domain,
83 obj_priv->last_rendering_seqno);
89 static int i915_gem_request_info(struct seq_file *m, void *data)
91 struct drm_info_node *node = (struct drm_info_node *) m->private;
92 struct drm_device *dev = node->minor->dev;
93 drm_i915_private_t *dev_priv = dev->dev_private;
94 struct drm_i915_gem_request *gem_request;
96 seq_printf(m, "Request:\n");
97 list_for_each_entry(gem_request, &dev_priv->mm.request_list, list) {
98 seq_printf(m, " %d @ %d\n",
100 (int) (jiffies - gem_request->emitted_jiffies));
105 static int i915_gem_seqno_info(struct seq_file *m, void *data)
107 struct drm_info_node *node = (struct drm_info_node *) m->private;
108 struct drm_device *dev = node->minor->dev;
109 drm_i915_private_t *dev_priv = dev->dev_private;
111 if (dev_priv->hw_status_page != NULL) {
112 seq_printf(m, "Current sequence: %d\n",
113 i915_get_gem_seqno(dev));
115 seq_printf(m, "Current sequence: hws uninitialized\n");
117 seq_printf(m, "Waiter sequence: %d\n",
118 dev_priv->mm.waiting_gem_seqno);
119 seq_printf(m, "IRQ sequence: %d\n", dev_priv->mm.irq_gem_seqno);
124 static int i915_interrupt_info(struct seq_file *m, void *data)
126 struct drm_info_node *node = (struct drm_info_node *) m->private;
127 struct drm_device *dev = node->minor->dev;
128 drm_i915_private_t *dev_priv = dev->dev_private;
130 seq_printf(m, "Interrupt enable: %08x\n",
132 seq_printf(m, "Interrupt identity: %08x\n",
134 seq_printf(m, "Interrupt mask: %08x\n",
136 seq_printf(m, "Pipe A stat: %08x\n",
137 I915_READ(PIPEASTAT));
138 seq_printf(m, "Pipe B stat: %08x\n",
139 I915_READ(PIPEBSTAT));
140 seq_printf(m, "Interrupts received: %d\n",
141 atomic_read(&dev_priv->irq_received));
142 if (dev_priv->hw_status_page != NULL) {
143 seq_printf(m, "Current sequence: %d\n",
144 i915_get_gem_seqno(dev));
146 seq_printf(m, "Current sequence: hws uninitialized\n");
148 seq_printf(m, "Waiter sequence: %d\n",
149 dev_priv->mm.waiting_gem_seqno);
150 seq_printf(m, "IRQ sequence: %d\n",
151 dev_priv->mm.irq_gem_seqno);
155 static int i915_hws_info(struct seq_file *m, void *data)
157 struct drm_info_node *node = (struct drm_info_node *) m->private;
158 struct drm_device *dev = node->minor->dev;
159 drm_i915_private_t *dev_priv = dev->dev_private;
163 hws = (volatile u32 *)dev_priv->hw_status_page;
167 for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
168 seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
170 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
175 static struct drm_info_list i915_gem_debugfs_list[] = {
176 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
177 {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
178 {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
179 {"i915_gem_request", i915_gem_request_info, 0},
180 {"i915_gem_seqno", i915_gem_seqno_info, 0},
181 {"i915_gem_interrupt", i915_interrupt_info, 0},
182 {"i915_gem_hws", i915_hws_info, 0},
184 #define I915_GEM_DEBUGFS_ENTRIES ARRAY_SIZE(i915_gem_debugfs_list)
186 int i915_gem_debugfs_init(struct drm_minor *minor)
188 return drm_debugfs_create_files(i915_gem_debugfs_list,
189 I915_GEM_DEBUGFS_ENTRIES,
190 minor->debugfs_root, minor);
193 void i915_gem_debugfs_cleanup(struct drm_minor *minor)
195 drm_debugfs_remove_files(i915_gem_debugfs_list,
196 I915_GEM_DEBUGFS_ENTRIES, minor);
199 #endif /* CONFIG_DEBUG_FS */