Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1 | /* |
| 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 Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 30 | #include <linux/debugfs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 31 | #include <linux/slab.h> |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 32 | #include "drmP.h" |
| 33 | #include "drm.h" |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 34 | #include "intel_drv.h" |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 35 | #include "intel_ringbuffer.h" |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 36 | #include "i915_drm.h" |
| 37 | #include "i915_drv.h" |
| 38 | |
| 39 | #define DRM_I915_RING_DEBUG 1 |
| 40 | |
| 41 | |
| 42 | #if defined(CONFIG_DEBUG_FS) |
| 43 | |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 44 | enum { |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 45 | ACTIVE_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 46 | FLUSHING_LIST, |
| 47 | INACTIVE_LIST, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 48 | PINNED_LIST, |
| 49 | DEFERRED_FREE_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 50 | }; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 51 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 52 | static const char *yesno(int v) |
| 53 | { |
| 54 | return v ? "yes" : "no"; |
| 55 | } |
| 56 | |
| 57 | static int i915_capabilities(struct seq_file *m, void *data) |
| 58 | { |
| 59 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 60 | struct drm_device *dev = node->minor->dev; |
| 61 | const struct intel_device_info *info = INTEL_INFO(dev); |
| 62 | |
| 63 | seq_printf(m, "gen: %d\n", info->gen); |
| 64 | #define B(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
| 65 | B(is_mobile); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 66 | B(is_i85x); |
| 67 | B(is_i915g); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 68 | B(is_i945gm); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 69 | B(is_g33); |
| 70 | B(need_gfx_hws); |
| 71 | B(is_g4x); |
| 72 | B(is_pineview); |
| 73 | B(is_broadwater); |
| 74 | B(is_crestline); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 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 Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 82 | B(supports_tv); |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 83 | B(has_bsd_ring); |
| 84 | B(has_blt_ring); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 85 | #undef B |
| 86 | |
| 87 | return 0; |
| 88 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 89 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 90 | static const char *get_pin_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 91 | { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 92 | if (obj->user_pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 93 | return "P"; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 94 | else if (obj->pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 95 | return "p"; |
| 96 | else |
| 97 | return " "; |
| 98 | } |
| 99 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 100 | static const char *get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 101 | { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 102 | switch (obj->tiling_mode) { |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 103 | default: |
| 104 | case I915_TILING_NONE: return " "; |
| 105 | case I915_TILING_X: return "X"; |
| 106 | case I915_TILING_Y: return "Y"; |
| 107 | } |
| 108 | } |
| 109 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 110 | static void |
| 111 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 112 | { |
Chris Wilson | caea747 | 2010-11-12 13:53:37 +0000 | [diff] [blame] | 113 | seq_printf(m, "%p: %s%s %8zd %04x %04x %d %d%s%s", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 114 | &obj->base, |
| 115 | get_pin_flag(obj), |
| 116 | get_tiling_flag(obj), |
| 117 | obj->base.size, |
| 118 | obj->base.read_domains, |
| 119 | obj->base.write_domain, |
| 120 | obj->last_rendering_seqno, |
Chris Wilson | caea747 | 2010-11-12 13:53:37 +0000 | [diff] [blame] | 121 | obj->last_fenced_seqno, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 122 | obj->dirty ? " dirty" : "", |
| 123 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 124 | if (obj->base.name) |
| 125 | seq_printf(m, " (name: %d)", obj->base.name); |
| 126 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 127 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
| 128 | if (obj->gtt_space != NULL) |
Chris Wilson | a00b10c | 2010-09-24 21:15:47 +0100 | [diff] [blame] | 129 | seq_printf(m, " (gtt offset: %08x, size: %08x)", |
| 130 | obj->gtt_offset, (unsigned int)obj->gtt_space->size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 131 | if (obj->pin_mappable || obj->fault_mappable) { |
| 132 | char s[3], *t = s; |
| 133 | if (obj->pin_mappable) |
| 134 | *t++ = 'p'; |
| 135 | if (obj->fault_mappable) |
| 136 | *t++ = 'f'; |
| 137 | *t = '\0'; |
| 138 | seq_printf(m, " (%s mappable)", s); |
| 139 | } |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 140 | if (obj->ring != NULL) |
| 141 | seq_printf(m, " (%s)", obj->ring->name); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 144 | static int i915_gem_object_list_info(struct seq_file *m, void *data) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 145 | { |
| 146 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 147 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 148 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 149 | struct drm_device *dev = node->minor->dev; |
| 150 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 151 | struct drm_i915_gem_object *obj; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 152 | size_t total_obj_size, total_gtt_size; |
| 153 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 154 | |
| 155 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 156 | if (ret) |
| 157 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 158 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 159 | switch (list) { |
| 160 | case ACTIVE_LIST: |
| 161 | seq_printf(m, "Active:\n"); |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 162 | head = &dev_priv->mm.active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 163 | break; |
| 164 | case INACTIVE_LIST: |
Ben Gamari | a17458f | 2009-07-01 15:01:36 -0400 | [diff] [blame] | 165 | seq_printf(m, "Inactive:\n"); |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 166 | head = &dev_priv->mm.inactive_list; |
| 167 | break; |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 168 | case PINNED_LIST: |
| 169 | seq_printf(m, "Pinned:\n"); |
| 170 | head = &dev_priv->mm.pinned_list; |
| 171 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 172 | case FLUSHING_LIST: |
| 173 | seq_printf(m, "Flushing:\n"); |
| 174 | head = &dev_priv->mm.flushing_list; |
| 175 | break; |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 176 | case DEFERRED_FREE_LIST: |
| 177 | seq_printf(m, "Deferred free:\n"); |
| 178 | head = &dev_priv->mm.deferred_free_list; |
| 179 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 180 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 181 | mutex_unlock(&dev->struct_mutex); |
| 182 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 183 | } |
| 184 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 185 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 186 | list_for_each_entry(obj, head, mm_list) { |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 187 | seq_printf(m, " "); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 188 | describe_obj(m, obj); |
Eric Anholt | f4ceda8 | 2009-02-17 23:53:41 -0800 | [diff] [blame] | 189 | seq_printf(m, "\n"); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 190 | total_obj_size += obj->base.size; |
| 191 | total_gtt_size += obj->gtt_space->size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 192 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 193 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 194 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 195 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 196 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 197 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 198 | return 0; |
| 199 | } |
| 200 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 201 | #define count_objects(list, member) do { \ |
| 202 | list_for_each_entry(obj, list, member) { \ |
| 203 | size += obj->gtt_space->size; \ |
| 204 | ++count; \ |
| 205 | if (obj->map_and_fenceable) { \ |
| 206 | mappable_size += obj->gtt_space->size; \ |
| 207 | ++mappable_count; \ |
| 208 | } \ |
| 209 | } \ |
| 210 | } while(0) |
| 211 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 212 | static int i915_gem_object_info(struct seq_file *m, void* data) |
| 213 | { |
| 214 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 215 | struct drm_device *dev = node->minor->dev; |
| 216 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 217 | u32 count, mappable_count; |
| 218 | size_t size, mappable_size; |
| 219 | struct drm_i915_gem_object *obj; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 220 | int ret; |
| 221 | |
| 222 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 223 | if (ret) |
| 224 | return ret; |
| 225 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 226 | seq_printf(m, "%u objects, %zu bytes\n", |
| 227 | dev_priv->mm.object_count, |
| 228 | dev_priv->mm.object_memory); |
| 229 | |
| 230 | size = count = mappable_size = mappable_count = 0; |
| 231 | count_objects(&dev_priv->mm.gtt_list, gtt_list); |
| 232 | seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", |
| 233 | count, mappable_count, size, mappable_size); |
| 234 | |
| 235 | size = count = mappable_size = mappable_count = 0; |
| 236 | count_objects(&dev_priv->mm.active_list, mm_list); |
| 237 | count_objects(&dev_priv->mm.flushing_list, mm_list); |
| 238 | seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n", |
| 239 | count, mappable_count, size, mappable_size); |
| 240 | |
| 241 | size = count = mappable_size = mappable_count = 0; |
| 242 | count_objects(&dev_priv->mm.pinned_list, mm_list); |
| 243 | seq_printf(m, " %u [%u] pinned objects, %zu [%zu] bytes\n", |
| 244 | count, mappable_count, size, mappable_size); |
| 245 | |
| 246 | size = count = mappable_size = mappable_count = 0; |
| 247 | count_objects(&dev_priv->mm.inactive_list, mm_list); |
| 248 | seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n", |
| 249 | count, mappable_count, size, mappable_size); |
| 250 | |
| 251 | size = count = mappable_size = mappable_count = 0; |
| 252 | count_objects(&dev_priv->mm.deferred_free_list, mm_list); |
| 253 | seq_printf(m, " %u [%u] freed objects, %zu [%zu] bytes\n", |
| 254 | count, mappable_count, size, mappable_size); |
| 255 | |
| 256 | size = count = mappable_size = mappable_count = 0; |
| 257 | list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { |
| 258 | if (obj->fault_mappable) { |
| 259 | size += obj->gtt_space->size; |
| 260 | ++count; |
| 261 | } |
| 262 | if (obj->pin_mappable) { |
| 263 | mappable_size += obj->gtt_space->size; |
| 264 | ++mappable_count; |
| 265 | } |
| 266 | } |
| 267 | seq_printf(m, "%u pinned mappable objects, %zu bytes\n", |
| 268 | mappable_count, mappable_size); |
| 269 | seq_printf(m, "%u fault mappable objects, %zu bytes\n", |
| 270 | count, size); |
| 271 | |
| 272 | seq_printf(m, "%zu [%zu] gtt total\n", |
| 273 | dev_priv->mm.gtt_total, dev_priv->mm.mappable_gtt_total); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 274 | |
| 275 | mutex_unlock(&dev->struct_mutex); |
| 276 | |
| 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 281 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 282 | { |
| 283 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 284 | struct drm_device *dev = node->minor->dev; |
| 285 | unsigned long flags; |
| 286 | struct intel_crtc *crtc; |
| 287 | |
| 288 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { |
| 289 | const char *pipe = crtc->pipe ? "B" : "A"; |
| 290 | const char *plane = crtc->plane ? "B" : "A"; |
| 291 | struct intel_unpin_work *work; |
| 292 | |
| 293 | spin_lock_irqsave(&dev->event_lock, flags); |
| 294 | work = crtc->unpin_work; |
| 295 | if (work == NULL) { |
| 296 | seq_printf(m, "No flip due on pipe %s (plane %s)\n", |
| 297 | pipe, plane); |
| 298 | } else { |
| 299 | if (!work->pending) { |
| 300 | seq_printf(m, "Flip queued on pipe %s (plane %s)\n", |
| 301 | pipe, plane); |
| 302 | } else { |
| 303 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %s (plane %s)\n", |
| 304 | pipe, plane); |
| 305 | } |
| 306 | if (work->enable_stall_check) |
| 307 | seq_printf(m, "Stall check enabled, "); |
| 308 | else |
| 309 | seq_printf(m, "Stall check waiting for page flip ioctl, "); |
| 310 | seq_printf(m, "%d prepares\n", work->pending); |
| 311 | |
| 312 | if (work->old_fb_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 313 | struct drm_i915_gem_object *obj = work->old_fb_obj; |
| 314 | if (obj) |
| 315 | seq_printf(m, "Old framebuffer gtt_offset 0x%08x\n", obj->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 316 | } |
| 317 | if (work->pending_flip_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 318 | struct drm_i915_gem_object *obj = work->pending_flip_obj; |
| 319 | if (obj) |
| 320 | seq_printf(m, "New framebuffer gtt_offset 0x%08x\n", obj->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 324 | } |
| 325 | |
| 326 | return 0; |
| 327 | } |
| 328 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 329 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 330 | { |
| 331 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 332 | struct drm_device *dev = node->minor->dev; |
| 333 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 334 | struct drm_i915_gem_request *gem_request; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 335 | int ret, count; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 336 | |
| 337 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 338 | if (ret) |
| 339 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 340 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 341 | count = 0; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 342 | if (!list_empty(&dev_priv->ring[RCS].request_list)) { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 343 | seq_printf(m, "Render requests:\n"); |
| 344 | list_for_each_entry(gem_request, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 345 | &dev_priv->ring[RCS].request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 346 | list) { |
| 347 | seq_printf(m, " %d @ %d\n", |
| 348 | gem_request->seqno, |
| 349 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 350 | } |
| 351 | count++; |
| 352 | } |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 353 | if (!list_empty(&dev_priv->ring[VCS].request_list)) { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 354 | seq_printf(m, "BSD requests:\n"); |
| 355 | list_for_each_entry(gem_request, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 356 | &dev_priv->ring[VCS].request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 357 | list) { |
| 358 | seq_printf(m, " %d @ %d\n", |
| 359 | gem_request->seqno, |
| 360 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 361 | } |
| 362 | count++; |
| 363 | } |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 364 | if (!list_empty(&dev_priv->ring[BCS].request_list)) { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 365 | seq_printf(m, "BLT requests:\n"); |
| 366 | list_for_each_entry(gem_request, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 367 | &dev_priv->ring[BCS].request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 368 | list) { |
| 369 | seq_printf(m, " %d @ %d\n", |
| 370 | gem_request->seqno, |
| 371 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 372 | } |
| 373 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 374 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 375 | mutex_unlock(&dev->struct_mutex); |
| 376 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 377 | if (count == 0) |
| 378 | seq_printf(m, "No requests\n"); |
| 379 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 380 | return 0; |
| 381 | } |
| 382 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 383 | static void i915_ring_seqno_info(struct seq_file *m, |
| 384 | struct intel_ring_buffer *ring) |
| 385 | { |
| 386 | if (ring->get_seqno) { |
| 387 | seq_printf(m, "Current sequence (%s): %d\n", |
| 388 | ring->name, ring->get_seqno(ring)); |
| 389 | seq_printf(m, "Waiter sequence (%s): %d\n", |
| 390 | ring->name, ring->waiting_seqno); |
| 391 | seq_printf(m, "IRQ sequence (%s): %d\n", |
| 392 | ring->name, ring->irq_seqno); |
| 393 | } |
| 394 | } |
| 395 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 396 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 397 | { |
| 398 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 399 | struct drm_device *dev = node->minor->dev; |
| 400 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 401 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 402 | |
| 403 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 404 | if (ret) |
| 405 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 406 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 407 | for (i = 0; i < I915_NUM_RINGS; i++) |
| 408 | i915_ring_seqno_info(m, &dev_priv->ring[i]); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 409 | |
| 410 | mutex_unlock(&dev->struct_mutex); |
| 411 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | |
| 416 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 417 | { |
| 418 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 419 | struct drm_device *dev = node->minor->dev; |
| 420 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 421 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 422 | |
| 423 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 424 | if (ret) |
| 425 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 426 | |
Eric Anholt | bad720f | 2009-10-22 16:11:14 -0700 | [diff] [blame] | 427 | if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 428 | seq_printf(m, "Interrupt enable: %08x\n", |
| 429 | I915_READ(IER)); |
| 430 | seq_printf(m, "Interrupt identity: %08x\n", |
| 431 | I915_READ(IIR)); |
| 432 | seq_printf(m, "Interrupt mask: %08x\n", |
| 433 | I915_READ(IMR)); |
| 434 | seq_printf(m, "Pipe A stat: %08x\n", |
| 435 | I915_READ(PIPEASTAT)); |
| 436 | seq_printf(m, "Pipe B stat: %08x\n", |
| 437 | I915_READ(PIPEBSTAT)); |
| 438 | } else { |
| 439 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 440 | I915_READ(DEIER)); |
| 441 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 442 | I915_READ(DEIIR)); |
| 443 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 444 | I915_READ(DEIMR)); |
| 445 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 446 | I915_READ(SDEIER)); |
| 447 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 448 | I915_READ(SDEIIR)); |
| 449 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 450 | I915_READ(SDEIMR)); |
| 451 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 452 | I915_READ(GTIER)); |
| 453 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 454 | I915_READ(GTIIR)); |
| 455 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 456 | I915_READ(GTIMR)); |
| 457 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 458 | seq_printf(m, "Interrupts received: %d\n", |
| 459 | atomic_read(&dev_priv->irq_received)); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 460 | for (i = 0; i < I915_NUM_RINGS; i++) |
| 461 | i915_ring_seqno_info(m, &dev_priv->ring[i]); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 462 | mutex_unlock(&dev->struct_mutex); |
| 463 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 464 | return 0; |
| 465 | } |
| 466 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 467 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 468 | { |
| 469 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 470 | struct drm_device *dev = node->minor->dev; |
| 471 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 472 | int i, ret; |
| 473 | |
| 474 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 475 | if (ret) |
| 476 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 477 | |
| 478 | seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start); |
| 479 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 480 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 481 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 482 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 483 | seq_printf(m, "Fenced object[%2d] = ", i); |
| 484 | if (obj == NULL) |
| 485 | seq_printf(m, "unused"); |
| 486 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 487 | describe_obj(m, obj); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 488 | seq_printf(m, "\n"); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 489 | } |
| 490 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 491 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 492 | return 0; |
| 493 | } |
| 494 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 495 | static int i915_hws_info(struct seq_file *m, void *data) |
| 496 | { |
| 497 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 498 | struct drm_device *dev = node->minor->dev; |
| 499 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 500 | struct intel_ring_buffer *ring; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 501 | volatile u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 502 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 503 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 504 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 505 | hws = (volatile u32 *)ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 506 | if (hws == NULL) |
| 507 | return 0; |
| 508 | |
| 509 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 510 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 511 | i * 4, |
| 512 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 513 | } |
| 514 | return 0; |
| 515 | } |
| 516 | |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 517 | static void i915_dump_object(struct seq_file *m, |
| 518 | struct io_mapping *mapping, |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 519 | struct drm_i915_gem_object *obj) |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 520 | { |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 521 | int page, page_count, i; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 522 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 523 | page_count = obj->base.size / PAGE_SIZE; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 524 | for (page = 0; page < page_count; page++) { |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 525 | u32 *mem = io_mapping_map_wc(mapping, |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 526 | obj->gtt_offset + page * PAGE_SIZE); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 527 | for (i = 0; i < PAGE_SIZE; i += 4) |
| 528 | seq_printf(m, "%08x : %08x\n", i, mem[i / 4]); |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 529 | io_mapping_unmap(mem); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 530 | } |
| 531 | } |
| 532 | |
| 533 | static int i915_batchbuffer_info(struct seq_file *m, void *data) |
| 534 | { |
| 535 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 536 | struct drm_device *dev = node->minor->dev; |
| 537 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 538 | struct drm_i915_gem_object *obj; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 539 | int ret; |
| 540 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 541 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 542 | if (ret) |
| 543 | return ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 544 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 545 | list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) { |
| 546 | if (obj->base.read_domains & I915_GEM_DOMAIN_COMMAND) { |
| 547 | seq_printf(m, "--- gtt_offset = 0x%08x\n", obj->gtt_offset); |
| 548 | i915_dump_object(m, dev_priv->mm.gtt_mapping, obj); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 549 | } |
| 550 | } |
| 551 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 552 | mutex_unlock(&dev->struct_mutex); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | static int i915_ringbuffer_data(struct seq_file *m, void *data) |
| 557 | { |
| 558 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 559 | struct drm_device *dev = node->minor->dev; |
| 560 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 561 | struct intel_ring_buffer *ring; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 562 | int ret; |
| 563 | |
| 564 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 565 | if (ret) |
| 566 | return ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 567 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 568 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 569 | if (!ring->obj) { |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 570 | seq_printf(m, "No ringbuffer setup\n"); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 571 | } else { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 572 | u8 *virt = ring->virtual_start; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 573 | uint32_t off; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 574 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 575 | for (off = 0; off < ring->size; off += 4) { |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 576 | uint32_t *ptr = (uint32_t *)(virt + off); |
| 577 | seq_printf(m, "%08x : %08x\n", off, *ptr); |
| 578 | } |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 579 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 580 | mutex_unlock(&dev->struct_mutex); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 581 | |
| 582 | return 0; |
| 583 | } |
| 584 | |
| 585 | static int i915_ringbuffer_info(struct seq_file *m, void *data) |
| 586 | { |
| 587 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 588 | struct drm_device *dev = node->minor->dev; |
| 589 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 590 | struct intel_ring_buffer *ring; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 591 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 592 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 593 | if (ring->size == 0) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 594 | return 0; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 595 | |
| 596 | seq_printf(m, "Ring %s:\n", ring->name); |
| 597 | seq_printf(m, " Head : %08x\n", I915_READ_HEAD(ring) & HEAD_ADDR); |
| 598 | seq_printf(m, " Tail : %08x\n", I915_READ_TAIL(ring) & TAIL_ADDR); |
| 599 | seq_printf(m, " Size : %08x\n", ring->size); |
| 600 | seq_printf(m, " Active : %08x\n", intel_ring_get_active_head(ring)); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 601 | seq_printf(m, " NOPID : %08x\n", I915_READ_NOPID(ring)); |
| 602 | if (IS_GEN6(dev)) { |
| 603 | seq_printf(m, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring)); |
| 604 | seq_printf(m, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring)); |
| 605 | } |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 606 | seq_printf(m, " Control : %08x\n", I915_READ_CTL(ring)); |
| 607 | seq_printf(m, " Start : %08x\n", I915_READ_START(ring)); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 612 | static const char *ring_str(int ring) |
| 613 | { |
| 614 | switch (ring) { |
Chris Wilson | 3685092 | 2010-11-23 08:49:38 +0000 | [diff] [blame] | 615 | case RING_RENDER: return " render"; |
| 616 | case RING_BSD: return " bsd"; |
| 617 | case RING_BLT: return " blt"; |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 618 | default: return ""; |
| 619 | } |
| 620 | } |
| 621 | |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 622 | static const char *pin_flag(int pinned) |
| 623 | { |
| 624 | if (pinned > 0) |
| 625 | return " P"; |
| 626 | else if (pinned < 0) |
| 627 | return " p"; |
| 628 | else |
| 629 | return ""; |
| 630 | } |
| 631 | |
| 632 | static const char *tiling_flag(int tiling) |
| 633 | { |
| 634 | switch (tiling) { |
| 635 | default: |
| 636 | case I915_TILING_NONE: return ""; |
| 637 | case I915_TILING_X: return " X"; |
| 638 | case I915_TILING_Y: return " Y"; |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | static const char *dirty_flag(int dirty) |
| 643 | { |
| 644 | return dirty ? " dirty" : ""; |
| 645 | } |
| 646 | |
| 647 | static const char *purgeable_flag(int purgeable) |
| 648 | { |
| 649 | return purgeable ? " purgeable" : ""; |
| 650 | } |
| 651 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 652 | static void print_error_buffers(struct seq_file *m, |
| 653 | const char *name, |
| 654 | struct drm_i915_error_buffer *err, |
| 655 | int count) |
| 656 | { |
| 657 | seq_printf(m, "%s [%d]:\n", name, count); |
| 658 | |
| 659 | while (count--) { |
| 660 | seq_printf(m, " %08x %8zd %04x %04x %08x%s%s%s%s%s", |
| 661 | err->gtt_offset, |
| 662 | err->size, |
| 663 | err->read_domains, |
| 664 | err->write_domain, |
| 665 | err->seqno, |
| 666 | pin_flag(err->pinned), |
| 667 | tiling_flag(err->tiling), |
| 668 | dirty_flag(err->dirty), |
| 669 | purgeable_flag(err->purgeable), |
| 670 | ring_str(err->ring)); |
| 671 | |
| 672 | if (err->name) |
| 673 | seq_printf(m, " (name: %d)", err->name); |
| 674 | if (err->fence_reg != I915_FENCE_REG_NONE) |
| 675 | seq_printf(m, " (fence: %d)", err->fence_reg); |
| 676 | |
| 677 | seq_printf(m, "\n"); |
| 678 | err++; |
| 679 | } |
| 680 | } |
| 681 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 682 | static int i915_error_state(struct seq_file *m, void *unused) |
| 683 | { |
| 684 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 685 | struct drm_device *dev = node->minor->dev; |
| 686 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 687 | struct drm_i915_error_state *error; |
| 688 | unsigned long flags; |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 689 | int i, page, offset, elt; |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 690 | |
| 691 | spin_lock_irqsave(&dev_priv->error_lock, flags); |
| 692 | if (!dev_priv->first_error) { |
| 693 | seq_printf(m, "no error state collected\n"); |
| 694 | goto out; |
| 695 | } |
| 696 | |
| 697 | error = dev_priv->first_error; |
| 698 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 699 | seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec, |
| 700 | error->time.tv_usec); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 701 | seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 702 | seq_printf(m, "EIR: 0x%08x\n", error->eir); |
| 703 | seq_printf(m, "PGTBL_ER: 0x%08x\n", error->pgtbl_er); |
Chris Wilson | f406839 | 2010-10-27 20:36:41 +0100 | [diff] [blame] | 704 | if (INTEL_INFO(dev)->gen >= 6) { |
| 705 | seq_printf(m, "ERROR: 0x%08x\n", error->error); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 706 | seq_printf(m, "Blitter command stream:\n"); |
| 707 | seq_printf(m, " ACTHD: 0x%08x\n", error->bcs_acthd); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 708 | seq_printf(m, " IPEIR: 0x%08x\n", error->bcs_ipeir); |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 709 | seq_printf(m, " IPEHR: 0x%08x\n", error->bcs_ipehr); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 710 | seq_printf(m, " INSTDONE: 0x%08x\n", error->bcs_instdone); |
| 711 | seq_printf(m, " seqno: 0x%08x\n", error->bcs_seqno); |
Chris Wilson | add354d | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 712 | seq_printf(m, "Video (BSD) command stream:\n"); |
| 713 | seq_printf(m, " ACTHD: 0x%08x\n", error->vcs_acthd); |
Chris Wilson | add354d | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 714 | seq_printf(m, " IPEIR: 0x%08x\n", error->vcs_ipeir); |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 715 | seq_printf(m, " IPEHR: 0x%08x\n", error->vcs_ipehr); |
Chris Wilson | add354d | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 716 | seq_printf(m, " INSTDONE: 0x%08x\n", error->vcs_instdone); |
| 717 | seq_printf(m, " seqno: 0x%08x\n", error->vcs_seqno); |
Chris Wilson | f406839 | 2010-10-27 20:36:41 +0100 | [diff] [blame] | 718 | } |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 719 | seq_printf(m, "Render command stream:\n"); |
| 720 | seq_printf(m, " ACTHD: 0x%08x\n", error->acthd); |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 721 | seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir); |
| 722 | seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr); |
| 723 | seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 724 | if (INTEL_INFO(dev)->gen >= 4) { |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 725 | seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 726 | seq_printf(m, " INSTPS: 0x%08x\n", error->instps); |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 727 | } |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 728 | seq_printf(m, " INSTPM: 0x%08x\n", error->instpm); |
| 729 | seq_printf(m, " seqno: 0x%08x\n", error->seqno); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 730 | |
Chris Wilson | 748ebc6 | 2010-10-24 10:28:47 +0100 | [diff] [blame] | 731 | for (i = 0; i < 16; i++) |
| 732 | seq_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]); |
| 733 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 734 | if (error->active_bo) |
| 735 | print_error_buffers(m, "Active", |
| 736 | error->active_bo, |
| 737 | error->active_bo_count); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 738 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 739 | if (error->pinned_bo) |
| 740 | print_error_buffers(m, "Pinned", |
| 741 | error->pinned_bo, |
| 742 | error->pinned_bo_count); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 743 | |
| 744 | for (i = 0; i < ARRAY_SIZE(error->batchbuffer); i++) { |
| 745 | if (error->batchbuffer[i]) { |
| 746 | struct drm_i915_error_object *obj = error->batchbuffer[i]; |
| 747 | |
| 748 | seq_printf(m, "--- gtt_offset = 0x%08x\n", obj->gtt_offset); |
| 749 | offset = 0; |
| 750 | for (page = 0; page < obj->page_count; page++) { |
| 751 | for (elt = 0; elt < PAGE_SIZE/4; elt++) { |
| 752 | seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]); |
| 753 | offset += 4; |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | if (error->ringbuffer) { |
| 760 | struct drm_i915_error_object *obj = error->ringbuffer; |
| 761 | |
| 762 | seq_printf(m, "--- ringbuffer = 0x%08x\n", obj->gtt_offset); |
| 763 | offset = 0; |
| 764 | for (page = 0; page < obj->page_count; page++) { |
| 765 | for (elt = 0; elt < PAGE_SIZE/4; elt++) { |
| 766 | seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]); |
| 767 | offset += 4; |
| 768 | } |
| 769 | } |
| 770 | } |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 771 | |
Chris Wilson | 6ef3d42 | 2010-08-04 20:26:07 +0100 | [diff] [blame] | 772 | if (error->overlay) |
| 773 | intel_overlay_print_error_state(m, error->overlay); |
| 774 | |
Chris Wilson | c4a1d9e | 2010-11-21 13:12:35 +0000 | [diff] [blame] | 775 | if (error->display) |
| 776 | intel_display_print_error_state(m, dev, error->display); |
| 777 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 778 | out: |
| 779 | spin_unlock_irqrestore(&dev_priv->error_lock, flags); |
| 780 | |
| 781 | return 0; |
| 782 | } |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 783 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 784 | static int i915_rstdby_delays(struct seq_file *m, void *unused) |
| 785 | { |
| 786 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 787 | struct drm_device *dev = node->minor->dev; |
| 788 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 789 | u16 crstanddelay = I915_READ16(CRSTANDVID); |
| 790 | |
| 791 | seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f)); |
| 792 | |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | static int i915_cur_delayinfo(struct seq_file *m, void *unused) |
| 797 | { |
| 798 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 799 | struct drm_device *dev = node->minor->dev; |
| 800 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 801 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 802 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 803 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 804 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 805 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 806 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 807 | MEMSTAT_VID_SHIFT); |
| 808 | seq_printf(m, "Current P-state: %d\n", |
| 809 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 810 | |
| 811 | return 0; |
| 812 | } |
| 813 | |
| 814 | static int i915_delayfreq_table(struct seq_file *m, void *unused) |
| 815 | { |
| 816 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 817 | struct drm_device *dev = node->minor->dev; |
| 818 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 819 | u32 delayfreq; |
| 820 | int i; |
| 821 | |
| 822 | for (i = 0; i < 16; i++) { |
| 823 | delayfreq = I915_READ(PXVFREQ_BASE + i * 4); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 824 | seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq, |
| 825 | (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | return 0; |
| 829 | } |
| 830 | |
| 831 | static inline int MAP_TO_MV(int map) |
| 832 | { |
| 833 | return 1250 - (map * 25); |
| 834 | } |
| 835 | |
| 836 | static int i915_inttoext_table(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 | u32 inttoext; |
| 842 | int i; |
| 843 | |
| 844 | for (i = 1; i <= 32; i++) { |
| 845 | inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4); |
| 846 | seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext); |
| 847 | } |
| 848 | |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 853 | { |
| 854 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 855 | struct drm_device *dev = node->minor->dev; |
| 856 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 857 | u32 rgvmodectl = I915_READ(MEMMODECTL); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 858 | u32 rstdbyctl = I915_READ(MCHBAR_RENDER_STANDBY); |
| 859 | u16 crstandvid = I915_READ16(CRSTANDVID); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 860 | |
| 861 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 862 | "yes" : "no"); |
| 863 | seq_printf(m, "Boost freq: %d\n", |
| 864 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 865 | MEMMODE_BOOST_FREQ_SHIFT); |
| 866 | seq_printf(m, "HW control enabled: %s\n", |
| 867 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 868 | seq_printf(m, "SW control enabled: %s\n", |
| 869 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 870 | seq_printf(m, "Gated voltage change: %s\n", |
| 871 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 872 | seq_printf(m, "Starting frequency: P%d\n", |
| 873 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 874 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 875 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 876 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 877 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 878 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 879 | seq_printf(m, "Render standby enabled: %s\n", |
| 880 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 881 | |
| 882 | return 0; |
| 883 | } |
| 884 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 885 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 886 | { |
| 887 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 888 | struct drm_device *dev = node->minor->dev; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 889 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 890 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 891 | if (!I915_HAS_FBC(dev)) { |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 892 | seq_printf(m, "FBC unsupported on this chipset\n"); |
| 893 | return 0; |
| 894 | } |
| 895 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 896 | if (intel_fbc_enabled(dev)) { |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 897 | seq_printf(m, "FBC enabled\n"); |
| 898 | } else { |
| 899 | seq_printf(m, "FBC disabled: "); |
| 900 | switch (dev_priv->no_fbc_reason) { |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 901 | case FBC_NO_OUTPUT: |
| 902 | seq_printf(m, "no outputs"); |
| 903 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 904 | case FBC_STOLEN_TOO_SMALL: |
| 905 | seq_printf(m, "not enough stolen memory"); |
| 906 | break; |
| 907 | case FBC_UNSUPPORTED_MODE: |
| 908 | seq_printf(m, "mode not supported"); |
| 909 | break; |
| 910 | case FBC_MODE_TOO_LARGE: |
| 911 | seq_printf(m, "mode too large"); |
| 912 | break; |
| 913 | case FBC_BAD_PLANE: |
| 914 | seq_printf(m, "FBC unsupported on plane"); |
| 915 | break; |
| 916 | case FBC_NOT_TILED: |
| 917 | seq_printf(m, "scanout buffer not tiled"); |
| 918 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 919 | case FBC_MULTIPLE_PIPES: |
| 920 | seq_printf(m, "multiple pipes are enabled"); |
| 921 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 922 | default: |
| 923 | seq_printf(m, "unknown reason"); |
| 924 | } |
| 925 | seq_printf(m, "\n"); |
| 926 | } |
| 927 | return 0; |
| 928 | } |
| 929 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 930 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 931 | { |
| 932 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 933 | struct drm_device *dev = node->minor->dev; |
| 934 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 935 | bool sr_enabled = false; |
| 936 | |
Chris Wilson | f00a3dd | 2010-10-21 14:57:17 +0100 | [diff] [blame] | 937 | if (IS_GEN5(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 938 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 939 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 940 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 941 | else if (IS_I915GM(dev)) |
| 942 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 943 | else if (IS_PINEVIEW(dev)) |
| 944 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 945 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 946 | seq_printf(m, "self-refresh: %s\n", |
| 947 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 952 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 953 | { |
| 954 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 955 | struct drm_device *dev = node->minor->dev; |
| 956 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 957 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 958 | int ret; |
| 959 | |
| 960 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 961 | if (ret) |
| 962 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 963 | |
| 964 | temp = i915_mch_val(dev_priv); |
| 965 | chipset = i915_chipset_val(dev_priv); |
| 966 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 967 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 968 | |
| 969 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 970 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 971 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 972 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 973 | |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | static int i915_gfxec(struct seq_file *m, void *unused) |
| 978 | { |
| 979 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 980 | struct drm_device *dev = node->minor->dev; |
| 981 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 982 | |
| 983 | seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4)); |
| 984 | |
| 985 | return 0; |
| 986 | } |
| 987 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 988 | static int i915_opregion(struct seq_file *m, void *unused) |
| 989 | { |
| 990 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 991 | struct drm_device *dev = node->minor->dev; |
| 992 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 993 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 994 | int ret; |
| 995 | |
| 996 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 997 | if (ret) |
| 998 | return ret; |
| 999 | |
| 1000 | if (opregion->header) |
| 1001 | seq_write(m, opregion->header, OPREGION_SIZE); |
| 1002 | |
| 1003 | mutex_unlock(&dev->struct_mutex); |
| 1004 | |
| 1005 | return 0; |
| 1006 | } |
| 1007 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1008 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1009 | { |
| 1010 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1011 | struct drm_device *dev = node->minor->dev; |
| 1012 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1013 | struct intel_fbdev *ifbdev; |
| 1014 | struct intel_framebuffer *fb; |
| 1015 | int ret; |
| 1016 | |
| 1017 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
| 1018 | if (ret) |
| 1019 | return ret; |
| 1020 | |
| 1021 | ifbdev = dev_priv->fbdev; |
| 1022 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1023 | |
| 1024 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ", |
| 1025 | fb->base.width, |
| 1026 | fb->base.height, |
| 1027 | fb->base.depth, |
| 1028 | fb->base.bits_per_pixel); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1029 | describe_obj(m, fb->obj); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1030 | seq_printf(m, "\n"); |
| 1031 | |
| 1032 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
| 1033 | if (&fb->base == ifbdev->helper.fb) |
| 1034 | continue; |
| 1035 | |
| 1036 | seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ", |
| 1037 | fb->base.width, |
| 1038 | fb->base.height, |
| 1039 | fb->base.depth, |
| 1040 | fb->base.bits_per_pixel); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1041 | describe_obj(m, fb->obj); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1042 | seq_printf(m, "\n"); |
| 1043 | } |
| 1044 | |
| 1045 | mutex_unlock(&dev->mode_config.mutex); |
| 1046 | |
| 1047 | return 0; |
| 1048 | } |
| 1049 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1050 | static int |
| 1051 | i915_wedged_open(struct inode *inode, |
| 1052 | struct file *filp) |
| 1053 | { |
| 1054 | filp->private_data = inode->i_private; |
| 1055 | return 0; |
| 1056 | } |
| 1057 | |
| 1058 | static ssize_t |
| 1059 | i915_wedged_read(struct file *filp, |
| 1060 | char __user *ubuf, |
| 1061 | size_t max, |
| 1062 | loff_t *ppos) |
| 1063 | { |
| 1064 | struct drm_device *dev = filp->private_data; |
| 1065 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1066 | char buf[80]; |
| 1067 | int len; |
| 1068 | |
| 1069 | len = snprintf(buf, sizeof (buf), |
| 1070 | "wedged : %d\n", |
| 1071 | atomic_read(&dev_priv->mm.wedged)); |
| 1072 | |
Dan Carpenter | f4433a8 | 2010-09-08 21:44:47 +0200 | [diff] [blame] | 1073 | if (len > sizeof (buf)) |
| 1074 | len = sizeof (buf); |
| 1075 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1076 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1077 | } |
| 1078 | |
| 1079 | static ssize_t |
| 1080 | i915_wedged_write(struct file *filp, |
| 1081 | const char __user *ubuf, |
| 1082 | size_t cnt, |
| 1083 | loff_t *ppos) |
| 1084 | { |
| 1085 | struct drm_device *dev = filp->private_data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1086 | char buf[20]; |
| 1087 | int val = 1; |
| 1088 | |
| 1089 | if (cnt > 0) { |
| 1090 | if (cnt > sizeof (buf) - 1) |
| 1091 | return -EINVAL; |
| 1092 | |
| 1093 | if (copy_from_user(buf, ubuf, cnt)) |
| 1094 | return -EFAULT; |
| 1095 | buf[cnt] = 0; |
| 1096 | |
| 1097 | val = simple_strtoul(buf, NULL, 0); |
| 1098 | } |
| 1099 | |
| 1100 | DRM_INFO("Manually setting wedged to %d\n", val); |
Chris Wilson | 527f9e9 | 2010-11-11 01:16:58 +0000 | [diff] [blame] | 1101 | i915_handle_error(dev, val); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1102 | |
| 1103 | return cnt; |
| 1104 | } |
| 1105 | |
| 1106 | static const struct file_operations i915_wedged_fops = { |
| 1107 | .owner = THIS_MODULE, |
| 1108 | .open = i915_wedged_open, |
| 1109 | .read = i915_wedged_read, |
| 1110 | .write = i915_wedged_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1111 | .llseek = default_llseek, |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1112 | }; |
| 1113 | |
| 1114 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 1115 | * allocated we need to hook into the minor for release. */ |
| 1116 | static int |
| 1117 | drm_add_fake_info_node(struct drm_minor *minor, |
| 1118 | struct dentry *ent, |
| 1119 | const void *key) |
| 1120 | { |
| 1121 | struct drm_info_node *node; |
| 1122 | |
| 1123 | node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); |
| 1124 | if (node == NULL) { |
| 1125 | debugfs_remove(ent); |
| 1126 | return -ENOMEM; |
| 1127 | } |
| 1128 | |
| 1129 | node->minor = minor; |
| 1130 | node->dent = ent; |
| 1131 | node->info_ent = (void *) key; |
| 1132 | list_add(&node->list, &minor->debugfs_nodes.list); |
| 1133 | |
| 1134 | return 0; |
| 1135 | } |
| 1136 | |
| 1137 | static int i915_wedged_create(struct dentry *root, struct drm_minor *minor) |
| 1138 | { |
| 1139 | struct drm_device *dev = minor->dev; |
| 1140 | struct dentry *ent; |
| 1141 | |
| 1142 | ent = debugfs_create_file("i915_wedged", |
| 1143 | S_IRUGO | S_IWUSR, |
| 1144 | root, dev, |
| 1145 | &i915_wedged_fops); |
| 1146 | if (IS_ERR(ent)) |
| 1147 | return PTR_ERR(ent); |
| 1148 | |
| 1149 | return drm_add_fake_info_node(minor, ent, &i915_wedged_fops); |
| 1150 | } |
Ben Gamari | 9e3a6d1 | 2009-07-01 22:26:53 -0400 | [diff] [blame] | 1151 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1152 | static struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 1153 | {"i915_capabilities", i915_capabilities, 0, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 1154 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 1155 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
| 1156 | {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST}, |
| 1157 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 1158 | {"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST}, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 1159 | {"i915_gem_deferred_free", i915_gem_object_list_info, 0, (void *) DEFERRED_FREE_LIST}, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 1160 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1161 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 1162 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1163 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1164 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame^] | 1165 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 1166 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 1167 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
| 1168 | {"i915_ringbuffer_data", i915_ringbuffer_data, 0, (void *)RCS}, |
| 1169 | {"i915_ringbuffer_info", i915_ringbuffer_info, 0, (void *)RCS}, |
| 1170 | {"i915_bsd_ringbuffer_data", i915_ringbuffer_data, 0, (void *)VCS}, |
| 1171 | {"i915_bsd_ringbuffer_info", i915_ringbuffer_info, 0, (void *)VCS}, |
| 1172 | {"i915_blt_ringbuffer_data", i915_ringbuffer_data, 0, (void *)BCS}, |
| 1173 | {"i915_blt_ringbuffer_info", i915_ringbuffer_info, 0, (void *)BCS}, |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 1174 | {"i915_batchbuffers", i915_batchbuffer_info, 0}, |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 1175 | {"i915_error_state", i915_error_state, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1176 | {"i915_rstdby_delays", i915_rstdby_delays, 0}, |
| 1177 | {"i915_cur_delayinfo", i915_cur_delayinfo, 0}, |
| 1178 | {"i915_delayfreq_table", i915_delayfreq_table, 0}, |
| 1179 | {"i915_inttoext_table", i915_inttoext_table, 0}, |
| 1180 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1181 | {"i915_emon_status", i915_emon_status, 0}, |
| 1182 | {"i915_gfxec", i915_gfxec, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1183 | {"i915_fbc_status", i915_fbc_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1184 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1185 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1186 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1187 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1188 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1189 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1190 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1191 | { |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1192 | int ret; |
| 1193 | |
| 1194 | ret = i915_wedged_create(minor->debugfs_root, minor); |
| 1195 | if (ret) |
| 1196 | return ret; |
| 1197 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1198 | return drm_debugfs_create_files(i915_debugfs_list, |
| 1199 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1200 | minor->debugfs_root, minor); |
| 1201 | } |
| 1202 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1203 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1204 | { |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1205 | drm_debugfs_remove_files(i915_debugfs_list, |
| 1206 | I915_DEBUGFS_ENTRIES, minor); |
Kristian Høgsberg | 33db679 | 2009-11-11 12:19:16 -0500 | [diff] [blame] | 1207 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, |
| 1208 | 1, minor); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1209 | } |
| 1210 | |
| 1211 | #endif /* CONFIG_DEBUG_FS */ |