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