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 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame^] | 1940 | if (!connector->base.encoder) |
| 1941 | continue; |
| 1942 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 1943 | encoder = to_intel_encoder(connector->base.encoder); |
| 1944 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 1945 | continue; |
| 1946 | |
| 1947 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 1948 | |
| 1949 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 1950 | if (ret) |
| 1951 | goto out; |
| 1952 | |
| 1953 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 1954 | crc[0], crc[1], crc[2], |
| 1955 | crc[3], crc[4], crc[5]); |
| 1956 | goto out; |
| 1957 | } |
| 1958 | ret = -ENODEV; |
| 1959 | out: |
| 1960 | drm_modeset_unlock_all(dev); |
| 1961 | return ret; |
| 1962 | } |
| 1963 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 1964 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 1965 | { |
| 1966 | struct drm_info_node *node = m->private; |
| 1967 | struct drm_device *dev = node->minor->dev; |
| 1968 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1969 | u64 power; |
| 1970 | u32 units; |
| 1971 | |
| 1972 | if (INTEL_INFO(dev)->gen < 6) |
| 1973 | return -ENODEV; |
| 1974 | |
| 1975 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 1976 | power = (power & 0x1f00) >> 8; |
| 1977 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 1978 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 1979 | power *= units; |
| 1980 | |
| 1981 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 1982 | |
| 1983 | return 0; |
| 1984 | } |
| 1985 | |
| 1986 | static int i915_pc8_status(struct seq_file *m, void *unused) |
| 1987 | { |
| 1988 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1989 | struct drm_device *dev = node->minor->dev; |
| 1990 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1991 | |
| 1992 | if (!IS_HASWELL(dev)) { |
| 1993 | seq_puts(m, "not supported\n"); |
| 1994 | return 0; |
| 1995 | } |
| 1996 | |
| 1997 | mutex_lock(&dev_priv->pc8.lock); |
| 1998 | seq_printf(m, "Requirements met: %s\n", |
| 1999 | yesno(dev_priv->pc8.requirements_met)); |
| 2000 | seq_printf(m, "GPU idle: %s\n", yesno(dev_priv->pc8.gpu_idle)); |
| 2001 | seq_printf(m, "Disable count: %d\n", dev_priv->pc8.disable_count); |
| 2002 | seq_printf(m, "IRQs disabled: %s\n", |
| 2003 | yesno(dev_priv->pc8.irqs_disabled)); |
| 2004 | seq_printf(m, "Enabled: %s\n", yesno(dev_priv->pc8.enabled)); |
| 2005 | mutex_unlock(&dev_priv->pc8.lock); |
| 2006 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2007 | return 0; |
| 2008 | } |
| 2009 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2010 | static const char *power_domain_str(enum intel_display_power_domain domain) |
| 2011 | { |
| 2012 | switch (domain) { |
| 2013 | case POWER_DOMAIN_PIPE_A: |
| 2014 | return "PIPE_A"; |
| 2015 | case POWER_DOMAIN_PIPE_B: |
| 2016 | return "PIPE_B"; |
| 2017 | case POWER_DOMAIN_PIPE_C: |
| 2018 | return "PIPE_C"; |
| 2019 | case POWER_DOMAIN_PIPE_A_PANEL_FITTER: |
| 2020 | return "PIPE_A_PANEL_FITTER"; |
| 2021 | case POWER_DOMAIN_PIPE_B_PANEL_FITTER: |
| 2022 | return "PIPE_B_PANEL_FITTER"; |
| 2023 | case POWER_DOMAIN_PIPE_C_PANEL_FITTER: |
| 2024 | return "PIPE_C_PANEL_FITTER"; |
| 2025 | case POWER_DOMAIN_TRANSCODER_A: |
| 2026 | return "TRANSCODER_A"; |
| 2027 | case POWER_DOMAIN_TRANSCODER_B: |
| 2028 | return "TRANSCODER_B"; |
| 2029 | case POWER_DOMAIN_TRANSCODER_C: |
| 2030 | return "TRANSCODER_C"; |
| 2031 | case POWER_DOMAIN_TRANSCODER_EDP: |
| 2032 | return "TRANSCODER_EDP"; |
| 2033 | case POWER_DOMAIN_VGA: |
| 2034 | return "VGA"; |
| 2035 | case POWER_DOMAIN_AUDIO: |
| 2036 | return "AUDIO"; |
| 2037 | case POWER_DOMAIN_INIT: |
| 2038 | return "INIT"; |
| 2039 | default: |
| 2040 | WARN_ON(1); |
| 2041 | return "?"; |
| 2042 | } |
| 2043 | } |
| 2044 | |
| 2045 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2046 | { |
| 2047 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2048 | struct drm_device *dev = node->minor->dev; |
| 2049 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2050 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2051 | int i; |
| 2052 | |
| 2053 | mutex_lock(&power_domains->lock); |
| 2054 | |
| 2055 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2056 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2057 | struct i915_power_well *power_well; |
| 2058 | enum intel_display_power_domain power_domain; |
| 2059 | |
| 2060 | power_well = &power_domains->power_wells[i]; |
| 2061 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2062 | power_well->count); |
| 2063 | |
| 2064 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2065 | power_domain++) { |
| 2066 | if (!(BIT(power_domain) & power_well->domains)) |
| 2067 | continue; |
| 2068 | |
| 2069 | seq_printf(m, " %-23s %d\n", |
| 2070 | power_domain_str(power_domain), |
| 2071 | power_domains->domain_use_count[power_domain]); |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | mutex_unlock(&power_domains->lock); |
| 2076 | |
| 2077 | return 0; |
| 2078 | } |
| 2079 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2080 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2081 | struct drm_display_mode *mode) |
| 2082 | { |
| 2083 | int i; |
| 2084 | |
| 2085 | for (i = 0; i < tabs; i++) |
| 2086 | seq_putc(m, '\t'); |
| 2087 | |
| 2088 | seq_printf(m, "id %d:\"%s\" freq %d clock %d hdisp %d hss %d hse %d htot %d vdisp %d vss %d vse %d vtot %d type 0x%x flags 0x%x\n", |
| 2089 | mode->base.id, mode->name, |
| 2090 | mode->vrefresh, mode->clock, |
| 2091 | mode->hdisplay, mode->hsync_start, |
| 2092 | mode->hsync_end, mode->htotal, |
| 2093 | mode->vdisplay, mode->vsync_start, |
| 2094 | mode->vsync_end, mode->vtotal, |
| 2095 | mode->type, mode->flags); |
| 2096 | } |
| 2097 | |
| 2098 | static void intel_encoder_info(struct seq_file *m, |
| 2099 | struct intel_crtc *intel_crtc, |
| 2100 | struct intel_encoder *intel_encoder) |
| 2101 | { |
| 2102 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2103 | struct drm_device *dev = node->minor->dev; |
| 2104 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2105 | struct intel_connector *intel_connector; |
| 2106 | struct drm_encoder *encoder; |
| 2107 | |
| 2108 | encoder = &intel_encoder->base; |
| 2109 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
| 2110 | encoder->base.id, drm_get_encoder_name(encoder)); |
| 2111 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2112 | struct drm_connector *connector = &intel_connector->base; |
| 2113 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2114 | connector->base.id, |
| 2115 | drm_get_connector_name(connector), |
| 2116 | drm_get_connector_status_name(connector->status)); |
| 2117 | if (connector->status == connector_status_connected) { |
| 2118 | struct drm_display_mode *mode = &crtc->mode; |
| 2119 | seq_printf(m, ", mode:\n"); |
| 2120 | intel_seq_print_mode(m, 2, mode); |
| 2121 | } else { |
| 2122 | seq_putc(m, '\n'); |
| 2123 | } |
| 2124 | } |
| 2125 | } |
| 2126 | |
| 2127 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2128 | { |
| 2129 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2130 | struct drm_device *dev = node->minor->dev; |
| 2131 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2132 | struct intel_encoder *intel_encoder; |
| 2133 | |
| 2134 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
| 2135 | crtc->fb->base.id, crtc->x, crtc->y, |
| 2136 | crtc->fb->width, crtc->fb->height); |
| 2137 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2138 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2139 | } |
| 2140 | |
| 2141 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2142 | { |
| 2143 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2144 | |
| 2145 | seq_printf(m, "\tfixed mode:\n"); |
| 2146 | intel_seq_print_mode(m, 2, mode); |
| 2147 | } |
| 2148 | |
| 2149 | static void intel_dp_info(struct seq_file *m, |
| 2150 | struct intel_connector *intel_connector) |
| 2151 | { |
| 2152 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2153 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2154 | |
| 2155 | seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); |
| 2156 | seq_printf(m, "\taudio support: %s\n", intel_dp->has_audio ? "yes" : |
| 2157 | "no"); |
| 2158 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2159 | intel_panel_info(m, &intel_connector->panel); |
| 2160 | } |
| 2161 | |
| 2162 | static void intel_hdmi_info(struct seq_file *m, |
| 2163 | struct intel_connector *intel_connector) |
| 2164 | { |
| 2165 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2166 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2167 | |
| 2168 | seq_printf(m, "\taudio support: %s\n", intel_hdmi->has_audio ? "yes" : |
| 2169 | "no"); |
| 2170 | } |
| 2171 | |
| 2172 | static void intel_lvds_info(struct seq_file *m, |
| 2173 | struct intel_connector *intel_connector) |
| 2174 | { |
| 2175 | intel_panel_info(m, &intel_connector->panel); |
| 2176 | } |
| 2177 | |
| 2178 | static void intel_connector_info(struct seq_file *m, |
| 2179 | struct drm_connector *connector) |
| 2180 | { |
| 2181 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2182 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2183 | |
| 2184 | seq_printf(m, "connector %d: type %s, status: %s\n", |
| 2185 | connector->base.id, drm_get_connector_name(connector), |
| 2186 | drm_get_connector_status_name(connector->status)); |
| 2187 | if (connector->status == connector_status_connected) { |
| 2188 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2189 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2190 | connector->display_info.width_mm, |
| 2191 | connector->display_info.height_mm); |
| 2192 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2193 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2194 | seq_printf(m, "\tCEA rev: %d\n", |
| 2195 | connector->display_info.cea_rev); |
| 2196 | } |
| 2197 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2198 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2199 | intel_dp_info(m, intel_connector); |
| 2200 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2201 | intel_hdmi_info(m, intel_connector); |
| 2202 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2203 | intel_lvds_info(m, intel_connector); |
| 2204 | |
| 2205 | } |
| 2206 | |
| 2207 | static int i915_display_info(struct seq_file *m, void *unused) |
| 2208 | { |
| 2209 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2210 | struct drm_device *dev = node->minor->dev; |
| 2211 | struct drm_crtc *crtc; |
| 2212 | struct drm_connector *connector; |
| 2213 | |
| 2214 | drm_modeset_lock_all(dev); |
| 2215 | seq_printf(m, "CRTC info\n"); |
| 2216 | seq_printf(m, "---------\n"); |
| 2217 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 2218 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 2219 | |
| 2220 | seq_printf(m, "CRTC %d: pipe: %c, active: %s\n", |
| 2221 | crtc->base.id, pipe_name(intel_crtc->pipe), |
| 2222 | intel_crtc->active ? "yes" : "no"); |
| 2223 | if (intel_crtc->active) |
| 2224 | intel_crtc_info(m, intel_crtc); |
| 2225 | } |
| 2226 | |
| 2227 | seq_printf(m, "\n"); |
| 2228 | seq_printf(m, "Connector info\n"); |
| 2229 | seq_printf(m, "--------------\n"); |
| 2230 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 2231 | intel_connector_info(m, connector); |
| 2232 | } |
| 2233 | drm_modeset_unlock_all(dev); |
| 2234 | |
| 2235 | return 0; |
| 2236 | } |
| 2237 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2238 | struct pipe_crc_info { |
| 2239 | const char *name; |
| 2240 | struct drm_device *dev; |
| 2241 | enum pipe pipe; |
| 2242 | }; |
| 2243 | |
| 2244 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2245 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2246 | struct pipe_crc_info *info = inode->i_private; |
| 2247 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2248 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2249 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 2250 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 2251 | return -ENODEV; |
| 2252 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2253 | spin_lock_irq(&pipe_crc->lock); |
| 2254 | |
| 2255 | if (pipe_crc->opened) { |
| 2256 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2257 | return -EBUSY; /* already open */ |
| 2258 | } |
| 2259 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2260 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2261 | filep->private_data = inode->i_private; |
| 2262 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2263 | spin_unlock_irq(&pipe_crc->lock); |
| 2264 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2265 | return 0; |
| 2266 | } |
| 2267 | |
| 2268 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 2269 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2270 | struct pipe_crc_info *info = inode->i_private; |
| 2271 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2272 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2273 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2274 | spin_lock_irq(&pipe_crc->lock); |
| 2275 | pipe_crc->opened = false; |
| 2276 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2277 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2278 | return 0; |
| 2279 | } |
| 2280 | |
| 2281 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 2282 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 2283 | /* account for \'0' */ |
| 2284 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 2285 | |
| 2286 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 2287 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2288 | assert_spin_locked(&pipe_crc->lock); |
| 2289 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 2290 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2291 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2292 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2293 | static ssize_t |
| 2294 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 2295 | loff_t *pos) |
| 2296 | { |
| 2297 | struct pipe_crc_info *info = filep->private_data; |
| 2298 | struct drm_device *dev = info->dev; |
| 2299 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2300 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2301 | char buf[PIPE_CRC_BUFFER_LEN]; |
| 2302 | int head, tail, n_entries, n; |
| 2303 | ssize_t bytes_read; |
| 2304 | |
| 2305 | /* |
| 2306 | * Don't allow user space to provide buffers not big enough to hold |
| 2307 | * a line of data. |
| 2308 | */ |
| 2309 | if (count < PIPE_CRC_LINE_LEN) |
| 2310 | return -EINVAL; |
| 2311 | |
| 2312 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 2313 | return 0; |
| 2314 | |
| 2315 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2316 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2317 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2318 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2319 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2320 | if (filep->f_flags & O_NONBLOCK) { |
| 2321 | spin_unlock_irq(&pipe_crc->lock); |
| 2322 | return -EAGAIN; |
| 2323 | } |
| 2324 | |
| 2325 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 2326 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 2327 | if (ret) { |
| 2328 | spin_unlock_irq(&pipe_crc->lock); |
| 2329 | return ret; |
| 2330 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2331 | } |
| 2332 | |
| 2333 | /* We now have one or more entries to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2334 | head = pipe_crc->head; |
| 2335 | tail = pipe_crc->tail; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2336 | n_entries = min((size_t)CIRC_CNT(head, tail, INTEL_PIPE_CRC_ENTRIES_NR), |
| 2337 | count / PIPE_CRC_LINE_LEN); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2338 | spin_unlock_irq(&pipe_crc->lock); |
| 2339 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2340 | bytes_read = 0; |
| 2341 | n = 0; |
| 2342 | do { |
| 2343 | struct intel_pipe_crc_entry *entry = &pipe_crc->entries[tail]; |
| 2344 | int ret; |
| 2345 | |
| 2346 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 2347 | "%8u %8x %8x %8x %8x %8x\n", |
| 2348 | entry->frame, entry->crc[0], |
| 2349 | entry->crc[1], entry->crc[2], |
| 2350 | entry->crc[3], entry->crc[4]); |
| 2351 | |
| 2352 | ret = copy_to_user(user_buf + n * PIPE_CRC_LINE_LEN, |
| 2353 | buf, PIPE_CRC_LINE_LEN); |
| 2354 | if (ret == PIPE_CRC_LINE_LEN) |
| 2355 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 2356 | |
| 2357 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 2358 | tail = (tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2359 | n++; |
| 2360 | } while (--n_entries); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2361 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2362 | spin_lock_irq(&pipe_crc->lock); |
| 2363 | pipe_crc->tail = tail; |
| 2364 | spin_unlock_irq(&pipe_crc->lock); |
| 2365 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2366 | return bytes_read; |
| 2367 | } |
| 2368 | |
| 2369 | static const struct file_operations i915_pipe_crc_fops = { |
| 2370 | .owner = THIS_MODULE, |
| 2371 | .open = i915_pipe_crc_open, |
| 2372 | .read = i915_pipe_crc_read, |
| 2373 | .release = i915_pipe_crc_release, |
| 2374 | }; |
| 2375 | |
| 2376 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 2377 | { |
| 2378 | .name = "i915_pipe_A_crc", |
| 2379 | .pipe = PIPE_A, |
| 2380 | }, |
| 2381 | { |
| 2382 | .name = "i915_pipe_B_crc", |
| 2383 | .pipe = PIPE_B, |
| 2384 | }, |
| 2385 | { |
| 2386 | .name = "i915_pipe_C_crc", |
| 2387 | .pipe = PIPE_C, |
| 2388 | }, |
| 2389 | }; |
| 2390 | |
| 2391 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 2392 | enum pipe pipe) |
| 2393 | { |
| 2394 | struct drm_device *dev = minor->dev; |
| 2395 | struct dentry *ent; |
| 2396 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 2397 | |
| 2398 | info->dev = dev; |
| 2399 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 2400 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 2401 | if (!ent) |
| 2402 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2403 | |
| 2404 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2405 | } |
| 2406 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 2407 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2408 | "none", |
| 2409 | "plane1", |
| 2410 | "plane2", |
| 2411 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2412 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2413 | "TV", |
| 2414 | "DP-B", |
| 2415 | "DP-C", |
| 2416 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2417 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2418 | }; |
| 2419 | |
| 2420 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 2421 | { |
| 2422 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 2423 | return pipe_crc_sources[source]; |
| 2424 | } |
| 2425 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2426 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2427 | { |
| 2428 | struct drm_device *dev = m->private; |
| 2429 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2430 | int i; |
| 2431 | |
| 2432 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 2433 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 2434 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 2435 | |
| 2436 | return 0; |
| 2437 | } |
| 2438 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2439 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2440 | { |
| 2441 | struct drm_device *dev = inode->i_private; |
| 2442 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2443 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2444 | } |
| 2445 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2446 | 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] | 2447 | uint32_t *val) |
| 2448 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2449 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 2450 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2451 | |
| 2452 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 2453 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2454 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 2455 | break; |
| 2456 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 2457 | *val = 0; |
| 2458 | break; |
| 2459 | default: |
| 2460 | return -EINVAL; |
| 2461 | } |
| 2462 | |
| 2463 | return 0; |
| 2464 | } |
| 2465 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2466 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 2467 | enum intel_pipe_crc_source *source) |
| 2468 | { |
| 2469 | struct intel_encoder *encoder; |
| 2470 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 2471 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2472 | int ret = 0; |
| 2473 | |
| 2474 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2475 | |
| 2476 | mutex_lock(&dev->mode_config.mutex); |
| 2477 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
| 2478 | base.head) { |
| 2479 | if (!encoder->base.crtc) |
| 2480 | continue; |
| 2481 | |
| 2482 | crtc = to_intel_crtc(encoder->base.crtc); |
| 2483 | |
| 2484 | if (crtc->pipe != pipe) |
| 2485 | continue; |
| 2486 | |
| 2487 | switch (encoder->type) { |
| 2488 | case INTEL_OUTPUT_TVOUT: |
| 2489 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 2490 | break; |
| 2491 | case INTEL_OUTPUT_DISPLAYPORT: |
| 2492 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 2493 | dig_port = enc_to_dig_port(&encoder->base); |
| 2494 | switch (dig_port->port) { |
| 2495 | case PORT_B: |
| 2496 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 2497 | break; |
| 2498 | case PORT_C: |
| 2499 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 2500 | break; |
| 2501 | case PORT_D: |
| 2502 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 2503 | break; |
| 2504 | default: |
| 2505 | WARN(1, "nonexisting DP port %c\n", |
| 2506 | port_name(dig_port->port)); |
| 2507 | break; |
| 2508 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2509 | break; |
| 2510 | } |
| 2511 | } |
| 2512 | mutex_unlock(&dev->mode_config.mutex); |
| 2513 | |
| 2514 | return ret; |
| 2515 | } |
| 2516 | |
| 2517 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 2518 | enum pipe pipe, |
| 2519 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2520 | uint32_t *val) |
| 2521 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2522 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2523 | bool need_stable_symbols = false; |
| 2524 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2525 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 2526 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 2527 | if (ret) |
| 2528 | return ret; |
| 2529 | } |
| 2530 | |
| 2531 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2532 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2533 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 2534 | break; |
| 2535 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 2536 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2537 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2538 | break; |
| 2539 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 2540 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2541 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2542 | break; |
| 2543 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 2544 | *val = 0; |
| 2545 | break; |
| 2546 | default: |
| 2547 | return -EINVAL; |
| 2548 | } |
| 2549 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2550 | /* |
| 2551 | * When the pipe CRC tap point is after the transcoders we need |
| 2552 | * to tweak symbol-level features to produce a deterministic series of |
| 2553 | * symbols for a given frame. We need to reset those features only once |
| 2554 | * a frame (instead of every nth symbol): |
| 2555 | * - DC-balance: used to ensure a better clock recovery from the data |
| 2556 | * link (SDVO) |
| 2557 | * - DisplayPort scrambling: used for EMI reduction |
| 2558 | */ |
| 2559 | if (need_stable_symbols) { |
| 2560 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 2561 | |
| 2562 | WARN_ON(!IS_G4X(dev)); |
| 2563 | |
| 2564 | tmp |= DC_BALANCE_RESET_VLV; |
| 2565 | if (pipe == PIPE_A) |
| 2566 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 2567 | else |
| 2568 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 2569 | |
| 2570 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 2571 | } |
| 2572 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2573 | return 0; |
| 2574 | } |
| 2575 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2576 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2577 | enum pipe pipe, |
| 2578 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2579 | uint32_t *val) |
| 2580 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2581 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2582 | bool need_stable_symbols = false; |
| 2583 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2584 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 2585 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 2586 | if (ret) |
| 2587 | return ret; |
| 2588 | } |
| 2589 | |
| 2590 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2591 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2592 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 2593 | break; |
| 2594 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 2595 | if (!SUPPORTS_TV(dev)) |
| 2596 | return -EINVAL; |
| 2597 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 2598 | break; |
| 2599 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 2600 | if (!IS_G4X(dev)) |
| 2601 | return -EINVAL; |
| 2602 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2603 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2604 | break; |
| 2605 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 2606 | if (!IS_G4X(dev)) |
| 2607 | return -EINVAL; |
| 2608 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2609 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2610 | break; |
| 2611 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 2612 | if (!IS_G4X(dev)) |
| 2613 | return -EINVAL; |
| 2614 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2615 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2616 | break; |
| 2617 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 2618 | *val = 0; |
| 2619 | break; |
| 2620 | default: |
| 2621 | return -EINVAL; |
| 2622 | } |
| 2623 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2624 | /* |
| 2625 | * When the pipe CRC tap point is after the transcoders we need |
| 2626 | * to tweak symbol-level features to produce a deterministic series of |
| 2627 | * symbols for a given frame. We need to reset those features only once |
| 2628 | * a frame (instead of every nth symbol): |
| 2629 | * - DC-balance: used to ensure a better clock recovery from the data |
| 2630 | * link (SDVO) |
| 2631 | * - DisplayPort scrambling: used for EMI reduction |
| 2632 | */ |
| 2633 | if (need_stable_symbols) { |
| 2634 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 2635 | |
| 2636 | WARN_ON(!IS_G4X(dev)); |
| 2637 | |
| 2638 | I915_WRITE(PORT_DFT_I9XX, |
| 2639 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 2640 | |
| 2641 | if (pipe == PIPE_A) |
| 2642 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 2643 | else |
| 2644 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 2645 | |
| 2646 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 2647 | } |
| 2648 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2649 | return 0; |
| 2650 | } |
| 2651 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2652 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 2653 | enum pipe pipe) |
| 2654 | { |
| 2655 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2656 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 2657 | |
| 2658 | if (pipe == PIPE_A) |
| 2659 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 2660 | else |
| 2661 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 2662 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 2663 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 2664 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 2665 | |
| 2666 | } |
| 2667 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2668 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 2669 | enum pipe pipe) |
| 2670 | { |
| 2671 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2672 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 2673 | |
| 2674 | if (pipe == PIPE_A) |
| 2675 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 2676 | else |
| 2677 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 2678 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 2679 | |
| 2680 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 2681 | I915_WRITE(PORT_DFT_I9XX, |
| 2682 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 2683 | } |
| 2684 | } |
| 2685 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2686 | 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] | 2687 | uint32_t *val) |
| 2688 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2689 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 2690 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2691 | |
| 2692 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2693 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 2694 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 2695 | break; |
| 2696 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 2697 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 2698 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2699 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2700 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 2701 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2702 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2703 | *val = 0; |
| 2704 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2705 | default: |
| 2706 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2707 | } |
| 2708 | |
| 2709 | return 0; |
| 2710 | } |
| 2711 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2712 | 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] | 2713 | uint32_t *val) |
| 2714 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2715 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 2716 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 2717 | |
| 2718 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2719 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 2720 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 2721 | break; |
| 2722 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 2723 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 2724 | break; |
| 2725 | case INTEL_PIPE_CRC_SOURCE_PF: |
| 2726 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 2727 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2728 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2729 | *val = 0; |
| 2730 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2731 | default: |
| 2732 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2733 | } |
| 2734 | |
| 2735 | return 0; |
| 2736 | } |
| 2737 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2738 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 2739 | enum intel_pipe_crc_source source) |
| 2740 | { |
| 2741 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 2742 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 2743 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2744 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2745 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 2746 | if (pipe_crc->source == source) |
| 2747 | return 0; |
| 2748 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 2749 | /* forbid changing the source without going back to 'none' */ |
| 2750 | if (pipe_crc->source && source) |
| 2751 | return -EINVAL; |
| 2752 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 2753 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2754 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 2755 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2756 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2757 | else if (IS_VALLEYVIEW(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2758 | ret = vlv_pipe_crc_ctl_reg(dev,pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2759 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2760 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2761 | else |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2762 | ret = ivb_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2763 | |
| 2764 | if (ret != 0) |
| 2765 | return ret; |
| 2766 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 2767 | /* none -> real source transition */ |
| 2768 | if (source) { |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 2769 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 2770 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 2771 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 2772 | pipe_crc->entries = kzalloc(sizeof(*pipe_crc->entries) * |
| 2773 | INTEL_PIPE_CRC_ENTRIES_NR, |
| 2774 | GFP_KERNEL); |
| 2775 | if (!pipe_crc->entries) |
| 2776 | return -ENOMEM; |
| 2777 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2778 | spin_lock_irq(&pipe_crc->lock); |
| 2779 | pipe_crc->head = 0; |
| 2780 | pipe_crc->tail = 0; |
| 2781 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 2782 | } |
| 2783 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 2784 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2785 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2786 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 2787 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 2788 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 2789 | /* real source -> none transition */ |
| 2790 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2791 | struct intel_pipe_crc_entry *entries; |
| 2792 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 2793 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 2794 | pipe_name(pipe)); |
| 2795 | |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 2796 | intel_wait_for_vblank(dev, pipe); |
| 2797 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2798 | spin_lock_irq(&pipe_crc->lock); |
| 2799 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 2800 | pipe_crc->entries = NULL; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2801 | spin_unlock_irq(&pipe_crc->lock); |
| 2802 | |
| 2803 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2804 | |
| 2805 | if (IS_G4X(dev)) |
| 2806 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2807 | else if (IS_VALLEYVIEW(dev)) |
| 2808 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 2809 | } |
| 2810 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2811 | return 0; |
| 2812 | } |
| 2813 | |
| 2814 | /* |
| 2815 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2816 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 2817 | * object: 'pipe' |
| 2818 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2819 | * source: (none | plane1 | plane2 | pf) |
| 2820 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 2821 | * |
| 2822 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2823 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 2824 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2825 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2826 | 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] | 2827 | { |
| 2828 | int n_words = 0; |
| 2829 | |
| 2830 | while (*buf) { |
| 2831 | char *end; |
| 2832 | |
| 2833 | /* skip leading white space */ |
| 2834 | buf = skip_spaces(buf); |
| 2835 | if (!*buf) |
| 2836 | break; /* end of buffer */ |
| 2837 | |
| 2838 | /* find end of word */ |
| 2839 | for (end = buf; *end && !isspace(*end); end++) |
| 2840 | ; |
| 2841 | |
| 2842 | if (n_words == max_words) { |
| 2843 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 2844 | max_words); |
| 2845 | return -EINVAL; /* ran out of words[] before bytes */ |
| 2846 | } |
| 2847 | |
| 2848 | if (*end) |
| 2849 | *end++ = '\0'; |
| 2850 | words[n_words++] = buf; |
| 2851 | buf = end; |
| 2852 | } |
| 2853 | |
| 2854 | return n_words; |
| 2855 | } |
| 2856 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2857 | enum intel_pipe_crc_object { |
| 2858 | PIPE_CRC_OBJECT_PIPE, |
| 2859 | }; |
| 2860 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 2861 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2862 | "pipe", |
| 2863 | }; |
| 2864 | |
| 2865 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2866 | 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] | 2867 | { |
| 2868 | int i; |
| 2869 | |
| 2870 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 2871 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2872 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2873 | return 0; |
| 2874 | } |
| 2875 | |
| 2876 | return -EINVAL; |
| 2877 | } |
| 2878 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2879 | 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] | 2880 | { |
| 2881 | const char name = buf[0]; |
| 2882 | |
| 2883 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 2884 | return -EINVAL; |
| 2885 | |
| 2886 | *pipe = name - 'A'; |
| 2887 | |
| 2888 | return 0; |
| 2889 | } |
| 2890 | |
| 2891 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2892 | 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] | 2893 | { |
| 2894 | int i; |
| 2895 | |
| 2896 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 2897 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2898 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2899 | return 0; |
| 2900 | } |
| 2901 | |
| 2902 | return -EINVAL; |
| 2903 | } |
| 2904 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2905 | 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] | 2906 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2907 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2908 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2909 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2910 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2911 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2912 | enum intel_pipe_crc_source source; |
| 2913 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2914 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2915 | if (n_words != N_WORDS) { |
| 2916 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 2917 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2918 | return -EINVAL; |
| 2919 | } |
| 2920 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2921 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2922 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2923 | return -EINVAL; |
| 2924 | } |
| 2925 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2926 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2927 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 2928 | return -EINVAL; |
| 2929 | } |
| 2930 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2931 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 2932 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2933 | return -EINVAL; |
| 2934 | } |
| 2935 | |
| 2936 | return pipe_crc_set_source(dev, pipe, source); |
| 2937 | } |
| 2938 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2939 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 2940 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2941 | { |
| 2942 | struct seq_file *m = file->private_data; |
| 2943 | struct drm_device *dev = m->private; |
| 2944 | char *tmpbuf; |
| 2945 | int ret; |
| 2946 | |
| 2947 | if (len == 0) |
| 2948 | return 0; |
| 2949 | |
| 2950 | if (len > PAGE_SIZE - 1) { |
| 2951 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 2952 | PAGE_SIZE); |
| 2953 | return -E2BIG; |
| 2954 | } |
| 2955 | |
| 2956 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 2957 | if (!tmpbuf) |
| 2958 | return -ENOMEM; |
| 2959 | |
| 2960 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 2961 | ret = -EFAULT; |
| 2962 | goto out; |
| 2963 | } |
| 2964 | tmpbuf[len] = '\0'; |
| 2965 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2966 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2967 | |
| 2968 | out: |
| 2969 | kfree(tmpbuf); |
| 2970 | if (ret < 0) |
| 2971 | return ret; |
| 2972 | |
| 2973 | *offp += len; |
| 2974 | return len; |
| 2975 | } |
| 2976 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2977 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2978 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2979 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2980 | .read = seq_read, |
| 2981 | .llseek = seq_lseek, |
| 2982 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2983 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2984 | }; |
| 2985 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 2986 | static void wm_latency_show(struct seq_file *m, const uint16_t wm[5]) |
| 2987 | { |
| 2988 | struct drm_device *dev = m->private; |
| 2989 | int num_levels = IS_HASWELL(dev) || IS_BROADWELL(dev) ? 5 : 4; |
| 2990 | int level; |
| 2991 | |
| 2992 | drm_modeset_lock_all(dev); |
| 2993 | |
| 2994 | for (level = 0; level < num_levels; level++) { |
| 2995 | unsigned int latency = wm[level]; |
| 2996 | |
| 2997 | /* WM1+ latency values in 0.5us units */ |
| 2998 | if (level > 0) |
| 2999 | latency *= 5; |
| 3000 | |
| 3001 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
| 3002 | level, wm[level], |
| 3003 | latency / 10, latency % 10); |
| 3004 | } |
| 3005 | |
| 3006 | drm_modeset_unlock_all(dev); |
| 3007 | } |
| 3008 | |
| 3009 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3010 | { |
| 3011 | struct drm_device *dev = m->private; |
| 3012 | |
| 3013 | wm_latency_show(m, to_i915(dev)->wm.pri_latency); |
| 3014 | |
| 3015 | return 0; |
| 3016 | } |
| 3017 | |
| 3018 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3019 | { |
| 3020 | struct drm_device *dev = m->private; |
| 3021 | |
| 3022 | wm_latency_show(m, to_i915(dev)->wm.spr_latency); |
| 3023 | |
| 3024 | return 0; |
| 3025 | } |
| 3026 | |
| 3027 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3028 | { |
| 3029 | struct drm_device *dev = m->private; |
| 3030 | |
| 3031 | wm_latency_show(m, to_i915(dev)->wm.cur_latency); |
| 3032 | |
| 3033 | return 0; |
| 3034 | } |
| 3035 | |
| 3036 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3037 | { |
| 3038 | struct drm_device *dev = inode->i_private; |
| 3039 | |
| 3040 | if (!HAS_PCH_SPLIT(dev)) |
| 3041 | return -ENODEV; |
| 3042 | |
| 3043 | return single_open(file, pri_wm_latency_show, dev); |
| 3044 | } |
| 3045 | |
| 3046 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3047 | { |
| 3048 | struct drm_device *dev = inode->i_private; |
| 3049 | |
| 3050 | if (!HAS_PCH_SPLIT(dev)) |
| 3051 | return -ENODEV; |
| 3052 | |
| 3053 | return single_open(file, spr_wm_latency_show, dev); |
| 3054 | } |
| 3055 | |
| 3056 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3057 | { |
| 3058 | struct drm_device *dev = inode->i_private; |
| 3059 | |
| 3060 | if (!HAS_PCH_SPLIT(dev)) |
| 3061 | return -ENODEV; |
| 3062 | |
| 3063 | return single_open(file, cur_wm_latency_show, dev); |
| 3064 | } |
| 3065 | |
| 3066 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
| 3067 | size_t len, loff_t *offp, uint16_t wm[5]) |
| 3068 | { |
| 3069 | struct seq_file *m = file->private_data; |
| 3070 | struct drm_device *dev = m->private; |
| 3071 | uint16_t new[5] = { 0 }; |
| 3072 | int num_levels = IS_HASWELL(dev) || IS_BROADWELL(dev) ? 5 : 4; |
| 3073 | int level; |
| 3074 | int ret; |
| 3075 | char tmp[32]; |
| 3076 | |
| 3077 | if (len >= sizeof(tmp)) |
| 3078 | return -EINVAL; |
| 3079 | |
| 3080 | if (copy_from_user(tmp, ubuf, len)) |
| 3081 | return -EFAULT; |
| 3082 | |
| 3083 | tmp[len] = '\0'; |
| 3084 | |
| 3085 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]); |
| 3086 | if (ret != num_levels) |
| 3087 | return -EINVAL; |
| 3088 | |
| 3089 | drm_modeset_lock_all(dev); |
| 3090 | |
| 3091 | for (level = 0; level < num_levels; level++) |
| 3092 | wm[level] = new[level]; |
| 3093 | |
| 3094 | drm_modeset_unlock_all(dev); |
| 3095 | |
| 3096 | return len; |
| 3097 | } |
| 3098 | |
| 3099 | |
| 3100 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3101 | size_t len, loff_t *offp) |
| 3102 | { |
| 3103 | struct seq_file *m = file->private_data; |
| 3104 | struct drm_device *dev = m->private; |
| 3105 | |
| 3106 | return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency); |
| 3107 | } |
| 3108 | |
| 3109 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3110 | size_t len, loff_t *offp) |
| 3111 | { |
| 3112 | struct seq_file *m = file->private_data; |
| 3113 | struct drm_device *dev = m->private; |
| 3114 | |
| 3115 | return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency); |
| 3116 | } |
| 3117 | |
| 3118 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3119 | size_t len, loff_t *offp) |
| 3120 | { |
| 3121 | struct seq_file *m = file->private_data; |
| 3122 | struct drm_device *dev = m->private; |
| 3123 | |
| 3124 | return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency); |
| 3125 | } |
| 3126 | |
| 3127 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3128 | .owner = THIS_MODULE, |
| 3129 | .open = pri_wm_latency_open, |
| 3130 | .read = seq_read, |
| 3131 | .llseek = seq_lseek, |
| 3132 | .release = single_release, |
| 3133 | .write = pri_wm_latency_write |
| 3134 | }; |
| 3135 | |
| 3136 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3137 | .owner = THIS_MODULE, |
| 3138 | .open = spr_wm_latency_open, |
| 3139 | .read = seq_read, |
| 3140 | .llseek = seq_lseek, |
| 3141 | .release = single_release, |
| 3142 | .write = spr_wm_latency_write |
| 3143 | }; |
| 3144 | |
| 3145 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3146 | .owner = THIS_MODULE, |
| 3147 | .open = cur_wm_latency_open, |
| 3148 | .read = seq_read, |
| 3149 | .llseek = seq_lseek, |
| 3150 | .release = single_release, |
| 3151 | .write = cur_wm_latency_write |
| 3152 | }; |
| 3153 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3154 | static int |
| 3155 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3156 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3157 | struct drm_device *dev = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3158 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3159 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3160 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3161 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3162 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3163 | } |
| 3164 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3165 | static int |
| 3166 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3167 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3168 | struct drm_device *dev = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3169 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3170 | DRM_INFO("Manually setting wedged to %llu\n", val); |
Chris Wilson | 527f9e9 | 2010-11-11 01:16:58 +0000 | [diff] [blame] | 3171 | i915_handle_error(dev, val); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3172 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3173 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3174 | } |
| 3175 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3176 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3177 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3178 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3179 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3180 | static int |
| 3181 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3182 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3183 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3184 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3185 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3186 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3187 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3188 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3189 | } |
| 3190 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3191 | static int |
| 3192 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3193 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3194 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3195 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3196 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3197 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3198 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3199 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 3200 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3201 | if (ret) |
| 3202 | return ret; |
| 3203 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 3204 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3205 | mutex_unlock(&dev->struct_mutex); |
| 3206 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3207 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3208 | } |
| 3209 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3210 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 3211 | i915_ring_stop_get, i915_ring_stop_set, |
| 3212 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 3213 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3214 | static int |
| 3215 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 3216 | { |
| 3217 | struct drm_device *dev = data; |
| 3218 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3219 | |
| 3220 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 3221 | return 0; |
| 3222 | } |
| 3223 | |
| 3224 | static int |
| 3225 | i915_ring_missed_irq_set(void *data, u64 val) |
| 3226 | { |
| 3227 | struct drm_device *dev = data; |
| 3228 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3229 | int ret; |
| 3230 | |
| 3231 | /* Lock against concurrent debugfs callers */ |
| 3232 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3233 | if (ret) |
| 3234 | return ret; |
| 3235 | dev_priv->gpu_error.missed_irq_rings = val; |
| 3236 | mutex_unlock(&dev->struct_mutex); |
| 3237 | |
| 3238 | return 0; |
| 3239 | } |
| 3240 | |
| 3241 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 3242 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 3243 | "0x%08llx\n"); |
| 3244 | |
| 3245 | static int |
| 3246 | i915_ring_test_irq_get(void *data, u64 *val) |
| 3247 | { |
| 3248 | struct drm_device *dev = data; |
| 3249 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3250 | |
| 3251 | *val = dev_priv->gpu_error.test_irq_rings; |
| 3252 | |
| 3253 | return 0; |
| 3254 | } |
| 3255 | |
| 3256 | static int |
| 3257 | i915_ring_test_irq_set(void *data, u64 val) |
| 3258 | { |
| 3259 | struct drm_device *dev = data; |
| 3260 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3261 | int ret; |
| 3262 | |
| 3263 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 3264 | |
| 3265 | /* Lock against concurrent debugfs callers */ |
| 3266 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3267 | if (ret) |
| 3268 | return ret; |
| 3269 | |
| 3270 | dev_priv->gpu_error.test_irq_rings = val; |
| 3271 | mutex_unlock(&dev->struct_mutex); |
| 3272 | |
| 3273 | return 0; |
| 3274 | } |
| 3275 | |
| 3276 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 3277 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 3278 | "0x%08llx\n"); |
| 3279 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3280 | #define DROP_UNBOUND 0x1 |
| 3281 | #define DROP_BOUND 0x2 |
| 3282 | #define DROP_RETIRE 0x4 |
| 3283 | #define DROP_ACTIVE 0x8 |
| 3284 | #define DROP_ALL (DROP_UNBOUND | \ |
| 3285 | DROP_BOUND | \ |
| 3286 | DROP_RETIRE | \ |
| 3287 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3288 | static int |
| 3289 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3290 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3291 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3292 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3293 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3294 | } |
| 3295 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3296 | static int |
| 3297 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3298 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3299 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3300 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3301 | struct drm_i915_gem_object *obj, *next; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3302 | struct i915_address_space *vm; |
| 3303 | struct i915_vma *vma, *x; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3304 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3305 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 3306 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3307 | |
| 3308 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 3309 | * on ioctls on -EAGAIN. */ |
| 3310 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3311 | if (ret) |
| 3312 | return ret; |
| 3313 | |
| 3314 | if (val & DROP_ACTIVE) { |
| 3315 | ret = i915_gpu_idle(dev); |
| 3316 | if (ret) |
| 3317 | goto unlock; |
| 3318 | } |
| 3319 | |
| 3320 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 3321 | i915_gem_retire_requests(dev); |
| 3322 | |
| 3323 | if (val & DROP_BOUND) { |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3324 | list_for_each_entry(vm, &dev_priv->vm_list, global_link) { |
| 3325 | list_for_each_entry_safe(vma, x, &vm->inactive_list, |
| 3326 | mm_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 3327 | if (vma->pin_count) |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3328 | continue; |
Ben Widawsky | 31a46c9 | 2013-07-31 16:59:55 -0700 | [diff] [blame] | 3329 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3330 | ret = i915_vma_unbind(vma); |
| 3331 | if (ret) |
| 3332 | goto unlock; |
| 3333 | } |
Ben Widawsky | 31a46c9 | 2013-07-31 16:59:55 -0700 | [diff] [blame] | 3334 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3335 | } |
| 3336 | |
| 3337 | if (val & DROP_UNBOUND) { |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 3338 | list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list, |
| 3339 | global_list) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3340 | if (obj->pages_pin_count == 0) { |
| 3341 | ret = i915_gem_object_put_pages(obj); |
| 3342 | if (ret) |
| 3343 | goto unlock; |
| 3344 | } |
| 3345 | } |
| 3346 | |
| 3347 | unlock: |
| 3348 | mutex_unlock(&dev->struct_mutex); |
| 3349 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3350 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3351 | } |
| 3352 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3353 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 3354 | i915_drop_caches_get, i915_drop_caches_set, |
| 3355 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3356 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3357 | static int |
| 3358 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3359 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3360 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3361 | drm_i915_private_t *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3362 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3363 | |
| 3364 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3365 | return -ENODEV; |
| 3366 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3367 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3368 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3369 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3370 | if (ret) |
| 3371 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3372 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3373 | if (IS_VALLEYVIEW(dev)) |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 3374 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.max_delay); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3375 | else |
| 3376 | *val = dev_priv->rps.max_delay * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3377 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3378 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3379 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3380 | } |
| 3381 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3382 | static int |
| 3383 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3384 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3385 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3386 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3387 | u32 rp_state_cap, hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3388 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3389 | |
| 3390 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3391 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3392 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3393 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3394 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3395 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3396 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3397 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3398 | if (ret) |
| 3399 | return ret; |
| 3400 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3401 | /* |
| 3402 | * Turbo will still be enabled, but won't go above the set value. |
| 3403 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3404 | if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 3405 | val = vlv_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3406 | |
| 3407 | hw_max = valleyview_rps_max_freq(dev_priv); |
| 3408 | hw_min = valleyview_rps_min_freq(dev_priv); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3409 | } else { |
| 3410 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3411 | |
| 3412 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 3413 | hw_max = dev_priv->rps.hw_max; |
| 3414 | hw_min = (rp_state_cap >> 16) & 0xff; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3415 | } |
| 3416 | |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3417 | if (val < hw_min || val > hw_max || val < dev_priv->rps.min_delay) { |
| 3418 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 3419 | return -EINVAL; |
| 3420 | } |
| 3421 | |
| 3422 | dev_priv->rps.max_delay = val; |
| 3423 | |
| 3424 | if (IS_VALLEYVIEW(dev)) |
| 3425 | valleyview_set_rps(dev, val); |
| 3426 | else |
| 3427 | gen6_set_rps(dev, val); |
| 3428 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3429 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3430 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3431 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3432 | } |
| 3433 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3434 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 3435 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3436 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3437 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3438 | static int |
| 3439 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3440 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3441 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3442 | drm_i915_private_t *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3443 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3444 | |
| 3445 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3446 | return -ENODEV; |
| 3447 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3448 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3449 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3450 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3451 | if (ret) |
| 3452 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3453 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3454 | if (IS_VALLEYVIEW(dev)) |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 3455 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.min_delay); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3456 | else |
| 3457 | *val = dev_priv->rps.min_delay * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3458 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3459 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3460 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3461 | } |
| 3462 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3463 | static int |
| 3464 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3465 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3466 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3467 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3468 | u32 rp_state_cap, hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3469 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3470 | |
| 3471 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3472 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3473 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3474 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3475 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3476 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3477 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3478 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3479 | if (ret) |
| 3480 | return ret; |
| 3481 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3482 | /* |
| 3483 | * Turbo will still be enabled, but won't go below the set value. |
| 3484 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3485 | if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 3486 | val = vlv_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3487 | |
| 3488 | hw_max = valleyview_rps_max_freq(dev_priv); |
| 3489 | hw_min = valleyview_rps_min_freq(dev_priv); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3490 | } else { |
| 3491 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3492 | |
| 3493 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 3494 | hw_max = dev_priv->rps.hw_max; |
| 3495 | hw_min = (rp_state_cap >> 16) & 0xff; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3496 | } |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3497 | |
| 3498 | if (val < hw_min || val > hw_max || val > dev_priv->rps.max_delay) { |
| 3499 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 3500 | return -EINVAL; |
| 3501 | } |
| 3502 | |
| 3503 | dev_priv->rps.min_delay = val; |
| 3504 | |
| 3505 | if (IS_VALLEYVIEW(dev)) |
| 3506 | valleyview_set_rps(dev, val); |
| 3507 | else |
| 3508 | gen6_set_rps(dev, val); |
| 3509 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3510 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3511 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3512 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3513 | } |
| 3514 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3515 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 3516 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3517 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3518 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3519 | static int |
| 3520 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3521 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3522 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3523 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3524 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3525 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3526 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3527 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3528 | return -ENODEV; |
| 3529 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 3530 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3531 | if (ret) |
| 3532 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 3533 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 3534 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3535 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 3536 | |
| 3537 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3538 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 3539 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3540 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3541 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3542 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3543 | } |
| 3544 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3545 | static int |
| 3546 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3547 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3548 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3549 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3550 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3551 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3552 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3553 | return -ENODEV; |
| 3554 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3555 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3556 | return -EINVAL; |
| 3557 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 3558 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3559 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3560 | |
| 3561 | /* Update the cache sharing policy here as well */ |
| 3562 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 3563 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 3564 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 3565 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 3566 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 3567 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3568 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3569 | } |
| 3570 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3571 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 3572 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 3573 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3574 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3575 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 3576 | { |
| 3577 | struct drm_device *dev = inode->i_private; |
| 3578 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3579 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 3580 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3581 | return 0; |
| 3582 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 3583 | intel_runtime_pm_get(dev_priv); |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 3584 | gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3585 | |
| 3586 | return 0; |
| 3587 | } |
| 3588 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 3589 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3590 | { |
| 3591 | struct drm_device *dev = inode->i_private; |
| 3592 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3593 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 3594 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3595 | return 0; |
| 3596 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 3597 | gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 3598 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3599 | |
| 3600 | return 0; |
| 3601 | } |
| 3602 | |
| 3603 | static const struct file_operations i915_forcewake_fops = { |
| 3604 | .owner = THIS_MODULE, |
| 3605 | .open = i915_forcewake_open, |
| 3606 | .release = i915_forcewake_release, |
| 3607 | }; |
| 3608 | |
| 3609 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 3610 | { |
| 3611 | struct drm_device *dev = minor->dev; |
| 3612 | struct dentry *ent; |
| 3613 | |
| 3614 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 3615 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3616 | root, dev, |
| 3617 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3618 | if (!ent) |
| 3619 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3620 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 3621 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3622 | } |
| 3623 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 3624 | static int i915_debugfs_create(struct dentry *root, |
| 3625 | struct drm_minor *minor, |
| 3626 | const char *name, |
| 3627 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3628 | { |
| 3629 | struct drm_device *dev = minor->dev; |
| 3630 | struct dentry *ent; |
| 3631 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 3632 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3633 | S_IRUGO | S_IWUSR, |
| 3634 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 3635 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3636 | if (!ent) |
| 3637 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3638 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 3639 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3640 | } |
| 3641 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 3642 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 3643 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 3644 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 3645 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 3646 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 3647 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 3648 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 3649 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 3650 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3651 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 3652 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 3653 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3654 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 3655 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 3656 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 3657 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 3658 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 3659 | {"i915_rstdby_delays", i915_rstdby_delays, 0}, |
| 3660 | {"i915_cur_delayinfo", i915_cur_delayinfo, 0}, |
| 3661 | {"i915_delayfreq_table", i915_delayfreq_table, 0}, |
| 3662 | {"i915_inttoext_table", i915_inttoext_table, 0}, |
| 3663 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 3664 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 3665 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 3666 | {"i915_gfxec", i915_gfxec, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 3667 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 3668 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 3669 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 3670 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 3671 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 3672 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3673 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 3674 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 3675 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 3676 | {"i915_dpio", i915_dpio_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 3677 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 3678 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 3679 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 3680 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 3681 | {"i915_pc8_status", i915_pc8_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 3682 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3683 | {"i915_display_info", i915_display_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3684 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 3685 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3686 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 3687 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3688 | const char *name; |
| 3689 | const struct file_operations *fops; |
| 3690 | } i915_debugfs_files[] = { |
| 3691 | {"i915_wedged", &i915_wedged_fops}, |
| 3692 | {"i915_max_freq", &i915_max_freq_fops}, |
| 3693 | {"i915_min_freq", &i915_min_freq_fops}, |
| 3694 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 3695 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3696 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 3697 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3698 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 3699 | {"i915_error_state", &i915_error_state_fops}, |
| 3700 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3701 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3702 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 3703 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 3704 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3705 | }; |
| 3706 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3707 | void intel_display_crc_init(struct drm_device *dev) |
| 3708 | { |
| 3709 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 3710 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3711 | |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 3712 | for_each_pipe(pipe) { |
| 3713 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3714 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3715 | pipe_crc->opened = false; |
| 3716 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3717 | init_waitqueue_head(&pipe_crc->wq); |
| 3718 | } |
| 3719 | } |
| 3720 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 3721 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3722 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3723 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3724 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3725 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 3726 | if (ret) |
| 3727 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 3728 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3729 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 3730 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 3731 | if (ret) |
| 3732 | return ret; |
| 3733 | } |
| 3734 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3735 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 3736 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 3737 | i915_debugfs_files[i].name, |
| 3738 | i915_debugfs_files[i].fops); |
| 3739 | if (ret) |
| 3740 | return ret; |
| 3741 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 3742 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 3743 | return drm_debugfs_create_files(i915_debugfs_list, |
| 3744 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3745 | minor->debugfs_root, minor); |
| 3746 | } |
| 3747 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 3748 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3749 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3750 | int i; |
| 3751 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 3752 | drm_debugfs_remove_files(i915_debugfs_list, |
| 3753 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3754 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 3755 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 3756 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3757 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 3758 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3759 | struct drm_info_list *info_list = |
| 3760 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 3761 | |
| 3762 | drm_debugfs_remove_files(info_list, 1, minor); |
| 3763 | } |
| 3764 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 3765 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 3766 | struct drm_info_list *info_list = |
| 3767 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 3768 | |
| 3769 | drm_debugfs_remove_files(info_list, 1, minor); |
| 3770 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 3771 | } |