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