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