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> |
Paul Gortmaker | 2d1a8a4 | 2011-08-30 18:16:33 -0400 | [diff] [blame] | 32 | #include <linux/export.h> |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 33 | #include "drmP.h" |
| 34 | #include "drm.h" |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 35 | #include "intel_drv.h" |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 36 | #include "intel_ringbuffer.h" |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 37 | #include "i915_drm.h" |
| 38 | #include "i915_drv.h" |
| 39 | |
| 40 | #define DRM_I915_RING_DEBUG 1 |
| 41 | |
| 42 | |
| 43 | #if defined(CONFIG_DEBUG_FS) |
| 44 | |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 45 | enum { |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 46 | ACTIVE_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 47 | FLUSHING_LIST, |
| 48 | INACTIVE_LIST, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 49 | PINNED_LIST, |
| 50 | DEFERRED_FREE_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 51 | }; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 52 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 53 | static const char *yesno(int v) |
| 54 | { |
| 55 | return v ? "yes" : "no"; |
| 56 | } |
| 57 | |
| 58 | static int i915_capabilities(struct seq_file *m, void *data) |
| 59 | { |
| 60 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 61 | struct drm_device *dev = node->minor->dev; |
| 62 | const struct intel_device_info *info = INTEL_INFO(dev); |
| 63 | |
| 64 | seq_printf(m, "gen: %d\n", info->gen); |
Paulo Zanoni | 03d00ac | 2011-10-14 18:17:41 -0300 | [diff] [blame] | 65 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev)); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 66 | #define B(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
| 67 | B(is_mobile); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 68 | B(is_i85x); |
| 69 | B(is_i915g); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 70 | B(is_i945gm); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 71 | B(is_g33); |
| 72 | B(need_gfx_hws); |
| 73 | B(is_g4x); |
| 74 | B(is_pineview); |
| 75 | B(is_broadwater); |
| 76 | B(is_crestline); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 77 | B(has_fbc); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 78 | B(has_pipe_cxsr); |
| 79 | B(has_hotplug); |
| 80 | B(cursor_needs_physical); |
| 81 | B(has_overlay); |
| 82 | B(overlay_needs_physical); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 83 | B(supports_tv); |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 84 | B(has_bsd_ring); |
| 85 | B(has_blt_ring); |
Eugeni Dodonov | 3d29b84 | 2012-01-17 14:43:53 -0200 | [diff] [blame] | 86 | B(has_llc); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 87 | #undef B |
| 88 | |
| 89 | return 0; |
| 90 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 91 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 92 | static const char *get_pin_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 93 | { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 94 | if (obj->user_pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 95 | return "P"; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 96 | else if (obj->pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 97 | return "p"; |
| 98 | else |
| 99 | return " "; |
| 100 | } |
| 101 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 102 | static const char *get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 103 | { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 104 | switch (obj->tiling_mode) { |
| 105 | default: |
| 106 | case I915_TILING_NONE: return " "; |
| 107 | case I915_TILING_X: return "X"; |
| 108 | case I915_TILING_Y: return "Y"; |
| 109 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Chris Wilson | 93dfb40 | 2011-03-29 16:59:50 -0700 | [diff] [blame] | 112 | static const char *cache_level_str(int type) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 113 | { |
| 114 | switch (type) { |
Chris Wilson | 93dfb40 | 2011-03-29 16:59:50 -0700 | [diff] [blame] | 115 | case I915_CACHE_NONE: return " uncached"; |
| 116 | case I915_CACHE_LLC: return " snooped (LLC)"; |
| 117 | case I915_CACHE_LLC_MLC: return " snooped (LLC+MLC)"; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 118 | default: return ""; |
| 119 | } |
| 120 | } |
| 121 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 122 | static void |
| 123 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 124 | { |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 125 | seq_printf(m, "%p: %s%s %8zd %04x %04x %d %d%s%s%s", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 126 | &obj->base, |
| 127 | get_pin_flag(obj), |
| 128 | get_tiling_flag(obj), |
| 129 | obj->base.size, |
| 130 | obj->base.read_domains, |
| 131 | obj->base.write_domain, |
| 132 | obj->last_rendering_seqno, |
Chris Wilson | caea747 | 2010-11-12 13:53:37 +0000 | [diff] [blame] | 133 | obj->last_fenced_seqno, |
Chris Wilson | 93dfb40 | 2011-03-29 16:59:50 -0700 | [diff] [blame] | 134 | cache_level_str(obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 135 | obj->dirty ? " dirty" : "", |
| 136 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 137 | if (obj->base.name) |
| 138 | seq_printf(m, " (name: %d)", obj->base.name); |
| 139 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 140 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
| 141 | if (obj->gtt_space != NULL) |
Chris Wilson | a00b10c | 2010-09-24 21:15:47 +0100 | [diff] [blame] | 142 | seq_printf(m, " (gtt offset: %08x, size: %08x)", |
| 143 | obj->gtt_offset, (unsigned int)obj->gtt_space->size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 144 | if (obj->pin_mappable || obj->fault_mappable) { |
| 145 | char s[3], *t = s; |
| 146 | if (obj->pin_mappable) |
| 147 | *t++ = 'p'; |
| 148 | if (obj->fault_mappable) |
| 149 | *t++ = 'f'; |
| 150 | *t = '\0'; |
| 151 | seq_printf(m, " (%s mappable)", s); |
| 152 | } |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 153 | if (obj->ring != NULL) |
| 154 | seq_printf(m, " (%s)", obj->ring->name); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 155 | } |
| 156 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 157 | 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] | 158 | { |
| 159 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 160 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 161 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 162 | struct drm_device *dev = node->minor->dev; |
| 163 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 164 | struct drm_i915_gem_object *obj; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 165 | size_t total_obj_size, total_gtt_size; |
| 166 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 167 | |
| 168 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 169 | if (ret) |
| 170 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 171 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 172 | switch (list) { |
| 173 | case ACTIVE_LIST: |
| 174 | seq_printf(m, "Active:\n"); |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 175 | head = &dev_priv->mm.active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 176 | break; |
| 177 | case INACTIVE_LIST: |
Ben Gamari | a17458f | 2009-07-01 15:01:36 -0400 | [diff] [blame] | 178 | seq_printf(m, "Inactive:\n"); |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 179 | head = &dev_priv->mm.inactive_list; |
| 180 | break; |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 181 | case PINNED_LIST: |
| 182 | seq_printf(m, "Pinned:\n"); |
| 183 | head = &dev_priv->mm.pinned_list; |
| 184 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 185 | case FLUSHING_LIST: |
| 186 | seq_printf(m, "Flushing:\n"); |
| 187 | head = &dev_priv->mm.flushing_list; |
| 188 | break; |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 189 | case DEFERRED_FREE_LIST: |
| 190 | seq_printf(m, "Deferred free:\n"); |
| 191 | head = &dev_priv->mm.deferred_free_list; |
| 192 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 193 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 194 | mutex_unlock(&dev->struct_mutex); |
| 195 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 196 | } |
| 197 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 198 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 199 | list_for_each_entry(obj, head, mm_list) { |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 200 | seq_printf(m, " "); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 201 | describe_obj(m, obj); |
Eric Anholt | f4ceda8 | 2009-02-17 23:53:41 -0800 | [diff] [blame] | 202 | seq_printf(m, "\n"); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 203 | total_obj_size += obj->base.size; |
| 204 | total_gtt_size += obj->gtt_space->size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 205 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 206 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 207 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 208 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 209 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 210 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 211 | return 0; |
| 212 | } |
| 213 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 214 | #define count_objects(list, member) do { \ |
| 215 | list_for_each_entry(obj, list, member) { \ |
| 216 | size += obj->gtt_space->size; \ |
| 217 | ++count; \ |
| 218 | if (obj->map_and_fenceable) { \ |
| 219 | mappable_size += obj->gtt_space->size; \ |
| 220 | ++mappable_count; \ |
| 221 | } \ |
| 222 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 223 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 224 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 225 | static int i915_gem_object_info(struct seq_file *m, void* data) |
| 226 | { |
| 227 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 228 | struct drm_device *dev = node->minor->dev; |
| 229 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 230 | u32 count, mappable_count; |
| 231 | size_t size, mappable_size; |
| 232 | struct drm_i915_gem_object *obj; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 233 | int ret; |
| 234 | |
| 235 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 236 | if (ret) |
| 237 | return ret; |
| 238 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 239 | seq_printf(m, "%u objects, %zu bytes\n", |
| 240 | dev_priv->mm.object_count, |
| 241 | dev_priv->mm.object_memory); |
| 242 | |
| 243 | size = count = mappable_size = mappable_count = 0; |
| 244 | count_objects(&dev_priv->mm.gtt_list, gtt_list); |
| 245 | seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", |
| 246 | count, mappable_count, size, mappable_size); |
| 247 | |
| 248 | size = count = mappable_size = mappable_count = 0; |
| 249 | count_objects(&dev_priv->mm.active_list, mm_list); |
| 250 | count_objects(&dev_priv->mm.flushing_list, mm_list); |
| 251 | seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n", |
| 252 | count, mappable_count, size, mappable_size); |
| 253 | |
| 254 | size = count = mappable_size = mappable_count = 0; |
| 255 | count_objects(&dev_priv->mm.pinned_list, mm_list); |
| 256 | seq_printf(m, " %u [%u] pinned objects, %zu [%zu] bytes\n", |
| 257 | count, mappable_count, size, mappable_size); |
| 258 | |
| 259 | size = count = mappable_size = mappable_count = 0; |
| 260 | count_objects(&dev_priv->mm.inactive_list, mm_list); |
| 261 | seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n", |
| 262 | count, mappable_count, size, mappable_size); |
| 263 | |
| 264 | size = count = mappable_size = mappable_count = 0; |
| 265 | count_objects(&dev_priv->mm.deferred_free_list, mm_list); |
| 266 | seq_printf(m, " %u [%u] freed objects, %zu [%zu] bytes\n", |
| 267 | count, mappable_count, size, mappable_size); |
| 268 | |
| 269 | size = count = mappable_size = mappable_count = 0; |
| 270 | list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { |
| 271 | if (obj->fault_mappable) { |
| 272 | size += obj->gtt_space->size; |
| 273 | ++count; |
| 274 | } |
| 275 | if (obj->pin_mappable) { |
| 276 | mappable_size += obj->gtt_space->size; |
| 277 | ++mappable_count; |
| 278 | } |
| 279 | } |
| 280 | seq_printf(m, "%u pinned mappable objects, %zu bytes\n", |
| 281 | mappable_count, mappable_size); |
| 282 | seq_printf(m, "%u fault mappable objects, %zu bytes\n", |
| 283 | count, size); |
| 284 | |
| 285 | seq_printf(m, "%zu [%zu] gtt total\n", |
| 286 | dev_priv->mm.gtt_total, dev_priv->mm.mappable_gtt_total); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 287 | |
| 288 | mutex_unlock(&dev->struct_mutex); |
| 289 | |
| 290 | return 0; |
| 291 | } |
| 292 | |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 293 | static int i915_gem_gtt_info(struct seq_file *m, void* data) |
| 294 | { |
| 295 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 296 | struct drm_device *dev = node->minor->dev; |
| 297 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 298 | struct drm_i915_gem_object *obj; |
| 299 | size_t total_obj_size, total_gtt_size; |
| 300 | int count, ret; |
| 301 | |
| 302 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 303 | if (ret) |
| 304 | return ret; |
| 305 | |
| 306 | total_obj_size = total_gtt_size = count = 0; |
| 307 | list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { |
| 308 | seq_printf(m, " "); |
| 309 | describe_obj(m, obj); |
| 310 | seq_printf(m, "\n"); |
| 311 | total_obj_size += obj->base.size; |
| 312 | total_gtt_size += obj->gtt_space->size; |
| 313 | count++; |
| 314 | } |
| 315 | |
| 316 | mutex_unlock(&dev->struct_mutex); |
| 317 | |
| 318 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 319 | count, total_obj_size, total_gtt_size); |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 324 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 325 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 326 | { |
| 327 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 328 | struct drm_device *dev = node->minor->dev; |
| 329 | unsigned long flags; |
| 330 | struct intel_crtc *crtc; |
| 331 | |
| 332 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 333 | const char pipe = pipe_name(crtc->pipe); |
| 334 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 335 | struct intel_unpin_work *work; |
| 336 | |
| 337 | spin_lock_irqsave(&dev->event_lock, flags); |
| 338 | work = crtc->unpin_work; |
| 339 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 340 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 341 | pipe, plane); |
| 342 | } else { |
| 343 | if (!work->pending) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 344 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 345 | pipe, plane); |
| 346 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 347 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 348 | pipe, plane); |
| 349 | } |
| 350 | if (work->enable_stall_check) |
| 351 | seq_printf(m, "Stall check enabled, "); |
| 352 | else |
| 353 | seq_printf(m, "Stall check waiting for page flip ioctl, "); |
| 354 | seq_printf(m, "%d prepares\n", work->pending); |
| 355 | |
| 356 | if (work->old_fb_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 357 | struct drm_i915_gem_object *obj = work->old_fb_obj; |
| 358 | if (obj) |
| 359 | 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] | 360 | } |
| 361 | if (work->pending_flip_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 362 | struct drm_i915_gem_object *obj = work->pending_flip_obj; |
| 363 | if (obj) |
| 364 | 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] | 365 | } |
| 366 | } |
| 367 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 368 | } |
| 369 | |
| 370 | return 0; |
| 371 | } |
| 372 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 373 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 374 | { |
| 375 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 376 | struct drm_device *dev = node->minor->dev; |
| 377 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 378 | struct drm_i915_gem_request *gem_request; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 379 | int ret, count; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 380 | |
| 381 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 382 | if (ret) |
| 383 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 384 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 385 | count = 0; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 386 | if (!list_empty(&dev_priv->ring[RCS].request_list)) { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 387 | seq_printf(m, "Render requests:\n"); |
| 388 | list_for_each_entry(gem_request, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 389 | &dev_priv->ring[RCS].request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 390 | list) { |
| 391 | seq_printf(m, " %d @ %d\n", |
| 392 | gem_request->seqno, |
| 393 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 394 | } |
| 395 | count++; |
| 396 | } |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 397 | if (!list_empty(&dev_priv->ring[VCS].request_list)) { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 398 | seq_printf(m, "BSD requests:\n"); |
| 399 | list_for_each_entry(gem_request, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 400 | &dev_priv->ring[VCS].request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 401 | list) { |
| 402 | seq_printf(m, " %d @ %d\n", |
| 403 | gem_request->seqno, |
| 404 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 405 | } |
| 406 | count++; |
| 407 | } |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 408 | if (!list_empty(&dev_priv->ring[BCS].request_list)) { |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 409 | seq_printf(m, "BLT requests:\n"); |
| 410 | list_for_each_entry(gem_request, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 411 | &dev_priv->ring[BCS].request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 412 | list) { |
| 413 | seq_printf(m, " %d @ %d\n", |
| 414 | gem_request->seqno, |
| 415 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 416 | } |
| 417 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 418 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 419 | mutex_unlock(&dev->struct_mutex); |
| 420 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 421 | if (count == 0) |
| 422 | seq_printf(m, "No requests\n"); |
| 423 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 424 | return 0; |
| 425 | } |
| 426 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 427 | static void i915_ring_seqno_info(struct seq_file *m, |
| 428 | struct intel_ring_buffer *ring) |
| 429 | { |
| 430 | if (ring->get_seqno) { |
| 431 | seq_printf(m, "Current sequence (%s): %d\n", |
| 432 | ring->name, ring->get_seqno(ring)); |
| 433 | seq_printf(m, "Waiter sequence (%s): %d\n", |
| 434 | ring->name, ring->waiting_seqno); |
| 435 | seq_printf(m, "IRQ sequence (%s): %d\n", |
| 436 | ring->name, ring->irq_seqno); |
| 437 | } |
| 438 | } |
| 439 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 440 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 441 | { |
| 442 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 443 | struct drm_device *dev = node->minor->dev; |
| 444 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 445 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 446 | |
| 447 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 448 | if (ret) |
| 449 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 450 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 451 | for (i = 0; i < I915_NUM_RINGS; i++) |
| 452 | i915_ring_seqno_info(m, &dev_priv->ring[i]); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 453 | |
| 454 | mutex_unlock(&dev->struct_mutex); |
| 455 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 456 | return 0; |
| 457 | } |
| 458 | |
| 459 | |
| 460 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 461 | { |
| 462 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 463 | struct drm_device *dev = node->minor->dev; |
| 464 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 465 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 466 | |
| 467 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 468 | if (ret) |
| 469 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 470 | |
Eric Anholt | bad720f | 2009-10-22 16:11:14 -0700 | [diff] [blame] | 471 | if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 472 | seq_printf(m, "Interrupt enable: %08x\n", |
| 473 | I915_READ(IER)); |
| 474 | seq_printf(m, "Interrupt identity: %08x\n", |
| 475 | I915_READ(IIR)); |
| 476 | seq_printf(m, "Interrupt mask: %08x\n", |
| 477 | I915_READ(IMR)); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 478 | for_each_pipe(pipe) |
| 479 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 480 | pipe_name(pipe), |
| 481 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 482 | } else { |
| 483 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 484 | I915_READ(DEIER)); |
| 485 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 486 | I915_READ(DEIIR)); |
| 487 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 488 | I915_READ(DEIMR)); |
| 489 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 490 | I915_READ(SDEIER)); |
| 491 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 492 | I915_READ(SDEIIR)); |
| 493 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 494 | I915_READ(SDEIMR)); |
| 495 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 496 | I915_READ(GTIER)); |
| 497 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 498 | I915_READ(GTIIR)); |
| 499 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 500 | I915_READ(GTIMR)); |
| 501 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 502 | seq_printf(m, "Interrupts received: %d\n", |
| 503 | atomic_read(&dev_priv->irq_received)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 504 | for (i = 0; i < I915_NUM_RINGS; i++) { |
Jesse Barnes | da64c6f | 2011-08-09 09:17:46 -0700 | [diff] [blame] | 505 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 506 | seq_printf(m, "Graphics Interrupt mask (%s): %08x\n", |
| 507 | dev_priv->ring[i].name, |
| 508 | I915_READ_IMR(&dev_priv->ring[i])); |
| 509 | } |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 510 | i915_ring_seqno_info(m, &dev_priv->ring[i]); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 511 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 512 | mutex_unlock(&dev->struct_mutex); |
| 513 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 514 | return 0; |
| 515 | } |
| 516 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 517 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 518 | { |
| 519 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 520 | struct drm_device *dev = node->minor->dev; |
| 521 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 522 | int i, ret; |
| 523 | |
| 524 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 525 | if (ret) |
| 526 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 527 | |
| 528 | seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start); |
| 529 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 530 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 531 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 532 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 533 | seq_printf(m, "Fenced object[%2d] = ", i); |
| 534 | if (obj == NULL) |
| 535 | seq_printf(m, "unused"); |
| 536 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 537 | describe_obj(m, obj); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 538 | seq_printf(m, "\n"); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 541 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 542 | return 0; |
| 543 | } |
| 544 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 545 | static int i915_hws_info(struct seq_file *m, void *data) |
| 546 | { |
| 547 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 548 | struct drm_device *dev = node->minor->dev; |
| 549 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 550 | struct intel_ring_buffer *ring; |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 551 | const volatile u32 __iomem *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 552 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 553 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 554 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 555 | hws = (volatile u32 __iomem *)ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 556 | if (hws == NULL) |
| 557 | return 0; |
| 558 | |
| 559 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 560 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 561 | i * 4, |
| 562 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 563 | } |
| 564 | return 0; |
| 565 | } |
| 566 | |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 567 | static int i915_ringbuffer_data(struct seq_file *m, void *data) |
| 568 | { |
| 569 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 570 | struct drm_device *dev = node->minor->dev; |
| 571 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 572 | struct intel_ring_buffer *ring; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 573 | int ret; |
| 574 | |
| 575 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 576 | if (ret) |
| 577 | return ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 578 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 579 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 580 | if (!ring->obj) { |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 581 | seq_printf(m, "No ringbuffer setup\n"); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 582 | } else { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 583 | const u8 __iomem *virt = ring->virtual_start; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 584 | uint32_t off; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 585 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 586 | for (off = 0; off < ring->size; off += 4) { |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 587 | uint32_t *ptr = (uint32_t *)(virt + off); |
| 588 | seq_printf(m, "%08x : %08x\n", off, *ptr); |
| 589 | } |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 590 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 591 | mutex_unlock(&dev->struct_mutex); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 592 | |
| 593 | return 0; |
| 594 | } |
| 595 | |
| 596 | static int i915_ringbuffer_info(struct seq_file *m, void *data) |
| 597 | { |
| 598 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 599 | struct drm_device *dev = node->minor->dev; |
| 600 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 601 | struct intel_ring_buffer *ring; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 602 | int ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 603 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 604 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 605 | if (ring->size == 0) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 606 | return 0; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 607 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 608 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 609 | if (ret) |
| 610 | return ret; |
| 611 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 612 | seq_printf(m, "Ring %s:\n", ring->name); |
| 613 | seq_printf(m, " Head : %08x\n", I915_READ_HEAD(ring) & HEAD_ADDR); |
| 614 | seq_printf(m, " Tail : %08x\n", I915_READ_TAIL(ring) & TAIL_ADDR); |
| 615 | seq_printf(m, " Size : %08x\n", ring->size); |
| 616 | seq_printf(m, " Active : %08x\n", intel_ring_get_active_head(ring)); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 617 | seq_printf(m, " NOPID : %08x\n", I915_READ_NOPID(ring)); |
| 618 | if (IS_GEN6(dev)) { |
| 619 | seq_printf(m, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring)); |
| 620 | seq_printf(m, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring)); |
| 621 | } |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 622 | seq_printf(m, " Control : %08x\n", I915_READ_CTL(ring)); |
| 623 | seq_printf(m, " Start : %08x\n", I915_READ_START(ring)); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 624 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 625 | mutex_unlock(&dev->struct_mutex); |
| 626 | |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 627 | return 0; |
| 628 | } |
| 629 | |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 630 | static const char *ring_str(int ring) |
| 631 | { |
| 632 | switch (ring) { |
Daniel Vetter | 96154f2 | 2011-12-14 13:57:00 +0100 | [diff] [blame] | 633 | case RCS: return "render"; |
| 634 | case VCS: return "bsd"; |
| 635 | case BCS: return "blt"; |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 636 | default: return ""; |
| 637 | } |
| 638 | } |
| 639 | |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 640 | static const char *pin_flag(int pinned) |
| 641 | { |
| 642 | if (pinned > 0) |
| 643 | return " P"; |
| 644 | else if (pinned < 0) |
| 645 | return " p"; |
| 646 | else |
| 647 | return ""; |
| 648 | } |
| 649 | |
| 650 | static const char *tiling_flag(int tiling) |
| 651 | { |
| 652 | switch (tiling) { |
| 653 | default: |
| 654 | case I915_TILING_NONE: return ""; |
| 655 | case I915_TILING_X: return " X"; |
| 656 | case I915_TILING_Y: return " Y"; |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | static const char *dirty_flag(int dirty) |
| 661 | { |
| 662 | return dirty ? " dirty" : ""; |
| 663 | } |
| 664 | |
| 665 | static const char *purgeable_flag(int purgeable) |
| 666 | { |
| 667 | return purgeable ? " purgeable" : ""; |
| 668 | } |
| 669 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 670 | static void print_error_buffers(struct seq_file *m, |
| 671 | const char *name, |
| 672 | struct drm_i915_error_buffer *err, |
| 673 | int count) |
| 674 | { |
| 675 | seq_printf(m, "%s [%d]:\n", name, count); |
| 676 | |
| 677 | while (count--) { |
Daniel Vetter | 96154f2 | 2011-12-14 13:57:00 +0100 | [diff] [blame] | 678 | seq_printf(m, " %08x %8u %04x %04x %08x%s%s%s%s%s%s%s", |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 679 | err->gtt_offset, |
| 680 | err->size, |
| 681 | err->read_domains, |
| 682 | err->write_domain, |
| 683 | err->seqno, |
| 684 | pin_flag(err->pinned), |
| 685 | tiling_flag(err->tiling), |
| 686 | dirty_flag(err->dirty), |
| 687 | purgeable_flag(err->purgeable), |
Daniel Vetter | 96154f2 | 2011-12-14 13:57:00 +0100 | [diff] [blame] | 688 | err->ring != -1 ? " " : "", |
Chris Wilson | a779e5a | 2011-01-09 21:07:49 +0000 | [diff] [blame] | 689 | ring_str(err->ring), |
Chris Wilson | 93dfb40 | 2011-03-29 16:59:50 -0700 | [diff] [blame] | 690 | cache_level_str(err->cache_level)); |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 691 | |
| 692 | if (err->name) |
| 693 | seq_printf(m, " (name: %d)", err->name); |
| 694 | if (err->fence_reg != I915_FENCE_REG_NONE) |
| 695 | seq_printf(m, " (fence: %d)", err->fence_reg); |
| 696 | |
| 697 | seq_printf(m, "\n"); |
| 698 | err++; |
| 699 | } |
| 700 | } |
| 701 | |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 702 | static void i915_ring_error_state(struct seq_file *m, |
| 703 | struct drm_device *dev, |
| 704 | struct drm_i915_error_state *error, |
| 705 | unsigned ring) |
| 706 | { |
| 707 | seq_printf(m, "%s command stream:\n", ring_str(ring)); |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 708 | seq_printf(m, " HEAD: 0x%08x\n", error->head[ring]); |
| 709 | seq_printf(m, " TAIL: 0x%08x\n", error->tail[ring]); |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 710 | seq_printf(m, " ACTHD: 0x%08x\n", error->acthd[ring]); |
| 711 | seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir[ring]); |
| 712 | seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr[ring]); |
| 713 | seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone[ring]); |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 714 | if (ring == RCS && INTEL_INFO(dev)->gen >= 4) { |
| 715 | seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1); |
| 716 | seq_printf(m, " BBADDR: 0x%08llx\n", error->bbaddr); |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 717 | } |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 718 | if (INTEL_INFO(dev)->gen >= 4) |
| 719 | seq_printf(m, " INSTPS: 0x%08x\n", error->instps[ring]); |
| 720 | seq_printf(m, " INSTPM: 0x%08x\n", error->instpm[ring]); |
Daniel Vetter | 33f3f51 | 2011-12-14 13:57:39 +0100 | [diff] [blame] | 721 | if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 722 | seq_printf(m, " FADDR: 0x%08x\n", error->faddr[ring]); |
Daniel Vetter | 33f3f51 | 2011-12-14 13:57:39 +0100 | [diff] [blame] | 723 | seq_printf(m, " FAULT_REG: 0x%08x\n", error->fault_reg[ring]); |
Daniel Vetter | 7e3b873 | 2012-02-01 22:26:45 +0100 | [diff] [blame] | 724 | seq_printf(m, " SYNC_0: 0x%08x\n", |
| 725 | error->semaphore_mboxes[ring][0]); |
| 726 | seq_printf(m, " SYNC_1: 0x%08x\n", |
| 727 | error->semaphore_mboxes[ring][1]); |
Daniel Vetter | 33f3f51 | 2011-12-14 13:57:39 +0100 | [diff] [blame] | 728 | } |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 729 | seq_printf(m, " seqno: 0x%08x\n", error->seqno[ring]); |
Daniel Vetter | 7e3b873 | 2012-02-01 22:26:45 +0100 | [diff] [blame] | 730 | seq_printf(m, " ring->head: 0x%08x\n", error->cpu_ring_head[ring]); |
| 731 | seq_printf(m, " ring->tail: 0x%08x\n", error->cpu_ring_tail[ring]); |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 732 | } |
| 733 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 734 | static int i915_error_state(struct seq_file *m, void *unused) |
| 735 | { |
| 736 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 737 | struct drm_device *dev = node->minor->dev; |
| 738 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 739 | struct drm_i915_error_state *error; |
| 740 | unsigned long flags; |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 741 | int i, page, offset, elt; |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 742 | |
| 743 | spin_lock_irqsave(&dev_priv->error_lock, flags); |
| 744 | if (!dev_priv->first_error) { |
| 745 | seq_printf(m, "no error state collected\n"); |
| 746 | goto out; |
| 747 | } |
| 748 | |
| 749 | error = dev_priv->first_error; |
| 750 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 751 | seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec, |
| 752 | error->time.tv_usec); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 753 | seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 754 | seq_printf(m, "EIR: 0x%08x\n", error->eir); |
| 755 | seq_printf(m, "PGTBL_ER: 0x%08x\n", error->pgtbl_er); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 756 | |
Daniel Vetter | bf3301a | 2011-05-12 22:17:12 +0100 | [diff] [blame] | 757 | for (i = 0; i < dev_priv->num_fence_regs; i++) |
Chris Wilson | 748ebc6 | 2010-10-24 10:28:47 +0100 | [diff] [blame] | 758 | seq_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]); |
| 759 | |
Daniel Vetter | 33f3f51 | 2011-12-14 13:57:39 +0100 | [diff] [blame] | 760 | if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 761 | seq_printf(m, "ERROR: 0x%08x\n", error->error); |
Daniel Vetter | 33f3f51 | 2011-12-14 13:57:39 +0100 | [diff] [blame] | 762 | seq_printf(m, "DONE_REG: 0x%08x\n", error->done_reg); |
| 763 | } |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 764 | |
| 765 | i915_ring_error_state(m, dev, error, RCS); |
| 766 | if (HAS_BLT(dev)) |
| 767 | i915_ring_error_state(m, dev, error, BCS); |
| 768 | if (HAS_BSD(dev)) |
| 769 | i915_ring_error_state(m, dev, error, VCS); |
| 770 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 771 | if (error->active_bo) |
| 772 | print_error_buffers(m, "Active", |
| 773 | error->active_bo, |
| 774 | error->active_bo_count); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 775 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 776 | if (error->pinned_bo) |
| 777 | print_error_buffers(m, "Pinned", |
| 778 | error->pinned_bo, |
| 779 | error->pinned_bo_count); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 780 | |
| 781 | for (i = 0; i < ARRAY_SIZE(error->batchbuffer); i++) { |
| 782 | if (error->batchbuffer[i]) { |
| 783 | struct drm_i915_error_object *obj = error->batchbuffer[i]; |
| 784 | |
Chris Wilson | bcfb2e2 | 2011-01-07 21:06:07 +0000 | [diff] [blame] | 785 | seq_printf(m, "%s --- gtt_offset = 0x%08x\n", |
| 786 | dev_priv->ring[i].name, |
| 787 | obj->gtt_offset); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 788 | offset = 0; |
| 789 | for (page = 0; page < obj->page_count; page++) { |
| 790 | for (elt = 0; elt < PAGE_SIZE/4; elt++) { |
| 791 | seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]); |
| 792 | offset += 4; |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | |
Chris Wilson | e2f973d | 2011-01-27 19:15:11 +0000 | [diff] [blame] | 798 | for (i = 0; i < ARRAY_SIZE(error->ringbuffer); i++) { |
| 799 | if (error->ringbuffer[i]) { |
| 800 | struct drm_i915_error_object *obj = error->ringbuffer[i]; |
| 801 | seq_printf(m, "%s --- ringbuffer = 0x%08x\n", |
| 802 | dev_priv->ring[i].name, |
| 803 | obj->gtt_offset); |
| 804 | offset = 0; |
| 805 | for (page = 0; page < obj->page_count; page++) { |
| 806 | for (elt = 0; elt < PAGE_SIZE/4; elt++) { |
| 807 | seq_printf(m, "%08x : %08x\n", |
| 808 | offset, |
| 809 | obj->pages[page][elt]); |
| 810 | offset += 4; |
| 811 | } |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 812 | } |
| 813 | } |
| 814 | } |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 815 | |
Chris Wilson | 6ef3d42 | 2010-08-04 20:26:07 +0100 | [diff] [blame] | 816 | if (error->overlay) |
| 817 | intel_overlay_print_error_state(m, error->overlay); |
| 818 | |
Chris Wilson | c4a1d9e | 2010-11-21 13:12:35 +0000 | [diff] [blame] | 819 | if (error->display) |
| 820 | intel_display_print_error_state(m, dev, error->display); |
| 821 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 822 | out: |
| 823 | spin_unlock_irqrestore(&dev_priv->error_lock, flags); |
| 824 | |
| 825 | return 0; |
| 826 | } |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 827 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 828 | static int i915_rstdby_delays(struct seq_file *m, void *unused) |
| 829 | { |
| 830 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 831 | struct drm_device *dev = node->minor->dev; |
| 832 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 833 | u16 crstanddelay; |
| 834 | int ret; |
| 835 | |
| 836 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 837 | if (ret) |
| 838 | return ret; |
| 839 | |
| 840 | crstanddelay = I915_READ16(CRSTANDVID); |
| 841 | |
| 842 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 843 | |
| 844 | seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f)); |
| 845 | |
| 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | static int i915_cur_delayinfo(struct seq_file *m, void *unused) |
| 850 | { |
| 851 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 852 | struct drm_device *dev = node->minor->dev; |
| 853 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 854 | int ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 855 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 856 | if (IS_GEN5(dev)) { |
| 857 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 858 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 859 | |
| 860 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 861 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 862 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 863 | MEMSTAT_VID_SHIFT); |
| 864 | seq_printf(m, "Current P-state: %d\n", |
| 865 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 866 | } else if (IS_GEN6(dev) || IS_GEN7(dev)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 867 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 868 | u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 869 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 870 | u32 rpstat; |
| 871 | u32 rpupei, rpcurup, rpprevup; |
| 872 | u32 rpdownei, rpcurdown, rpprevdown; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 873 | int max_freq; |
| 874 | |
| 875 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 876 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 877 | if (ret) |
| 878 | return ret; |
| 879 | |
Ben Widawsky | fcca792 | 2011-04-25 11:23:07 -0700 | [diff] [blame] | 880 | gen6_gt_force_wake_get(dev_priv); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 881 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 882 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 883 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 884 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 885 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 886 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 887 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 888 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
| 889 | |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 890 | gen6_gt_force_wake_put(dev_priv); |
| 891 | mutex_unlock(&dev->struct_mutex); |
| 892 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 893 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 894 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 895 | seq_printf(m, "Render p-state ratio: %d\n", |
| 896 | (gt_perf_status & 0xff00) >> 8); |
| 897 | seq_printf(m, "Render p-state VID: %d\n", |
| 898 | gt_perf_status & 0xff); |
| 899 | seq_printf(m, "Render p-state limit: %d\n", |
| 900 | rp_state_limits & 0xff); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 901 | seq_printf(m, "CAGF: %dMHz\n", ((rpstat & GEN6_CAGF_MASK) >> |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 902 | GEN6_CAGF_SHIFT) * 50); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 903 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 904 | GEN6_CURICONT_MASK); |
| 905 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 906 | GEN6_CURBSYTAVG_MASK); |
| 907 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 908 | GEN6_CURBSYTAVG_MASK); |
| 909 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 910 | GEN6_CURIAVG_MASK); |
| 911 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 912 | GEN6_CURBSYTAVG_MASK); |
| 913 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 914 | GEN6_CURBSYTAVG_MASK); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 915 | |
| 916 | max_freq = (rp_state_cap & 0xff0000) >> 16; |
| 917 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 918 | max_freq * 50); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 919 | |
| 920 | max_freq = (rp_state_cap & 0xff00) >> 8; |
| 921 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 922 | max_freq * 50); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 923 | |
| 924 | max_freq = rp_state_cap & 0xff; |
| 925 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 926 | max_freq * 50); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 927 | } else { |
| 928 | seq_printf(m, "no P-state info available\n"); |
| 929 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 930 | |
| 931 | return 0; |
| 932 | } |
| 933 | |
| 934 | static int i915_delayfreq_table(struct seq_file *m, void *unused) |
| 935 | { |
| 936 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 937 | struct drm_device *dev = node->minor->dev; |
| 938 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 939 | u32 delayfreq; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 940 | int ret, i; |
| 941 | |
| 942 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 943 | if (ret) |
| 944 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 945 | |
| 946 | for (i = 0; i < 16; i++) { |
| 947 | delayfreq = I915_READ(PXVFREQ_BASE + i * 4); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 948 | seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq, |
| 949 | (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 950 | } |
| 951 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 952 | mutex_unlock(&dev->struct_mutex); |
| 953 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 954 | return 0; |
| 955 | } |
| 956 | |
| 957 | static inline int MAP_TO_MV(int map) |
| 958 | { |
| 959 | return 1250 - (map * 25); |
| 960 | } |
| 961 | |
| 962 | static int i915_inttoext_table(struct seq_file *m, void *unused) |
| 963 | { |
| 964 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 965 | struct drm_device *dev = node->minor->dev; |
| 966 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 967 | u32 inttoext; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 968 | int ret, i; |
| 969 | |
| 970 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 971 | if (ret) |
| 972 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 973 | |
| 974 | for (i = 1; i <= 32; i++) { |
| 975 | inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4); |
| 976 | seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext); |
| 977 | } |
| 978 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 979 | mutex_unlock(&dev->struct_mutex); |
| 980 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 981 | return 0; |
| 982 | } |
| 983 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 984 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 985 | { |
| 986 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 987 | struct drm_device *dev = node->minor->dev; |
| 988 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 989 | u32 rgvmodectl, rstdbyctl; |
| 990 | u16 crstandvid; |
| 991 | int ret; |
| 992 | |
| 993 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 994 | if (ret) |
| 995 | return ret; |
| 996 | |
| 997 | rgvmodectl = I915_READ(MEMMODECTL); |
| 998 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 999 | crstandvid = I915_READ16(CRSTANDVID); |
| 1000 | |
| 1001 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1002 | |
| 1003 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1004 | "yes" : "no"); |
| 1005 | seq_printf(m, "Boost freq: %d\n", |
| 1006 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1007 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1008 | seq_printf(m, "HW control enabled: %s\n", |
| 1009 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1010 | seq_printf(m, "SW control enabled: %s\n", |
| 1011 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1012 | seq_printf(m, "Gated voltage change: %s\n", |
| 1013 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1014 | seq_printf(m, "Starting frequency: P%d\n", |
| 1015 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1016 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1017 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1018 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1019 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1020 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1021 | seq_printf(m, "Render standby enabled: %s\n", |
| 1022 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1023 | seq_printf(m, "Current RS state: "); |
| 1024 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1025 | case RSX_STATUS_ON: |
| 1026 | seq_printf(m, "on\n"); |
| 1027 | break; |
| 1028 | case RSX_STATUS_RC1: |
| 1029 | seq_printf(m, "RC1\n"); |
| 1030 | break; |
| 1031 | case RSX_STATUS_RC1E: |
| 1032 | seq_printf(m, "RC1E\n"); |
| 1033 | break; |
| 1034 | case RSX_STATUS_RS1: |
| 1035 | seq_printf(m, "RS1\n"); |
| 1036 | break; |
| 1037 | case RSX_STATUS_RS2: |
| 1038 | seq_printf(m, "RS2 (RC6)\n"); |
| 1039 | break; |
| 1040 | case RSX_STATUS_RS3: |
| 1041 | seq_printf(m, "RC3 (RC6+)\n"); |
| 1042 | break; |
| 1043 | default: |
| 1044 | seq_printf(m, "unknown\n"); |
| 1045 | break; |
| 1046 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1047 | |
| 1048 | return 0; |
| 1049 | } |
| 1050 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1051 | static int gen6_drpc_info(struct seq_file *m) |
| 1052 | { |
| 1053 | |
| 1054 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1055 | struct drm_device *dev = node->minor->dev; |
| 1056 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1057 | u32 rpmodectl1, gt_core_status, rcctl1; |
| 1058 | int count=0, ret; |
| 1059 | |
| 1060 | |
| 1061 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1062 | if (ret) |
| 1063 | return ret; |
| 1064 | |
| 1065 | if (atomic_read(&dev_priv->forcewake_count)) { |
| 1066 | seq_printf(m, "RC information inaccurate because userspace " |
| 1067 | "holds a reference \n"); |
| 1068 | } else { |
| 1069 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1070 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1071 | udelay(10); |
| 1072 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1073 | } |
| 1074 | |
| 1075 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
| 1076 | trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4); |
| 1077 | |
| 1078 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1079 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1080 | mutex_unlock(&dev->struct_mutex); |
| 1081 | |
| 1082 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1083 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1084 | seq_printf(m, "HW control enabled: %s\n", |
| 1085 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1086 | seq_printf(m, "SW control enabled: %s\n", |
| 1087 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1088 | GEN6_RP_MEDIA_SW_MODE)); |
| 1089 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1090 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1091 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1092 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1093 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1094 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1095 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1096 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
| 1097 | seq_printf(m, "Current RC state: "); |
| 1098 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1099 | case GEN6_RC0: |
| 1100 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
| 1101 | seq_printf(m, "Core Power Down\n"); |
| 1102 | else |
| 1103 | seq_printf(m, "on\n"); |
| 1104 | break; |
| 1105 | case GEN6_RC3: |
| 1106 | seq_printf(m, "RC3\n"); |
| 1107 | break; |
| 1108 | case GEN6_RC6: |
| 1109 | seq_printf(m, "RC6\n"); |
| 1110 | break; |
| 1111 | case GEN6_RC7: |
| 1112 | seq_printf(m, "RC7\n"); |
| 1113 | break; |
| 1114 | default: |
| 1115 | seq_printf(m, "Unknown\n"); |
| 1116 | break; |
| 1117 | } |
| 1118 | |
| 1119 | seq_printf(m, "Core Power Down: %s\n", |
| 1120 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
| 1121 | return 0; |
| 1122 | } |
| 1123 | |
| 1124 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1125 | { |
| 1126 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1127 | struct drm_device *dev = node->minor->dev; |
| 1128 | |
| 1129 | if (IS_GEN6(dev) || IS_GEN7(dev)) |
| 1130 | return gen6_drpc_info(m); |
| 1131 | else |
| 1132 | return ironlake_drpc_info(m); |
| 1133 | } |
| 1134 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1135 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1136 | { |
| 1137 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1138 | struct drm_device *dev = node->minor->dev; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1139 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1140 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1141 | if (!I915_HAS_FBC(dev)) { |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1142 | seq_printf(m, "FBC unsupported on this chipset\n"); |
| 1143 | return 0; |
| 1144 | } |
| 1145 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1146 | if (intel_fbc_enabled(dev)) { |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1147 | seq_printf(m, "FBC enabled\n"); |
| 1148 | } else { |
| 1149 | seq_printf(m, "FBC disabled: "); |
| 1150 | switch (dev_priv->no_fbc_reason) { |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1151 | case FBC_NO_OUTPUT: |
| 1152 | seq_printf(m, "no outputs"); |
| 1153 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1154 | case FBC_STOLEN_TOO_SMALL: |
| 1155 | seq_printf(m, "not enough stolen memory"); |
| 1156 | break; |
| 1157 | case FBC_UNSUPPORTED_MODE: |
| 1158 | seq_printf(m, "mode not supported"); |
| 1159 | break; |
| 1160 | case FBC_MODE_TOO_LARGE: |
| 1161 | seq_printf(m, "mode too large"); |
| 1162 | break; |
| 1163 | case FBC_BAD_PLANE: |
| 1164 | seq_printf(m, "FBC unsupported on plane"); |
| 1165 | break; |
| 1166 | case FBC_NOT_TILED: |
| 1167 | seq_printf(m, "scanout buffer not tiled"); |
| 1168 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1169 | case FBC_MULTIPLE_PIPES: |
| 1170 | seq_printf(m, "multiple pipes are enabled"); |
| 1171 | break; |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1172 | case FBC_MODULE_PARAM: |
| 1173 | seq_printf(m, "disabled per module param (default off)"); |
| 1174 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1175 | default: |
| 1176 | seq_printf(m, "unknown reason"); |
| 1177 | } |
| 1178 | seq_printf(m, "\n"); |
| 1179 | } |
| 1180 | return 0; |
| 1181 | } |
| 1182 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1183 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1184 | { |
| 1185 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1186 | struct drm_device *dev = node->minor->dev; |
| 1187 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1188 | bool sr_enabled = false; |
| 1189 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1190 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1191 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1192 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1193 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1194 | else if (IS_I915GM(dev)) |
| 1195 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1196 | else if (IS_PINEVIEW(dev)) |
| 1197 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1198 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1199 | seq_printf(m, "self-refresh: %s\n", |
| 1200 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1201 | |
| 1202 | return 0; |
| 1203 | } |
| 1204 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1205 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1206 | { |
| 1207 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1208 | struct drm_device *dev = node->minor->dev; |
| 1209 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1210 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1211 | int ret; |
| 1212 | |
| 1213 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1214 | if (ret) |
| 1215 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1216 | |
| 1217 | temp = i915_mch_val(dev_priv); |
| 1218 | chipset = i915_chipset_val(dev_priv); |
| 1219 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1220 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1221 | |
| 1222 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1223 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1224 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1225 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1226 | |
| 1227 | return 0; |
| 1228 | } |
| 1229 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1230 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1231 | { |
| 1232 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1233 | struct drm_device *dev = node->minor->dev; |
| 1234 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1235 | int ret; |
| 1236 | int gpu_freq, ia_freq; |
| 1237 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1238 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1239 | seq_printf(m, "unsupported on this chipset\n"); |
| 1240 | return 0; |
| 1241 | } |
| 1242 | |
| 1243 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1244 | if (ret) |
| 1245 | return ret; |
| 1246 | |
| 1247 | seq_printf(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\n"); |
| 1248 | |
| 1249 | for (gpu_freq = dev_priv->min_delay; gpu_freq <= dev_priv->max_delay; |
| 1250 | gpu_freq++) { |
| 1251 | I915_WRITE(GEN6_PCODE_DATA, gpu_freq); |
| 1252 | I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | |
| 1253 | GEN6_PCODE_READ_MIN_FREQ_TABLE); |
| 1254 | if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & |
| 1255 | GEN6_PCODE_READY) == 0, 10)) { |
| 1256 | DRM_ERROR("pcode read of freq table timed out\n"); |
| 1257 | continue; |
| 1258 | } |
| 1259 | ia_freq = I915_READ(GEN6_PCODE_DATA); |
| 1260 | seq_printf(m, "%d\t\t%d\n", gpu_freq * 50, ia_freq * 100); |
| 1261 | } |
| 1262 | |
| 1263 | mutex_unlock(&dev->struct_mutex); |
| 1264 | |
| 1265 | return 0; |
| 1266 | } |
| 1267 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1268 | static int i915_gfxec(struct seq_file *m, void *unused) |
| 1269 | { |
| 1270 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1271 | struct drm_device *dev = node->minor->dev; |
| 1272 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1273 | int ret; |
| 1274 | |
| 1275 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1276 | if (ret) |
| 1277 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1278 | |
| 1279 | seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4)); |
| 1280 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1281 | mutex_unlock(&dev->struct_mutex); |
| 1282 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1283 | return 0; |
| 1284 | } |
| 1285 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1286 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1287 | { |
| 1288 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1289 | struct drm_device *dev = node->minor->dev; |
| 1290 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1291 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1292 | int ret; |
| 1293 | |
| 1294 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1295 | if (ret) |
| 1296 | return ret; |
| 1297 | |
| 1298 | if (opregion->header) |
| 1299 | seq_write(m, opregion->header, OPREGION_SIZE); |
| 1300 | |
| 1301 | mutex_unlock(&dev->struct_mutex); |
| 1302 | |
| 1303 | return 0; |
| 1304 | } |
| 1305 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1306 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1307 | { |
| 1308 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1309 | struct drm_device *dev = node->minor->dev; |
| 1310 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1311 | struct intel_fbdev *ifbdev; |
| 1312 | struct intel_framebuffer *fb; |
| 1313 | int ret; |
| 1314 | |
| 1315 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
| 1316 | if (ret) |
| 1317 | return ret; |
| 1318 | |
| 1319 | ifbdev = dev_priv->fbdev; |
| 1320 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1321 | |
| 1322 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ", |
| 1323 | fb->base.width, |
| 1324 | fb->base.height, |
| 1325 | fb->base.depth, |
| 1326 | fb->base.bits_per_pixel); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1327 | describe_obj(m, fb->obj); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1328 | seq_printf(m, "\n"); |
| 1329 | |
| 1330 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
| 1331 | if (&fb->base == ifbdev->helper.fb) |
| 1332 | continue; |
| 1333 | |
| 1334 | seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ", |
| 1335 | fb->base.width, |
| 1336 | fb->base.height, |
| 1337 | fb->base.depth, |
| 1338 | fb->base.bits_per_pixel); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1339 | describe_obj(m, fb->obj); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1340 | seq_printf(m, "\n"); |
| 1341 | } |
| 1342 | |
| 1343 | mutex_unlock(&dev->mode_config.mutex); |
| 1344 | |
| 1345 | return 0; |
| 1346 | } |
| 1347 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1348 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1349 | { |
| 1350 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1351 | struct drm_device *dev = node->minor->dev; |
| 1352 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1353 | int ret; |
| 1354 | |
| 1355 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
| 1356 | if (ret) |
| 1357 | return ret; |
| 1358 | |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1359 | if (dev_priv->pwrctx) { |
| 1360 | seq_printf(m, "power context "); |
| 1361 | describe_obj(m, dev_priv->pwrctx); |
| 1362 | seq_printf(m, "\n"); |
| 1363 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1364 | |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1365 | if (dev_priv->renderctx) { |
| 1366 | seq_printf(m, "render context "); |
| 1367 | describe_obj(m, dev_priv->renderctx); |
| 1368 | seq_printf(m, "\n"); |
| 1369 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1370 | |
| 1371 | mutex_unlock(&dev->mode_config.mutex); |
| 1372 | |
| 1373 | return 0; |
| 1374 | } |
| 1375 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1376 | static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data) |
| 1377 | { |
| 1378 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1379 | struct drm_device *dev = node->minor->dev; |
| 1380 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1381 | |
| 1382 | seq_printf(m, "forcewake count = %d\n", |
| 1383 | atomic_read(&dev_priv->forcewake_count)); |
| 1384 | |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1388 | static const char *swizzle_string(unsigned swizzle) |
| 1389 | { |
| 1390 | switch(swizzle) { |
| 1391 | case I915_BIT_6_SWIZZLE_NONE: |
| 1392 | return "none"; |
| 1393 | case I915_BIT_6_SWIZZLE_9: |
| 1394 | return "bit9"; |
| 1395 | case I915_BIT_6_SWIZZLE_9_10: |
| 1396 | return "bit9/bit10"; |
| 1397 | case I915_BIT_6_SWIZZLE_9_11: |
| 1398 | return "bit9/bit11"; |
| 1399 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1400 | return "bit9/bit10/bit11"; |
| 1401 | case I915_BIT_6_SWIZZLE_9_17: |
| 1402 | return "bit9/bit17"; |
| 1403 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1404 | return "bit9/bit10/bit17"; |
| 1405 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
| 1406 | return "unkown"; |
| 1407 | } |
| 1408 | |
| 1409 | return "bug"; |
| 1410 | } |
| 1411 | |
| 1412 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1413 | { |
| 1414 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1415 | struct drm_device *dev = node->minor->dev; |
| 1416 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1417 | |
| 1418 | mutex_lock(&dev->struct_mutex); |
| 1419 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1420 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1421 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1422 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1423 | |
| 1424 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 1425 | seq_printf(m, "DDC = 0x%08x\n", |
| 1426 | I915_READ(DCC)); |
| 1427 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1428 | I915_READ16(C0DRB3)); |
| 1429 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1430 | I915_READ16(C1DRB3)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1431 | } else if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1432 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1433 | I915_READ(MAD_DIMM_C0)); |
| 1434 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1435 | I915_READ(MAD_DIMM_C1)); |
| 1436 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1437 | I915_READ(MAD_DIMM_C2)); |
| 1438 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1439 | I915_READ(TILECTL)); |
| 1440 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 1441 | I915_READ(ARB_MODE)); |
| 1442 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 1443 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1444 | } |
| 1445 | mutex_unlock(&dev->struct_mutex); |
| 1446 | |
| 1447 | return 0; |
| 1448 | } |
| 1449 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame^] | 1450 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 1451 | { |
| 1452 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1453 | struct drm_device *dev = node->minor->dev; |
| 1454 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1455 | struct intel_ring_buffer *ring; |
| 1456 | int i, ret; |
| 1457 | |
| 1458 | |
| 1459 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1460 | if (ret) |
| 1461 | return ret; |
| 1462 | if (INTEL_INFO(dev)->gen == 6) |
| 1463 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 1464 | |
| 1465 | for (i = 0; i < I915_NUM_RINGS; i++) { |
| 1466 | ring = &dev_priv->ring[i]; |
| 1467 | |
| 1468 | seq_printf(m, "%s\n", ring->name); |
| 1469 | if (INTEL_INFO(dev)->gen == 7) |
| 1470 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 1471 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 1472 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 1473 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 1474 | } |
| 1475 | if (dev_priv->mm.aliasing_ppgtt) { |
| 1476 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 1477 | |
| 1478 | seq_printf(m, "aliasing PPGTT:\n"); |
| 1479 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset); |
| 1480 | } |
| 1481 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
| 1482 | mutex_unlock(&dev->struct_mutex); |
| 1483 | |
| 1484 | return 0; |
| 1485 | } |
| 1486 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1487 | static int |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1488 | i915_debugfs_common_open(struct inode *inode, |
| 1489 | struct file *filp) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1490 | { |
| 1491 | filp->private_data = inode->i_private; |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
| 1495 | static ssize_t |
| 1496 | i915_wedged_read(struct file *filp, |
| 1497 | char __user *ubuf, |
| 1498 | size_t max, |
| 1499 | loff_t *ppos) |
| 1500 | { |
| 1501 | struct drm_device *dev = filp->private_data; |
| 1502 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1503 | char buf[80]; |
| 1504 | int len; |
| 1505 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1506 | len = snprintf(buf, sizeof(buf), |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1507 | "wedged : %d\n", |
| 1508 | atomic_read(&dev_priv->mm.wedged)); |
| 1509 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1510 | if (len > sizeof(buf)) |
| 1511 | len = sizeof(buf); |
Dan Carpenter | f4433a8 | 2010-09-08 21:44:47 +0200 | [diff] [blame] | 1512 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1513 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1514 | } |
| 1515 | |
| 1516 | static ssize_t |
| 1517 | i915_wedged_write(struct file *filp, |
| 1518 | const char __user *ubuf, |
| 1519 | size_t cnt, |
| 1520 | loff_t *ppos) |
| 1521 | { |
| 1522 | struct drm_device *dev = filp->private_data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1523 | char buf[20]; |
| 1524 | int val = 1; |
| 1525 | |
| 1526 | if (cnt > 0) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1527 | if (cnt > sizeof(buf) - 1) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1528 | return -EINVAL; |
| 1529 | |
| 1530 | if (copy_from_user(buf, ubuf, cnt)) |
| 1531 | return -EFAULT; |
| 1532 | buf[cnt] = 0; |
| 1533 | |
| 1534 | val = simple_strtoul(buf, NULL, 0); |
| 1535 | } |
| 1536 | |
| 1537 | DRM_INFO("Manually setting wedged to %d\n", val); |
Chris Wilson | 527f9e9 | 2010-11-11 01:16:58 +0000 | [diff] [blame] | 1538 | i915_handle_error(dev, val); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1539 | |
| 1540 | return cnt; |
| 1541 | } |
| 1542 | |
| 1543 | static const struct file_operations i915_wedged_fops = { |
| 1544 | .owner = THIS_MODULE, |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1545 | .open = i915_debugfs_common_open, |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1546 | .read = i915_wedged_read, |
| 1547 | .write = i915_wedged_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1548 | .llseek = default_llseek, |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1549 | }; |
| 1550 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1551 | static ssize_t |
| 1552 | i915_max_freq_read(struct file *filp, |
| 1553 | char __user *ubuf, |
| 1554 | size_t max, |
| 1555 | loff_t *ppos) |
| 1556 | { |
| 1557 | struct drm_device *dev = filp->private_data; |
| 1558 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1559 | char buf[80]; |
| 1560 | int len; |
| 1561 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1562 | len = snprintf(buf, sizeof(buf), |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1563 | "max freq: %d\n", dev_priv->max_delay * 50); |
| 1564 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1565 | if (len > sizeof(buf)) |
| 1566 | len = sizeof(buf); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1567 | |
| 1568 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1569 | } |
| 1570 | |
| 1571 | static ssize_t |
| 1572 | i915_max_freq_write(struct file *filp, |
| 1573 | const char __user *ubuf, |
| 1574 | size_t cnt, |
| 1575 | loff_t *ppos) |
| 1576 | { |
| 1577 | struct drm_device *dev = filp->private_data; |
| 1578 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1579 | char buf[20]; |
| 1580 | int val = 1; |
| 1581 | |
| 1582 | if (cnt > 0) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1583 | if (cnt > sizeof(buf) - 1) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1584 | return -EINVAL; |
| 1585 | |
| 1586 | if (copy_from_user(buf, ubuf, cnt)) |
| 1587 | return -EFAULT; |
| 1588 | buf[cnt] = 0; |
| 1589 | |
| 1590 | val = simple_strtoul(buf, NULL, 0); |
| 1591 | } |
| 1592 | |
| 1593 | DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val); |
| 1594 | |
| 1595 | /* |
| 1596 | * Turbo will still be enabled, but won't go above the set value. |
| 1597 | */ |
| 1598 | dev_priv->max_delay = val / 50; |
| 1599 | |
| 1600 | gen6_set_rps(dev, val / 50); |
| 1601 | |
| 1602 | return cnt; |
| 1603 | } |
| 1604 | |
| 1605 | static const struct file_operations i915_max_freq_fops = { |
| 1606 | .owner = THIS_MODULE, |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1607 | .open = i915_debugfs_common_open, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1608 | .read = i915_max_freq_read, |
| 1609 | .write = i915_max_freq_write, |
| 1610 | .llseek = default_llseek, |
| 1611 | }; |
| 1612 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1613 | static ssize_t |
| 1614 | i915_cache_sharing_read(struct file *filp, |
| 1615 | char __user *ubuf, |
| 1616 | size_t max, |
| 1617 | loff_t *ppos) |
| 1618 | { |
| 1619 | struct drm_device *dev = filp->private_data; |
| 1620 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1621 | char buf[80]; |
| 1622 | u32 snpcr; |
| 1623 | int len; |
| 1624 | |
| 1625 | mutex_lock(&dev_priv->dev->struct_mutex); |
| 1626 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 1627 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 1628 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1629 | len = snprintf(buf, sizeof(buf), |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1630 | "%d\n", (snpcr & GEN6_MBC_SNPCR_MASK) >> |
| 1631 | GEN6_MBC_SNPCR_SHIFT); |
| 1632 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1633 | if (len > sizeof(buf)) |
| 1634 | len = sizeof(buf); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1635 | |
| 1636 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1637 | } |
| 1638 | |
| 1639 | static ssize_t |
| 1640 | i915_cache_sharing_write(struct file *filp, |
| 1641 | const char __user *ubuf, |
| 1642 | size_t cnt, |
| 1643 | loff_t *ppos) |
| 1644 | { |
| 1645 | struct drm_device *dev = filp->private_data; |
| 1646 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1647 | char buf[20]; |
| 1648 | u32 snpcr; |
| 1649 | int val = 1; |
| 1650 | |
| 1651 | if (cnt > 0) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1652 | if (cnt > sizeof(buf) - 1) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1653 | return -EINVAL; |
| 1654 | |
| 1655 | if (copy_from_user(buf, ubuf, cnt)) |
| 1656 | return -EFAULT; |
| 1657 | buf[cnt] = 0; |
| 1658 | |
| 1659 | val = simple_strtoul(buf, NULL, 0); |
| 1660 | } |
| 1661 | |
| 1662 | if (val < 0 || val > 3) |
| 1663 | return -EINVAL; |
| 1664 | |
| 1665 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val); |
| 1666 | |
| 1667 | /* Update the cache sharing policy here as well */ |
| 1668 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 1669 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 1670 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 1671 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 1672 | |
| 1673 | return cnt; |
| 1674 | } |
| 1675 | |
| 1676 | static const struct file_operations i915_cache_sharing_fops = { |
| 1677 | .owner = THIS_MODULE, |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1678 | .open = i915_debugfs_common_open, |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1679 | .read = i915_cache_sharing_read, |
| 1680 | .write = i915_cache_sharing_write, |
| 1681 | .llseek = default_llseek, |
| 1682 | }; |
| 1683 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1684 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 1685 | * allocated we need to hook into the minor for release. */ |
| 1686 | static int |
| 1687 | drm_add_fake_info_node(struct drm_minor *minor, |
| 1688 | struct dentry *ent, |
| 1689 | const void *key) |
| 1690 | { |
| 1691 | struct drm_info_node *node; |
| 1692 | |
| 1693 | node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); |
| 1694 | if (node == NULL) { |
| 1695 | debugfs_remove(ent); |
| 1696 | return -ENOMEM; |
| 1697 | } |
| 1698 | |
| 1699 | node->minor = minor; |
| 1700 | node->dent = ent; |
| 1701 | node->info_ent = (void *) key; |
Marcin Slusarz | b3e067c | 2011-11-09 22:20:35 +0100 | [diff] [blame] | 1702 | |
| 1703 | mutex_lock(&minor->debugfs_lock); |
| 1704 | list_add(&node->list, &minor->debugfs_list); |
| 1705 | mutex_unlock(&minor->debugfs_lock); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1706 | |
| 1707 | return 0; |
| 1708 | } |
| 1709 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1710 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 1711 | { |
| 1712 | struct drm_device *dev = inode->i_private; |
| 1713 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1714 | int ret; |
| 1715 | |
| 1716 | if (!IS_GEN6(dev)) |
| 1717 | return 0; |
| 1718 | |
| 1719 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1720 | if (ret) |
| 1721 | return ret; |
| 1722 | gen6_gt_force_wake_get(dev_priv); |
| 1723 | mutex_unlock(&dev->struct_mutex); |
| 1724 | |
| 1725 | return 0; |
| 1726 | } |
| 1727 | |
| 1728 | int i915_forcewake_release(struct inode *inode, struct file *file) |
| 1729 | { |
| 1730 | struct drm_device *dev = inode->i_private; |
| 1731 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1732 | |
| 1733 | if (!IS_GEN6(dev)) |
| 1734 | return 0; |
| 1735 | |
| 1736 | /* |
| 1737 | * It's bad that we can potentially hang userspace if struct_mutex gets |
| 1738 | * forever stuck. However, if we cannot acquire this lock it means that |
| 1739 | * almost certainly the driver has hung, is not unload-able. Therefore |
| 1740 | * hanging here is probably a minor inconvenience not to be seen my |
| 1741 | * almost every user. |
| 1742 | */ |
| 1743 | mutex_lock(&dev->struct_mutex); |
| 1744 | gen6_gt_force_wake_put(dev_priv); |
| 1745 | mutex_unlock(&dev->struct_mutex); |
| 1746 | |
| 1747 | return 0; |
| 1748 | } |
| 1749 | |
| 1750 | static const struct file_operations i915_forcewake_fops = { |
| 1751 | .owner = THIS_MODULE, |
| 1752 | .open = i915_forcewake_open, |
| 1753 | .release = i915_forcewake_release, |
| 1754 | }; |
| 1755 | |
| 1756 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 1757 | { |
| 1758 | struct drm_device *dev = minor->dev; |
| 1759 | struct dentry *ent; |
| 1760 | |
| 1761 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 1762 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1763 | root, dev, |
| 1764 | &i915_forcewake_fops); |
| 1765 | if (IS_ERR(ent)) |
| 1766 | return PTR_ERR(ent); |
| 1767 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 1768 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1769 | } |
| 1770 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1771 | static int i915_debugfs_create(struct dentry *root, |
| 1772 | struct drm_minor *minor, |
| 1773 | const char *name, |
| 1774 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1775 | { |
| 1776 | struct drm_device *dev = minor->dev; |
| 1777 | struct dentry *ent; |
| 1778 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1779 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1780 | S_IRUGO | S_IWUSR, |
| 1781 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1782 | fops); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1783 | if (IS_ERR(ent)) |
| 1784 | return PTR_ERR(ent); |
| 1785 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1786 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1787 | } |
| 1788 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1789 | static struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 1790 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 1791 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 1792 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 1793 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
| 1794 | {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST}, |
| 1795 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 1796 | {"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST}, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 1797 | {"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] | 1798 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1799 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 1800 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1801 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1802 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1803 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 1804 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 1805 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
| 1806 | {"i915_ringbuffer_data", i915_ringbuffer_data, 0, (void *)RCS}, |
| 1807 | {"i915_ringbuffer_info", i915_ringbuffer_info, 0, (void *)RCS}, |
| 1808 | {"i915_bsd_ringbuffer_data", i915_ringbuffer_data, 0, (void *)VCS}, |
| 1809 | {"i915_bsd_ringbuffer_info", i915_ringbuffer_info, 0, (void *)VCS}, |
| 1810 | {"i915_blt_ringbuffer_data", i915_ringbuffer_data, 0, (void *)BCS}, |
| 1811 | {"i915_blt_ringbuffer_info", i915_ringbuffer_info, 0, (void *)BCS}, |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 1812 | {"i915_error_state", i915_error_state, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1813 | {"i915_rstdby_delays", i915_rstdby_delays, 0}, |
| 1814 | {"i915_cur_delayinfo", i915_cur_delayinfo, 0}, |
| 1815 | {"i915_delayfreq_table", i915_delayfreq_table, 0}, |
| 1816 | {"i915_inttoext_table", i915_inttoext_table, 0}, |
| 1817 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1818 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1819 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1820 | {"i915_gfxec", i915_gfxec, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1821 | {"i915_fbc_status", i915_fbc_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1822 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1823 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1824 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1825 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1826 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1827 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame^] | 1828 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1829 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1830 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1831 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1832 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1833 | { |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1834 | int ret; |
| 1835 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1836 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 1837 | "i915_wedged", |
| 1838 | &i915_wedged_fops); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1839 | if (ret) |
| 1840 | return ret; |
| 1841 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1842 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 1843 | if (ret) |
| 1844 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1845 | |
| 1846 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 1847 | "i915_max_freq", |
| 1848 | &i915_max_freq_fops); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1849 | if (ret) |
| 1850 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 1851 | |
| 1852 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 1853 | "i915_cache_sharing", |
| 1854 | &i915_cache_sharing_fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1855 | if (ret) |
| 1856 | return ret; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1857 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1858 | return drm_debugfs_create_files(i915_debugfs_list, |
| 1859 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1860 | minor->debugfs_root, minor); |
| 1861 | } |
| 1862 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1863 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1864 | { |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1865 | drm_debugfs_remove_files(i915_debugfs_list, |
| 1866 | I915_DEBUGFS_ENTRIES, minor); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1867 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 1868 | 1, minor); |
Kristian Høgsberg | 33db679 | 2009-11-11 12:19:16 -0500 | [diff] [blame] | 1869 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, |
| 1870 | 1, minor); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1871 | drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops, |
| 1872 | 1, minor); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1873 | drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops, |
| 1874 | 1, minor); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1875 | } |
| 1876 | |
| 1877 | #endif /* CONFIG_DEBUG_FS */ |