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