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 | |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 567 | static void i915_dump_object(struct seq_file *m, |
| 568 | struct io_mapping *mapping, |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 569 | struct drm_i915_gem_object *obj) |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 570 | { |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 571 | int page, page_count, i; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 572 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 573 | page_count = obj->base.size / PAGE_SIZE; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 574 | for (page = 0; page < page_count; page++) { |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 575 | u32 *mem = io_mapping_map_wc(mapping, |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 576 | obj->gtt_offset + page * PAGE_SIZE); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 577 | for (i = 0; i < PAGE_SIZE; i += 4) |
| 578 | seq_printf(m, "%08x : %08x\n", i, mem[i / 4]); |
Chris Wilson | 5cdf588 | 2010-09-27 15:51:07 +0100 | [diff] [blame] | 579 | io_mapping_unmap(mem); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 580 | } |
| 581 | } |
| 582 | |
| 583 | static int i915_batchbuffer_info(struct seq_file *m, void *data) |
| 584 | { |
| 585 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 586 | struct drm_device *dev = node->minor->dev; |
| 587 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 588 | struct drm_i915_gem_object *obj; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 589 | int ret; |
| 590 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 591 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 592 | if (ret) |
| 593 | return ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 594 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 595 | list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) { |
| 596 | if (obj->base.read_domains & I915_GEM_DOMAIN_COMMAND) { |
| 597 | seq_printf(m, "--- gtt_offset = 0x%08x\n", obj->gtt_offset); |
| 598 | i915_dump_object(m, dev_priv->mm.gtt_mapping, obj); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 599 | } |
| 600 | } |
| 601 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 602 | mutex_unlock(&dev->struct_mutex); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | static int i915_ringbuffer_data(struct seq_file *m, void *data) |
| 607 | { |
| 608 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 609 | struct drm_device *dev = node->minor->dev; |
| 610 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 611 | struct intel_ring_buffer *ring; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 612 | int ret; |
| 613 | |
| 614 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 615 | if (ret) |
| 616 | return ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 617 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 618 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 619 | if (!ring->obj) { |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 620 | seq_printf(m, "No ringbuffer setup\n"); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 621 | } else { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 622 | const u8 __iomem *virt = ring->virtual_start; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 623 | uint32_t off; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 624 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 625 | for (off = 0; off < ring->size; off += 4) { |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 626 | uint32_t *ptr = (uint32_t *)(virt + off); |
| 627 | seq_printf(m, "%08x : %08x\n", off, *ptr); |
| 628 | } |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 629 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 630 | mutex_unlock(&dev->struct_mutex); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 631 | |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | static int i915_ringbuffer_info(struct seq_file *m, void *data) |
| 636 | { |
| 637 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 638 | struct drm_device *dev = node->minor->dev; |
| 639 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 640 | struct intel_ring_buffer *ring; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 641 | int ret; |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 642 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 643 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 644 | if (ring->size == 0) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 645 | return 0; |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 646 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 647 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 648 | if (ret) |
| 649 | return ret; |
| 650 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 651 | seq_printf(m, "Ring %s:\n", ring->name); |
| 652 | seq_printf(m, " Head : %08x\n", I915_READ_HEAD(ring) & HEAD_ADDR); |
| 653 | seq_printf(m, " Tail : %08x\n", I915_READ_TAIL(ring) & TAIL_ADDR); |
| 654 | seq_printf(m, " Size : %08x\n", ring->size); |
| 655 | seq_printf(m, " Active : %08x\n", intel_ring_get_active_head(ring)); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 656 | seq_printf(m, " NOPID : %08x\n", I915_READ_NOPID(ring)); |
| 657 | if (IS_GEN6(dev)) { |
| 658 | seq_printf(m, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring)); |
| 659 | seq_printf(m, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring)); |
| 660 | } |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 661 | seq_printf(m, " Control : %08x\n", I915_READ_CTL(ring)); |
| 662 | seq_printf(m, " Start : %08x\n", I915_READ_START(ring)); |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 663 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 664 | mutex_unlock(&dev->struct_mutex); |
| 665 | |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 666 | return 0; |
| 667 | } |
| 668 | |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 669 | static const char *ring_str(int ring) |
| 670 | { |
| 671 | switch (ring) { |
Daniel Vetter | 96154f2 | 2011-12-14 13:57:00 +0100 | [diff] [blame] | 672 | case RCS: return "render"; |
| 673 | case VCS: return "bsd"; |
| 674 | case BCS: return "blt"; |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 675 | default: return ""; |
| 676 | } |
| 677 | } |
| 678 | |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 679 | static const char *pin_flag(int pinned) |
| 680 | { |
| 681 | if (pinned > 0) |
| 682 | return " P"; |
| 683 | else if (pinned < 0) |
| 684 | return " p"; |
| 685 | else |
| 686 | return ""; |
| 687 | } |
| 688 | |
| 689 | static const char *tiling_flag(int tiling) |
| 690 | { |
| 691 | switch (tiling) { |
| 692 | default: |
| 693 | case I915_TILING_NONE: return ""; |
| 694 | case I915_TILING_X: return " X"; |
| 695 | case I915_TILING_Y: return " Y"; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | static const char *dirty_flag(int dirty) |
| 700 | { |
| 701 | return dirty ? " dirty" : ""; |
| 702 | } |
| 703 | |
| 704 | static const char *purgeable_flag(int purgeable) |
| 705 | { |
| 706 | return purgeable ? " purgeable" : ""; |
| 707 | } |
| 708 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 709 | static void print_error_buffers(struct seq_file *m, |
| 710 | const char *name, |
| 711 | struct drm_i915_error_buffer *err, |
| 712 | int count) |
| 713 | { |
| 714 | seq_printf(m, "%s [%d]:\n", name, count); |
| 715 | |
| 716 | while (count--) { |
Daniel Vetter | 96154f2 | 2011-12-14 13:57:00 +0100 | [diff] [blame] | 717 | 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] | 718 | err->gtt_offset, |
| 719 | err->size, |
| 720 | err->read_domains, |
| 721 | err->write_domain, |
| 722 | err->seqno, |
| 723 | pin_flag(err->pinned), |
| 724 | tiling_flag(err->tiling), |
| 725 | dirty_flag(err->dirty), |
| 726 | purgeable_flag(err->purgeable), |
Daniel Vetter | 96154f2 | 2011-12-14 13:57:00 +0100 | [diff] [blame] | 727 | err->ring != -1 ? " " : "", |
Chris Wilson | a779e5a | 2011-01-09 21:07:49 +0000 | [diff] [blame] | 728 | ring_str(err->ring), |
Chris Wilson | 93dfb40 | 2011-03-29 16:59:50 -0700 | [diff] [blame] | 729 | cache_level_str(err->cache_level)); |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 730 | |
| 731 | if (err->name) |
| 732 | seq_printf(m, " (name: %d)", err->name); |
| 733 | if (err->fence_reg != I915_FENCE_REG_NONE) |
| 734 | seq_printf(m, " (fence: %d)", err->fence_reg); |
| 735 | |
| 736 | seq_printf(m, "\n"); |
| 737 | err++; |
| 738 | } |
| 739 | } |
| 740 | |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 741 | static void i915_ring_error_state(struct seq_file *m, |
| 742 | struct drm_device *dev, |
| 743 | struct drm_i915_error_state *error, |
| 744 | unsigned ring) |
| 745 | { |
| 746 | seq_printf(m, "%s command stream:\n", ring_str(ring)); |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 747 | seq_printf(m, " HEAD: 0x%08x\n", error->head[ring]); |
| 748 | seq_printf(m, " TAIL: 0x%08x\n", error->tail[ring]); |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 749 | seq_printf(m, " ACTHD: 0x%08x\n", error->acthd[ring]); |
| 750 | seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir[ring]); |
| 751 | seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr[ring]); |
| 752 | seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone[ring]); |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 753 | if (ring == RCS && INTEL_INFO(dev)->gen >= 4) { |
| 754 | seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1); |
| 755 | seq_printf(m, " BBADDR: 0x%08llx\n", error->bbaddr); |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 756 | } |
Daniel Vetter | c1cd90e | 2011-12-14 13:57:02 +0100 | [diff] [blame] | 757 | if (INTEL_INFO(dev)->gen >= 4) |
| 758 | seq_printf(m, " INSTPS: 0x%08x\n", error->instps[ring]); |
| 759 | seq_printf(m, " INSTPM: 0x%08x\n", error->instpm[ring]); |
| 760 | if (INTEL_INFO(dev)->gen >= 6) |
| 761 | seq_printf(m, " FADDR: 0x%08x\n", error->faddr[ring]); |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 762 | seq_printf(m, " seqno: 0x%08x\n", error->seqno[ring]); |
| 763 | } |
| 764 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 765 | static int i915_error_state(struct seq_file *m, void *unused) |
| 766 | { |
| 767 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 768 | struct drm_device *dev = node->minor->dev; |
| 769 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 770 | struct drm_i915_error_state *error; |
| 771 | unsigned long flags; |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 772 | int i, page, offset, elt; |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 773 | |
| 774 | spin_lock_irqsave(&dev_priv->error_lock, flags); |
| 775 | if (!dev_priv->first_error) { |
| 776 | seq_printf(m, "no error state collected\n"); |
| 777 | goto out; |
| 778 | } |
| 779 | |
| 780 | error = dev_priv->first_error; |
| 781 | |
Jesse Barnes | 8a90523 | 2009-07-11 16:48:03 -0400 | [diff] [blame] | 782 | seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec, |
| 783 | error->time.tv_usec); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 784 | seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device); |
Chris Wilson | 1d8f38f | 2010-10-29 19:00:51 +0100 | [diff] [blame] | 785 | seq_printf(m, "EIR: 0x%08x\n", error->eir); |
| 786 | seq_printf(m, "PGTBL_ER: 0x%08x\n", error->pgtbl_er); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 787 | |
Daniel Vetter | bf3301a | 2011-05-12 22:17:12 +0100 | [diff] [blame] | 788 | for (i = 0; i < dev_priv->num_fence_regs; i++) |
Chris Wilson | 748ebc6 | 2010-10-24 10:28:47 +0100 | [diff] [blame] | 789 | seq_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]); |
| 790 | |
Daniel Vetter | d27b1e0 | 2011-12-14 13:57:01 +0100 | [diff] [blame] | 791 | if (INTEL_INFO(dev)->gen >= 6) |
| 792 | seq_printf(m, "ERROR: 0x%08x\n", error->error); |
| 793 | |
| 794 | i915_ring_error_state(m, dev, error, RCS); |
| 795 | if (HAS_BLT(dev)) |
| 796 | i915_ring_error_state(m, dev, error, BCS); |
| 797 | if (HAS_BSD(dev)) |
| 798 | i915_ring_error_state(m, dev, error, VCS); |
| 799 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 800 | if (error->active_bo) |
| 801 | print_error_buffers(m, "Active", |
| 802 | error->active_bo, |
| 803 | error->active_bo_count); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 804 | |
Chris Wilson | c724e8a | 2010-11-22 08:07:02 +0000 | [diff] [blame] | 805 | if (error->pinned_bo) |
| 806 | print_error_buffers(m, "Pinned", |
| 807 | error->pinned_bo, |
| 808 | error->pinned_bo_count); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 809 | |
| 810 | for (i = 0; i < ARRAY_SIZE(error->batchbuffer); i++) { |
| 811 | if (error->batchbuffer[i]) { |
| 812 | struct drm_i915_error_object *obj = error->batchbuffer[i]; |
| 813 | |
Chris Wilson | bcfb2e2 | 2011-01-07 21:06:07 +0000 | [diff] [blame] | 814 | seq_printf(m, "%s --- gtt_offset = 0x%08x\n", |
| 815 | dev_priv->ring[i].name, |
| 816 | obj->gtt_offset); |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 817 | offset = 0; |
| 818 | for (page = 0; page < obj->page_count; page++) { |
| 819 | for (elt = 0; elt < PAGE_SIZE/4; elt++) { |
| 820 | seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]); |
| 821 | offset += 4; |
| 822 | } |
| 823 | } |
| 824 | } |
| 825 | } |
| 826 | |
Chris Wilson | e2f973d | 2011-01-27 19:15:11 +0000 | [diff] [blame] | 827 | for (i = 0; i < ARRAY_SIZE(error->ringbuffer); i++) { |
| 828 | if (error->ringbuffer[i]) { |
| 829 | struct drm_i915_error_object *obj = error->ringbuffer[i]; |
| 830 | seq_printf(m, "%s --- ringbuffer = 0x%08x\n", |
| 831 | dev_priv->ring[i].name, |
| 832 | obj->gtt_offset); |
| 833 | offset = 0; |
| 834 | for (page = 0; page < obj->page_count; page++) { |
| 835 | for (elt = 0; elt < PAGE_SIZE/4; elt++) { |
| 836 | seq_printf(m, "%08x : %08x\n", |
| 837 | offset, |
| 838 | obj->pages[page][elt]); |
| 839 | offset += 4; |
| 840 | } |
Chris Wilson | 9df3079 | 2010-02-18 10:24:56 +0000 | [diff] [blame] | 841 | } |
| 842 | } |
| 843 | } |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 844 | |
Chris Wilson | 6ef3d42 | 2010-08-04 20:26:07 +0100 | [diff] [blame] | 845 | if (error->overlay) |
| 846 | intel_overlay_print_error_state(m, error->overlay); |
| 847 | |
Chris Wilson | c4a1d9e | 2010-11-21 13:12:35 +0000 | [diff] [blame] | 848 | if (error->display) |
| 849 | intel_display_print_error_state(m, dev, error->display); |
| 850 | |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 851 | out: |
| 852 | spin_unlock_irqrestore(&dev_priv->error_lock, flags); |
| 853 | |
| 854 | return 0; |
| 855 | } |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 856 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 857 | static int i915_rstdby_delays(struct seq_file *m, void *unused) |
| 858 | { |
| 859 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 860 | struct drm_device *dev = node->minor->dev; |
| 861 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 862 | u16 crstanddelay; |
| 863 | int ret; |
| 864 | |
| 865 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 866 | if (ret) |
| 867 | return ret; |
| 868 | |
| 869 | crstanddelay = I915_READ16(CRSTANDVID); |
| 870 | |
| 871 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 872 | |
| 873 | seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f)); |
| 874 | |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | static int i915_cur_delayinfo(struct seq_file *m, void *unused) |
| 879 | { |
| 880 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 881 | struct drm_device *dev = node->minor->dev; |
| 882 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 883 | int ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 884 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 885 | if (IS_GEN5(dev)) { |
| 886 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 887 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 888 | |
| 889 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 890 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 891 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 892 | MEMSTAT_VID_SHIFT); |
| 893 | seq_printf(m, "Current P-state: %d\n", |
| 894 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 895 | } else if (IS_GEN6(dev) || IS_GEN7(dev)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 896 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 897 | u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 898 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 899 | u32 rpstat; |
| 900 | u32 rpupei, rpcurup, rpprevup; |
| 901 | u32 rpdownei, rpcurdown, rpprevdown; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 902 | int max_freq; |
| 903 | |
| 904 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 905 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 906 | if (ret) |
| 907 | return ret; |
| 908 | |
Ben Widawsky | fcca792 | 2011-04-25 11:23:07 -0700 | [diff] [blame] | 909 | gen6_gt_force_wake_get(dev_priv); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 910 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 911 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 912 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 913 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 914 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 915 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 916 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 917 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
| 918 | |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 919 | gen6_gt_force_wake_put(dev_priv); |
| 920 | mutex_unlock(&dev->struct_mutex); |
| 921 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 922 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 923 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 924 | seq_printf(m, "Render p-state ratio: %d\n", |
| 925 | (gt_perf_status & 0xff00) >> 8); |
| 926 | seq_printf(m, "Render p-state VID: %d\n", |
| 927 | gt_perf_status & 0xff); |
| 928 | seq_printf(m, "Render p-state limit: %d\n", |
| 929 | rp_state_limits & 0xff); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 930 | seq_printf(m, "CAGF: %dMHz\n", ((rpstat & GEN6_CAGF_MASK) >> |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 931 | GEN6_CAGF_SHIFT) * 50); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 932 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 933 | GEN6_CURICONT_MASK); |
| 934 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 935 | GEN6_CURBSYTAVG_MASK); |
| 936 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 937 | GEN6_CURBSYTAVG_MASK); |
| 938 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 939 | GEN6_CURIAVG_MASK); |
| 940 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 941 | GEN6_CURBSYTAVG_MASK); |
| 942 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 943 | GEN6_CURBSYTAVG_MASK); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 944 | |
| 945 | max_freq = (rp_state_cap & 0xff0000) >> 16; |
| 946 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 947 | max_freq * 50); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 948 | |
| 949 | max_freq = (rp_state_cap & 0xff00) >> 8; |
| 950 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 951 | max_freq * 50); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 952 | |
| 953 | max_freq = rp_state_cap & 0xff; |
| 954 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Jesse Barnes | e281fca | 2011-03-18 10:32:07 -0700 | [diff] [blame] | 955 | max_freq * 50); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 956 | } else { |
| 957 | seq_printf(m, "no P-state info available\n"); |
| 958 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 959 | |
| 960 | return 0; |
| 961 | } |
| 962 | |
| 963 | static int i915_delayfreq_table(struct seq_file *m, void *unused) |
| 964 | { |
| 965 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 966 | struct drm_device *dev = node->minor->dev; |
| 967 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 968 | u32 delayfreq; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 969 | int ret, i; |
| 970 | |
| 971 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 972 | if (ret) |
| 973 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 974 | |
| 975 | for (i = 0; i < 16; i++) { |
| 976 | delayfreq = I915_READ(PXVFREQ_BASE + i * 4); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 977 | seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq, |
| 978 | (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 979 | } |
| 980 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 981 | mutex_unlock(&dev->struct_mutex); |
| 982 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 983 | return 0; |
| 984 | } |
| 985 | |
| 986 | static inline int MAP_TO_MV(int map) |
| 987 | { |
| 988 | return 1250 - (map * 25); |
| 989 | } |
| 990 | |
| 991 | static int i915_inttoext_table(struct seq_file *m, void *unused) |
| 992 | { |
| 993 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 994 | struct drm_device *dev = node->minor->dev; |
| 995 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 996 | u32 inttoext; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 997 | int ret, i; |
| 998 | |
| 999 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1000 | if (ret) |
| 1001 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1002 | |
| 1003 | for (i = 1; i <= 32; i++) { |
| 1004 | inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4); |
| 1005 | seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext); |
| 1006 | } |
| 1007 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1008 | mutex_unlock(&dev->struct_mutex); |
| 1009 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1010 | return 0; |
| 1011 | } |
| 1012 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1013 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1014 | { |
| 1015 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1016 | struct drm_device *dev = node->minor->dev; |
| 1017 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1018 | u32 rgvmodectl, rstdbyctl; |
| 1019 | u16 crstandvid; |
| 1020 | int ret; |
| 1021 | |
| 1022 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1023 | if (ret) |
| 1024 | return ret; |
| 1025 | |
| 1026 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1027 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1028 | crstandvid = I915_READ16(CRSTANDVID); |
| 1029 | |
| 1030 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1031 | |
| 1032 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1033 | "yes" : "no"); |
| 1034 | seq_printf(m, "Boost freq: %d\n", |
| 1035 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1036 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1037 | seq_printf(m, "HW control enabled: %s\n", |
| 1038 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1039 | seq_printf(m, "SW control enabled: %s\n", |
| 1040 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1041 | seq_printf(m, "Gated voltage change: %s\n", |
| 1042 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1043 | seq_printf(m, "Starting frequency: P%d\n", |
| 1044 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1045 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1046 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1047 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1048 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1049 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1050 | seq_printf(m, "Render standby enabled: %s\n", |
| 1051 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1052 | seq_printf(m, "Current RS state: "); |
| 1053 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1054 | case RSX_STATUS_ON: |
| 1055 | seq_printf(m, "on\n"); |
| 1056 | break; |
| 1057 | case RSX_STATUS_RC1: |
| 1058 | seq_printf(m, "RC1\n"); |
| 1059 | break; |
| 1060 | case RSX_STATUS_RC1E: |
| 1061 | seq_printf(m, "RC1E\n"); |
| 1062 | break; |
| 1063 | case RSX_STATUS_RS1: |
| 1064 | seq_printf(m, "RS1\n"); |
| 1065 | break; |
| 1066 | case RSX_STATUS_RS2: |
| 1067 | seq_printf(m, "RS2 (RC6)\n"); |
| 1068 | break; |
| 1069 | case RSX_STATUS_RS3: |
| 1070 | seq_printf(m, "RC3 (RC6+)\n"); |
| 1071 | break; |
| 1072 | default: |
| 1073 | seq_printf(m, "unknown\n"); |
| 1074 | break; |
| 1075 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1076 | |
| 1077 | return 0; |
| 1078 | } |
| 1079 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1080 | static int gen6_drpc_info(struct seq_file *m) |
| 1081 | { |
| 1082 | |
| 1083 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1084 | struct drm_device *dev = node->minor->dev; |
| 1085 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1086 | u32 rpmodectl1, gt_core_status, rcctl1; |
| 1087 | int count=0, ret; |
| 1088 | |
| 1089 | |
| 1090 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1091 | if (ret) |
| 1092 | return ret; |
| 1093 | |
| 1094 | if (atomic_read(&dev_priv->forcewake_count)) { |
| 1095 | seq_printf(m, "RC information inaccurate because userspace " |
| 1096 | "holds a reference \n"); |
| 1097 | } else { |
| 1098 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1099 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1100 | udelay(10); |
| 1101 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1102 | } |
| 1103 | |
| 1104 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
| 1105 | trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4); |
| 1106 | |
| 1107 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1108 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1109 | mutex_unlock(&dev->struct_mutex); |
| 1110 | |
| 1111 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1112 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1113 | seq_printf(m, "HW control enabled: %s\n", |
| 1114 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1115 | seq_printf(m, "SW control enabled: %s\n", |
| 1116 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1117 | GEN6_RP_MEDIA_SW_MODE)); |
| 1118 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1119 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1120 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1121 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1122 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1123 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1124 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1125 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
| 1126 | seq_printf(m, "Current RC state: "); |
| 1127 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1128 | case GEN6_RC0: |
| 1129 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
| 1130 | seq_printf(m, "Core Power Down\n"); |
| 1131 | else |
| 1132 | seq_printf(m, "on\n"); |
| 1133 | break; |
| 1134 | case GEN6_RC3: |
| 1135 | seq_printf(m, "RC3\n"); |
| 1136 | break; |
| 1137 | case GEN6_RC6: |
| 1138 | seq_printf(m, "RC6\n"); |
| 1139 | break; |
| 1140 | case GEN6_RC7: |
| 1141 | seq_printf(m, "RC7\n"); |
| 1142 | break; |
| 1143 | default: |
| 1144 | seq_printf(m, "Unknown\n"); |
| 1145 | break; |
| 1146 | } |
| 1147 | |
| 1148 | seq_printf(m, "Core Power Down: %s\n", |
| 1149 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
| 1150 | return 0; |
| 1151 | } |
| 1152 | |
| 1153 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1154 | { |
| 1155 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1156 | struct drm_device *dev = node->minor->dev; |
| 1157 | |
| 1158 | if (IS_GEN6(dev) || IS_GEN7(dev)) |
| 1159 | return gen6_drpc_info(m); |
| 1160 | else |
| 1161 | return ironlake_drpc_info(m); |
| 1162 | } |
| 1163 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1164 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1165 | { |
| 1166 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1167 | struct drm_device *dev = node->minor->dev; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1168 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1169 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1170 | if (!I915_HAS_FBC(dev)) { |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1171 | seq_printf(m, "FBC unsupported on this chipset\n"); |
| 1172 | return 0; |
| 1173 | } |
| 1174 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1175 | if (intel_fbc_enabled(dev)) { |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1176 | seq_printf(m, "FBC enabled\n"); |
| 1177 | } else { |
| 1178 | seq_printf(m, "FBC disabled: "); |
| 1179 | switch (dev_priv->no_fbc_reason) { |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1180 | case FBC_NO_OUTPUT: |
| 1181 | seq_printf(m, "no outputs"); |
| 1182 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1183 | case FBC_STOLEN_TOO_SMALL: |
| 1184 | seq_printf(m, "not enough stolen memory"); |
| 1185 | break; |
| 1186 | case FBC_UNSUPPORTED_MODE: |
| 1187 | seq_printf(m, "mode not supported"); |
| 1188 | break; |
| 1189 | case FBC_MODE_TOO_LARGE: |
| 1190 | seq_printf(m, "mode too large"); |
| 1191 | break; |
| 1192 | case FBC_BAD_PLANE: |
| 1193 | seq_printf(m, "FBC unsupported on plane"); |
| 1194 | break; |
| 1195 | case FBC_NOT_TILED: |
| 1196 | seq_printf(m, "scanout buffer not tiled"); |
| 1197 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1198 | case FBC_MULTIPLE_PIPES: |
| 1199 | seq_printf(m, "multiple pipes are enabled"); |
| 1200 | break; |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1201 | case FBC_MODULE_PARAM: |
| 1202 | seq_printf(m, "disabled per module param (default off)"); |
| 1203 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1204 | default: |
| 1205 | seq_printf(m, "unknown reason"); |
| 1206 | } |
| 1207 | seq_printf(m, "\n"); |
| 1208 | } |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1212 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1213 | { |
| 1214 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1215 | struct drm_device *dev = node->minor->dev; |
| 1216 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1217 | bool sr_enabled = false; |
| 1218 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1219 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1220 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1221 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1222 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1223 | else if (IS_I915GM(dev)) |
| 1224 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1225 | else if (IS_PINEVIEW(dev)) |
| 1226 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1227 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1228 | seq_printf(m, "self-refresh: %s\n", |
| 1229 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1230 | |
| 1231 | return 0; |
| 1232 | } |
| 1233 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1234 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1235 | { |
| 1236 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1237 | struct drm_device *dev = node->minor->dev; |
| 1238 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1239 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1240 | int ret; |
| 1241 | |
| 1242 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1243 | if (ret) |
| 1244 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1245 | |
| 1246 | temp = i915_mch_val(dev_priv); |
| 1247 | chipset = i915_chipset_val(dev_priv); |
| 1248 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1249 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1250 | |
| 1251 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1252 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1253 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1254 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1255 | |
| 1256 | return 0; |
| 1257 | } |
| 1258 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1259 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1260 | { |
| 1261 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1262 | struct drm_device *dev = node->minor->dev; |
| 1263 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1264 | int ret; |
| 1265 | int gpu_freq, ia_freq; |
| 1266 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1267 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1268 | seq_printf(m, "unsupported on this chipset\n"); |
| 1269 | return 0; |
| 1270 | } |
| 1271 | |
| 1272 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1273 | if (ret) |
| 1274 | return ret; |
| 1275 | |
| 1276 | seq_printf(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\n"); |
| 1277 | |
| 1278 | for (gpu_freq = dev_priv->min_delay; gpu_freq <= dev_priv->max_delay; |
| 1279 | gpu_freq++) { |
| 1280 | I915_WRITE(GEN6_PCODE_DATA, gpu_freq); |
| 1281 | I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | |
| 1282 | GEN6_PCODE_READ_MIN_FREQ_TABLE); |
| 1283 | if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & |
| 1284 | GEN6_PCODE_READY) == 0, 10)) { |
| 1285 | DRM_ERROR("pcode read of freq table timed out\n"); |
| 1286 | continue; |
| 1287 | } |
| 1288 | ia_freq = I915_READ(GEN6_PCODE_DATA); |
| 1289 | seq_printf(m, "%d\t\t%d\n", gpu_freq * 50, ia_freq * 100); |
| 1290 | } |
| 1291 | |
| 1292 | mutex_unlock(&dev->struct_mutex); |
| 1293 | |
| 1294 | return 0; |
| 1295 | } |
| 1296 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1297 | static int i915_gfxec(struct seq_file *m, void *unused) |
| 1298 | { |
| 1299 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1300 | struct drm_device *dev = node->minor->dev; |
| 1301 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1302 | int ret; |
| 1303 | |
| 1304 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1305 | if (ret) |
| 1306 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1307 | |
| 1308 | seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4)); |
| 1309 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1310 | mutex_unlock(&dev->struct_mutex); |
| 1311 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1312 | return 0; |
| 1313 | } |
| 1314 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1315 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1316 | { |
| 1317 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1318 | struct drm_device *dev = node->minor->dev; |
| 1319 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1320 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1321 | int ret; |
| 1322 | |
| 1323 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1324 | if (ret) |
| 1325 | return ret; |
| 1326 | |
| 1327 | if (opregion->header) |
| 1328 | seq_write(m, opregion->header, OPREGION_SIZE); |
| 1329 | |
| 1330 | mutex_unlock(&dev->struct_mutex); |
| 1331 | |
| 1332 | return 0; |
| 1333 | } |
| 1334 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1335 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1336 | { |
| 1337 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1338 | struct drm_device *dev = node->minor->dev; |
| 1339 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1340 | struct intel_fbdev *ifbdev; |
| 1341 | struct intel_framebuffer *fb; |
| 1342 | int ret; |
| 1343 | |
| 1344 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
| 1345 | if (ret) |
| 1346 | return ret; |
| 1347 | |
| 1348 | ifbdev = dev_priv->fbdev; |
| 1349 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1350 | |
| 1351 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ", |
| 1352 | fb->base.width, |
| 1353 | fb->base.height, |
| 1354 | fb->base.depth, |
| 1355 | fb->base.bits_per_pixel); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1356 | describe_obj(m, fb->obj); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1357 | seq_printf(m, "\n"); |
| 1358 | |
| 1359 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
| 1360 | if (&fb->base == ifbdev->helper.fb) |
| 1361 | continue; |
| 1362 | |
| 1363 | seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ", |
| 1364 | fb->base.width, |
| 1365 | fb->base.height, |
| 1366 | fb->base.depth, |
| 1367 | fb->base.bits_per_pixel); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1368 | describe_obj(m, fb->obj); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1369 | seq_printf(m, "\n"); |
| 1370 | } |
| 1371 | |
| 1372 | mutex_unlock(&dev->mode_config.mutex); |
| 1373 | |
| 1374 | return 0; |
| 1375 | } |
| 1376 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1377 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1378 | { |
| 1379 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1380 | struct drm_device *dev = node->minor->dev; |
| 1381 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1382 | int ret; |
| 1383 | |
| 1384 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
| 1385 | if (ret) |
| 1386 | return ret; |
| 1387 | |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1388 | if (dev_priv->pwrctx) { |
| 1389 | seq_printf(m, "power context "); |
| 1390 | describe_obj(m, dev_priv->pwrctx); |
| 1391 | seq_printf(m, "\n"); |
| 1392 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1393 | |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1394 | if (dev_priv->renderctx) { |
| 1395 | seq_printf(m, "render context "); |
| 1396 | describe_obj(m, dev_priv->renderctx); |
| 1397 | seq_printf(m, "\n"); |
| 1398 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1399 | |
| 1400 | mutex_unlock(&dev->mode_config.mutex); |
| 1401 | |
| 1402 | return 0; |
| 1403 | } |
| 1404 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1405 | static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data) |
| 1406 | { |
| 1407 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1408 | struct drm_device *dev = node->minor->dev; |
| 1409 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1410 | |
| 1411 | seq_printf(m, "forcewake count = %d\n", |
| 1412 | atomic_read(&dev_priv->forcewake_count)); |
| 1413 | |
| 1414 | return 0; |
| 1415 | } |
| 1416 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1417 | static int |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1418 | i915_debugfs_common_open(struct inode *inode, |
| 1419 | struct file *filp) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1420 | { |
| 1421 | filp->private_data = inode->i_private; |
| 1422 | return 0; |
| 1423 | } |
| 1424 | |
| 1425 | static ssize_t |
| 1426 | i915_wedged_read(struct file *filp, |
| 1427 | char __user *ubuf, |
| 1428 | size_t max, |
| 1429 | loff_t *ppos) |
| 1430 | { |
| 1431 | struct drm_device *dev = filp->private_data; |
| 1432 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1433 | char buf[80]; |
| 1434 | int len; |
| 1435 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1436 | len = snprintf(buf, sizeof(buf), |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1437 | "wedged : %d\n", |
| 1438 | atomic_read(&dev_priv->mm.wedged)); |
| 1439 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1440 | if (len > sizeof(buf)) |
| 1441 | len = sizeof(buf); |
Dan Carpenter | f4433a8 | 2010-09-08 21:44:47 +0200 | [diff] [blame] | 1442 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1443 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1444 | } |
| 1445 | |
| 1446 | static ssize_t |
| 1447 | i915_wedged_write(struct file *filp, |
| 1448 | const char __user *ubuf, |
| 1449 | size_t cnt, |
| 1450 | loff_t *ppos) |
| 1451 | { |
| 1452 | struct drm_device *dev = filp->private_data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1453 | char buf[20]; |
| 1454 | int val = 1; |
| 1455 | |
| 1456 | if (cnt > 0) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1457 | if (cnt > sizeof(buf) - 1) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1458 | return -EINVAL; |
| 1459 | |
| 1460 | if (copy_from_user(buf, ubuf, cnt)) |
| 1461 | return -EFAULT; |
| 1462 | buf[cnt] = 0; |
| 1463 | |
| 1464 | val = simple_strtoul(buf, NULL, 0); |
| 1465 | } |
| 1466 | |
| 1467 | DRM_INFO("Manually setting wedged to %d\n", val); |
Chris Wilson | 527f9e9 | 2010-11-11 01:16:58 +0000 | [diff] [blame] | 1468 | i915_handle_error(dev, val); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1469 | |
| 1470 | return cnt; |
| 1471 | } |
| 1472 | |
| 1473 | static const struct file_operations i915_wedged_fops = { |
| 1474 | .owner = THIS_MODULE, |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1475 | .open = i915_debugfs_common_open, |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1476 | .read = i915_wedged_read, |
| 1477 | .write = i915_wedged_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1478 | .llseek = default_llseek, |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1479 | }; |
| 1480 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1481 | static ssize_t |
| 1482 | i915_max_freq_read(struct file *filp, |
| 1483 | char __user *ubuf, |
| 1484 | size_t max, |
| 1485 | loff_t *ppos) |
| 1486 | { |
| 1487 | struct drm_device *dev = filp->private_data; |
| 1488 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1489 | char buf[80]; |
| 1490 | int len; |
| 1491 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1492 | len = snprintf(buf, sizeof(buf), |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1493 | "max freq: %d\n", dev_priv->max_delay * 50); |
| 1494 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1495 | if (len > sizeof(buf)) |
| 1496 | len = sizeof(buf); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1497 | |
| 1498 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1499 | } |
| 1500 | |
| 1501 | static ssize_t |
| 1502 | i915_max_freq_write(struct file *filp, |
| 1503 | const char __user *ubuf, |
| 1504 | size_t cnt, |
| 1505 | loff_t *ppos) |
| 1506 | { |
| 1507 | struct drm_device *dev = filp->private_data; |
| 1508 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1509 | char buf[20]; |
| 1510 | int val = 1; |
| 1511 | |
| 1512 | if (cnt > 0) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1513 | if (cnt > sizeof(buf) - 1) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1514 | return -EINVAL; |
| 1515 | |
| 1516 | if (copy_from_user(buf, ubuf, cnt)) |
| 1517 | return -EFAULT; |
| 1518 | buf[cnt] = 0; |
| 1519 | |
| 1520 | val = simple_strtoul(buf, NULL, 0); |
| 1521 | } |
| 1522 | |
| 1523 | DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val); |
| 1524 | |
| 1525 | /* |
| 1526 | * Turbo will still be enabled, but won't go above the set value. |
| 1527 | */ |
| 1528 | dev_priv->max_delay = val / 50; |
| 1529 | |
| 1530 | gen6_set_rps(dev, val / 50); |
| 1531 | |
| 1532 | return cnt; |
| 1533 | } |
| 1534 | |
| 1535 | static const struct file_operations i915_max_freq_fops = { |
| 1536 | .owner = THIS_MODULE, |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1537 | .open = i915_debugfs_common_open, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1538 | .read = i915_max_freq_read, |
| 1539 | .write = i915_max_freq_write, |
| 1540 | .llseek = default_llseek, |
| 1541 | }; |
| 1542 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1543 | static ssize_t |
| 1544 | i915_cache_sharing_read(struct file *filp, |
| 1545 | char __user *ubuf, |
| 1546 | size_t max, |
| 1547 | loff_t *ppos) |
| 1548 | { |
| 1549 | struct drm_device *dev = filp->private_data; |
| 1550 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1551 | char buf[80]; |
| 1552 | u32 snpcr; |
| 1553 | int len; |
| 1554 | |
| 1555 | mutex_lock(&dev_priv->dev->struct_mutex); |
| 1556 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 1557 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 1558 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1559 | len = snprintf(buf, sizeof(buf), |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1560 | "%d\n", (snpcr & GEN6_MBC_SNPCR_MASK) >> |
| 1561 | GEN6_MBC_SNPCR_SHIFT); |
| 1562 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1563 | if (len > sizeof(buf)) |
| 1564 | len = sizeof(buf); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1565 | |
| 1566 | return simple_read_from_buffer(ubuf, max, ppos, buf, len); |
| 1567 | } |
| 1568 | |
| 1569 | static ssize_t |
| 1570 | i915_cache_sharing_write(struct file *filp, |
| 1571 | const char __user *ubuf, |
| 1572 | size_t cnt, |
| 1573 | loff_t *ppos) |
| 1574 | { |
| 1575 | struct drm_device *dev = filp->private_data; |
| 1576 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1577 | char buf[20]; |
| 1578 | u32 snpcr; |
| 1579 | int val = 1; |
| 1580 | |
| 1581 | if (cnt > 0) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1582 | if (cnt > sizeof(buf) - 1) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1583 | return -EINVAL; |
| 1584 | |
| 1585 | if (copy_from_user(buf, ubuf, cnt)) |
| 1586 | return -EFAULT; |
| 1587 | buf[cnt] = 0; |
| 1588 | |
| 1589 | val = simple_strtoul(buf, NULL, 0); |
| 1590 | } |
| 1591 | |
| 1592 | if (val < 0 || val > 3) |
| 1593 | return -EINVAL; |
| 1594 | |
| 1595 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val); |
| 1596 | |
| 1597 | /* Update the cache sharing policy here as well */ |
| 1598 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 1599 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 1600 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 1601 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 1602 | |
| 1603 | return cnt; |
| 1604 | } |
| 1605 | |
| 1606 | static const struct file_operations i915_cache_sharing_fops = { |
| 1607 | .owner = THIS_MODULE, |
Daniel Vetter | 08e14e8 | 2011-12-14 13:57:10 +0100 | [diff] [blame] | 1608 | .open = i915_debugfs_common_open, |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1609 | .read = i915_cache_sharing_read, |
| 1610 | .write = i915_cache_sharing_write, |
| 1611 | .llseek = default_llseek, |
| 1612 | }; |
| 1613 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1614 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 1615 | * allocated we need to hook into the minor for release. */ |
| 1616 | static int |
| 1617 | drm_add_fake_info_node(struct drm_minor *minor, |
| 1618 | struct dentry *ent, |
| 1619 | const void *key) |
| 1620 | { |
| 1621 | struct drm_info_node *node; |
| 1622 | |
| 1623 | node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); |
| 1624 | if (node == NULL) { |
| 1625 | debugfs_remove(ent); |
| 1626 | return -ENOMEM; |
| 1627 | } |
| 1628 | |
| 1629 | node->minor = minor; |
| 1630 | node->dent = ent; |
| 1631 | node->info_ent = (void *) key; |
Marcin Slusarz | b3e067c | 2011-11-09 22:20:35 +0100 | [diff] [blame] | 1632 | |
| 1633 | mutex_lock(&minor->debugfs_lock); |
| 1634 | list_add(&node->list, &minor->debugfs_list); |
| 1635 | mutex_unlock(&minor->debugfs_lock); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1636 | |
| 1637 | return 0; |
| 1638 | } |
| 1639 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1640 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 1641 | { |
| 1642 | struct drm_device *dev = inode->i_private; |
| 1643 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1644 | int ret; |
| 1645 | |
| 1646 | if (!IS_GEN6(dev)) |
| 1647 | return 0; |
| 1648 | |
| 1649 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1650 | if (ret) |
| 1651 | return ret; |
| 1652 | gen6_gt_force_wake_get(dev_priv); |
| 1653 | mutex_unlock(&dev->struct_mutex); |
| 1654 | |
| 1655 | return 0; |
| 1656 | } |
| 1657 | |
| 1658 | int i915_forcewake_release(struct inode *inode, struct file *file) |
| 1659 | { |
| 1660 | struct drm_device *dev = inode->i_private; |
| 1661 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1662 | |
| 1663 | if (!IS_GEN6(dev)) |
| 1664 | return 0; |
| 1665 | |
| 1666 | /* |
| 1667 | * It's bad that we can potentially hang userspace if struct_mutex gets |
| 1668 | * forever stuck. However, if we cannot acquire this lock it means that |
| 1669 | * almost certainly the driver has hung, is not unload-able. Therefore |
| 1670 | * hanging here is probably a minor inconvenience not to be seen my |
| 1671 | * almost every user. |
| 1672 | */ |
| 1673 | mutex_lock(&dev->struct_mutex); |
| 1674 | gen6_gt_force_wake_put(dev_priv); |
| 1675 | mutex_unlock(&dev->struct_mutex); |
| 1676 | |
| 1677 | return 0; |
| 1678 | } |
| 1679 | |
| 1680 | static const struct file_operations i915_forcewake_fops = { |
| 1681 | .owner = THIS_MODULE, |
| 1682 | .open = i915_forcewake_open, |
| 1683 | .release = i915_forcewake_release, |
| 1684 | }; |
| 1685 | |
| 1686 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 1687 | { |
| 1688 | struct drm_device *dev = minor->dev; |
| 1689 | struct dentry *ent; |
| 1690 | |
| 1691 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 1692 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1693 | root, dev, |
| 1694 | &i915_forcewake_fops); |
| 1695 | if (IS_ERR(ent)) |
| 1696 | return PTR_ERR(ent); |
| 1697 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 1698 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1699 | } |
| 1700 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1701 | static int i915_debugfs_create(struct dentry *root, |
| 1702 | struct drm_minor *minor, |
| 1703 | const char *name, |
| 1704 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1705 | { |
| 1706 | struct drm_device *dev = minor->dev; |
| 1707 | struct dentry *ent; |
| 1708 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1709 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1710 | S_IRUGO | S_IWUSR, |
| 1711 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1712 | fops); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1713 | if (IS_ERR(ent)) |
| 1714 | return PTR_ERR(ent); |
| 1715 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1716 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1717 | } |
| 1718 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1719 | static struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 1720 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 1721 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 1722 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 1723 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
| 1724 | {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST}, |
| 1725 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 1726 | {"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST}, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 1727 | {"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] | 1728 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1729 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 1730 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1731 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1732 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1733 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 1734 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 1735 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
| 1736 | {"i915_ringbuffer_data", i915_ringbuffer_data, 0, (void *)RCS}, |
| 1737 | {"i915_ringbuffer_info", i915_ringbuffer_info, 0, (void *)RCS}, |
| 1738 | {"i915_bsd_ringbuffer_data", i915_ringbuffer_data, 0, (void *)VCS}, |
| 1739 | {"i915_bsd_ringbuffer_info", i915_ringbuffer_info, 0, (void *)VCS}, |
| 1740 | {"i915_blt_ringbuffer_data", i915_ringbuffer_data, 0, (void *)BCS}, |
| 1741 | {"i915_blt_ringbuffer_info", i915_ringbuffer_info, 0, (void *)BCS}, |
Ben Gamari | 6911a9b | 2009-04-02 11:24:54 -0700 | [diff] [blame] | 1742 | {"i915_batchbuffers", i915_batchbuffer_info, 0}, |
Jesse Barnes | 63eeaf3 | 2009-06-18 16:56:52 -0700 | [diff] [blame] | 1743 | {"i915_error_state", i915_error_state, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1744 | {"i915_rstdby_delays", i915_rstdby_delays, 0}, |
| 1745 | {"i915_cur_delayinfo", i915_cur_delayinfo, 0}, |
| 1746 | {"i915_delayfreq_table", i915_delayfreq_table, 0}, |
| 1747 | {"i915_inttoext_table", i915_inttoext_table, 0}, |
| 1748 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1749 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1750 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1751 | {"i915_gfxec", i915_gfxec, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1752 | {"i915_fbc_status", i915_fbc_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1753 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1754 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1755 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1756 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1757 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1758 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1759 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1760 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1761 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1762 | { |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1763 | int ret; |
| 1764 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1765 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 1766 | "i915_wedged", |
| 1767 | &i915_wedged_fops); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1768 | if (ret) |
| 1769 | return ret; |
| 1770 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1771 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 1772 | if (ret) |
| 1773 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1774 | |
| 1775 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 1776 | "i915_max_freq", |
| 1777 | &i915_max_freq_fops); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1778 | if (ret) |
| 1779 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame^] | 1780 | |
| 1781 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 1782 | "i915_cache_sharing", |
| 1783 | &i915_cache_sharing_fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1784 | if (ret) |
| 1785 | return ret; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1786 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1787 | return drm_debugfs_create_files(i915_debugfs_list, |
| 1788 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1789 | minor->debugfs_root, minor); |
| 1790 | } |
| 1791 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1792 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1793 | { |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 1794 | drm_debugfs_remove_files(i915_debugfs_list, |
| 1795 | I915_DEBUGFS_ENTRIES, minor); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1796 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 1797 | 1, minor); |
Kristian Høgsberg | 33db679 | 2009-11-11 12:19:16 -0500 | [diff] [blame] | 1798 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, |
| 1799 | 1, minor); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 1800 | drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops, |
| 1801 | 1, minor); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 1802 | drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops, |
| 1803 | 1, minor); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1804 | } |
| 1805 | |
| 1806 | #endif /* CONFIG_DEBUG_FS */ |