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