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