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