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