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