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