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 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 82 | struct drm_info_node *node = m->private; |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 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 | { |
Tvrtko Ursulin | aff4376 | 2014-10-24 12:42:33 +0100 | [diff] [blame] | 119 | return i915_gem_obj_to_ggtt(obj) ? "g" : " "; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 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, |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 139 | i915_cache_level_str(to_i915(obj->base.dev), 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); |
Daniel Vetter | d5a81ef | 2014-06-18 14:46:49 +0200 | [diff] [blame] | 173 | if (obj->frontbuffer_bits) |
| 174 | seq_printf(m, " (frontbuffer: 0x%03x)", obj->frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 175 | } |
| 176 | |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 177 | static void describe_ctx(struct seq_file *m, struct intel_context *ctx) |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 178 | { |
Oscar Mateo | ea0c76f | 2014-07-03 16:27:59 +0100 | [diff] [blame] | 179 | seq_putc(m, ctx->legacy_hw_ctx.initialized ? 'I' : 'i'); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 180 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 181 | seq_putc(m, ' '); |
| 182 | } |
| 183 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 184 | 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] | 185 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 186 | struct drm_info_node *node = m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 187 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 188 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 189 | struct drm_device *dev = node->minor->dev; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 190 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 191 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 192 | struct i915_vma *vma; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 193 | size_t total_obj_size, total_gtt_size; |
| 194 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 195 | |
| 196 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 197 | if (ret) |
| 198 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 199 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 200 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 201 | switch (list) { |
| 202 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 203 | seq_puts(m, "Active:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 204 | head = &vm->active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 205 | break; |
| 206 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 207 | seq_puts(m, "Inactive:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 208 | head = &vm->inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 209 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 210 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 211 | mutex_unlock(&dev->struct_mutex); |
| 212 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 213 | } |
| 214 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 215 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 216 | list_for_each_entry(vma, head, mm_list) { |
| 217 | seq_printf(m, " "); |
| 218 | describe_obj(m, vma->obj); |
| 219 | seq_printf(m, "\n"); |
| 220 | total_obj_size += vma->obj->base.size; |
| 221 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 222 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 223 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 224 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 225 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 226 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 227 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 228 | return 0; |
| 229 | } |
| 230 | |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 231 | static int obj_rank_by_stolen(void *priv, |
| 232 | struct list_head *A, struct list_head *B) |
| 233 | { |
| 234 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 235 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 236 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 237 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 238 | |
| 239 | return a->stolen->start - b->stolen->start; |
| 240 | } |
| 241 | |
| 242 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 243 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 244 | struct drm_info_node *node = m->private; |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 245 | struct drm_device *dev = node->minor->dev; |
| 246 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 247 | struct drm_i915_gem_object *obj; |
| 248 | size_t total_obj_size, total_gtt_size; |
| 249 | LIST_HEAD(stolen); |
| 250 | int count, ret; |
| 251 | |
| 252 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 253 | if (ret) |
| 254 | return ret; |
| 255 | |
| 256 | total_obj_size = total_gtt_size = count = 0; |
| 257 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 258 | if (obj->stolen == NULL) |
| 259 | continue; |
| 260 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 261 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 262 | |
| 263 | total_obj_size += obj->base.size; |
| 264 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
| 265 | count++; |
| 266 | } |
| 267 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 268 | if (obj->stolen == NULL) |
| 269 | continue; |
| 270 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 271 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 272 | |
| 273 | total_obj_size += obj->base.size; |
| 274 | count++; |
| 275 | } |
| 276 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 277 | seq_puts(m, "Stolen:\n"); |
| 278 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 279 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | seq_puts(m, " "); |
| 281 | describe_obj(m, obj); |
| 282 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 283 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 284 | } |
| 285 | mutex_unlock(&dev->struct_mutex); |
| 286 | |
| 287 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 288 | count, total_obj_size, total_gtt_size); |
| 289 | return 0; |
| 290 | } |
| 291 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 292 | #define count_objects(list, member) do { \ |
| 293 | list_for_each_entry(obj, list, member) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 294 | size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 295 | ++count; \ |
| 296 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 297 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 298 | ++mappable_count; \ |
| 299 | } \ |
| 300 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 301 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 302 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 303 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 304 | struct drm_i915_file_private *file_priv; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 305 | int count; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 306 | size_t total, unbound; |
| 307 | size_t global, shared; |
| 308 | size_t active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 309 | }; |
| 310 | |
| 311 | static int per_file_stats(int id, void *ptr, void *data) |
| 312 | { |
| 313 | struct drm_i915_gem_object *obj = ptr; |
| 314 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 315 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 316 | |
| 317 | stats->count++; |
| 318 | stats->total += obj->base.size; |
| 319 | |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 320 | if (obj->base.name || obj->base.dma_buf) |
| 321 | stats->shared += obj->base.size; |
| 322 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 323 | if (USES_FULL_PPGTT(obj->base.dev)) { |
| 324 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 325 | struct i915_hw_ppgtt *ppgtt; |
| 326 | |
| 327 | if (!drm_mm_node_allocated(&vma->node)) |
| 328 | continue; |
| 329 | |
| 330 | if (i915_is_ggtt(vma->vm)) { |
| 331 | stats->global += obj->base.size; |
| 332 | continue; |
| 333 | } |
| 334 | |
| 335 | ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base); |
Daniel Vetter | 4d88470 | 2014-08-06 15:04:47 +0200 | [diff] [blame] | 336 | if (ppgtt->file_priv != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 337 | continue; |
| 338 | |
| 339 | if (obj->ring) /* XXX per-vma statistic */ |
| 340 | stats->active += obj->base.size; |
| 341 | else |
| 342 | stats->inactive += obj->base.size; |
| 343 | |
| 344 | return 0; |
| 345 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 346 | } else { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 347 | if (i915_gem_obj_ggtt_bound(obj)) { |
| 348 | stats->global += obj->base.size; |
| 349 | if (obj->ring) |
| 350 | stats->active += obj->base.size; |
| 351 | else |
| 352 | stats->inactive += obj->base.size; |
| 353 | return 0; |
| 354 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 355 | } |
| 356 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 357 | if (!list_empty(&obj->global_list)) |
| 358 | stats->unbound += obj->base.size; |
| 359 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 360 | return 0; |
| 361 | } |
| 362 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 363 | #define count_vmas(list, member) do { \ |
| 364 | list_for_each_entry(vma, list, member) { \ |
| 365 | size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 366 | ++count; \ |
| 367 | if (vma->obj->map_and_fenceable) { \ |
| 368 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 369 | ++mappable_count; \ |
| 370 | } \ |
| 371 | } \ |
| 372 | } while (0) |
| 373 | |
| 374 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 375 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 376 | struct drm_info_node *node = m->private; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 377 | struct drm_device *dev = node->minor->dev; |
| 378 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 379 | u32 count, mappable_count, purgeable_count; |
| 380 | size_t size, mappable_size, purgeable_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 381 | struct drm_i915_gem_object *obj; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 382 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 383 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 384 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 385 | int ret; |
| 386 | |
| 387 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 388 | if (ret) |
| 389 | return ret; |
| 390 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 391 | seq_printf(m, "%u objects, %zu bytes\n", |
| 392 | dev_priv->mm.object_count, |
| 393 | dev_priv->mm.object_memory); |
| 394 | |
| 395 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 396 | count_objects(&dev_priv->mm.bound_list, global_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 397 | seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", |
| 398 | count, mappable_count, size, mappable_size); |
| 399 | |
| 400 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 401 | count_vmas(&vm->active_list, mm_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 402 | seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n", |
| 403 | count, mappable_count, size, mappable_size); |
| 404 | |
| 405 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 406 | count_vmas(&vm->inactive_list, mm_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 407 | seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n", |
| 408 | count, mappable_count, size, mappable_size); |
| 409 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 410 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 411 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 412 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 413 | if (obj->madv == I915_MADV_DONTNEED) |
| 414 | purgeable_size += obj->base.size, ++purgeable_count; |
| 415 | } |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 416 | seq_printf(m, "%u unbound objects, %zu bytes\n", count, size); |
| 417 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 418 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 419 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 420 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 421 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 422 | ++count; |
| 423 | } |
| 424 | if (obj->pin_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 425 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 426 | ++mappable_count; |
| 427 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 428 | if (obj->madv == I915_MADV_DONTNEED) { |
| 429 | purgeable_size += obj->base.size; |
| 430 | ++purgeable_count; |
| 431 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 432 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 433 | seq_printf(m, "%u purgeable objects, %zu bytes\n", |
| 434 | purgeable_count, purgeable_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 435 | seq_printf(m, "%u pinned mappable objects, %zu bytes\n", |
| 436 | mappable_count, mappable_size); |
| 437 | seq_printf(m, "%u fault mappable objects, %zu bytes\n", |
| 438 | count, size); |
| 439 | |
Ben Widawsky | 93d1879 | 2013-01-17 12:45:17 -0800 | [diff] [blame] | 440 | seq_printf(m, "%zu [%lu] gtt total\n", |
Ben Widawsky | 853ba5d | 2013-07-16 16:50:05 -0700 | [diff] [blame] | 441 | dev_priv->gtt.base.total, |
| 442 | dev_priv->gtt.mappable_end - dev_priv->gtt.base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 443 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 444 | seq_putc(m, '\n'); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 445 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 446 | struct file_stats stats; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 447 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 448 | |
| 449 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 450 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 451 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 452 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 453 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 454 | /* |
| 455 | * Although we have a valid reference on file->pid, that does |
| 456 | * not guarantee that the task_struct who called get_pid() is |
| 457 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 458 | * Therefore, we need to protect this ->comm access using RCU. |
| 459 | */ |
| 460 | rcu_read_lock(); |
| 461 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 462 | seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 463 | task ? task->comm : "<unknown>", |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 464 | stats.count, |
| 465 | stats.total, |
| 466 | stats.active, |
| 467 | stats.inactive, |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 468 | stats.global, |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 469 | stats.shared, |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 470 | stats.unbound); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 471 | rcu_read_unlock(); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 472 | } |
| 473 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 474 | mutex_unlock(&dev->struct_mutex); |
| 475 | |
| 476 | return 0; |
| 477 | } |
| 478 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 479 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 480 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 481 | struct drm_info_node *node = m->private; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 482 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 483 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 484 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 485 | struct drm_i915_gem_object *obj; |
| 486 | size_t total_obj_size, total_gtt_size; |
| 487 | int count, ret; |
| 488 | |
| 489 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 490 | if (ret) |
| 491 | return ret; |
| 492 | |
| 493 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 494 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 495 | if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj)) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 496 | continue; |
| 497 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 498 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 499 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 500 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 501 | total_obj_size += obj->base.size; |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 502 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 503 | count++; |
| 504 | } |
| 505 | |
| 506 | mutex_unlock(&dev->struct_mutex); |
| 507 | |
| 508 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 509 | count, total_obj_size, total_gtt_size); |
| 510 | |
| 511 | return 0; |
| 512 | } |
| 513 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 514 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 515 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 516 | struct drm_info_node *node = m->private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 517 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 518 | struct drm_i915_private *dev_priv = dev->dev_private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 519 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 520 | int ret; |
| 521 | |
| 522 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 523 | if (ret) |
| 524 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 525 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 526 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 527 | const char pipe = pipe_name(crtc->pipe); |
| 528 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 529 | struct intel_unpin_work *work; |
| 530 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 531 | spin_lock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 532 | work = crtc->unpin_work; |
| 533 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 534 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 535 | pipe, plane); |
| 536 | } else { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 537 | u32 addr; |
| 538 | |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 539 | if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 540 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 541 | pipe, plane); |
| 542 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 543 | 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] | 544 | pipe, plane); |
| 545 | } |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 546 | if (work->flip_queued_ring) { |
| 547 | seq_printf(m, "Flip queued on %s at seqno %u, next seqno %u [current breadcrumb %u], completed? %d\n", |
| 548 | work->flip_queued_ring->name, |
| 549 | work->flip_queued_seqno, |
| 550 | dev_priv->next_seqno, |
| 551 | work->flip_queued_ring->get_seqno(work->flip_queued_ring, true), |
| 552 | i915_seqno_passed(work->flip_queued_ring->get_seqno(work->flip_queued_ring, true), |
| 553 | work->flip_queued_seqno)); |
| 554 | } else |
| 555 | seq_printf(m, "Flip not associated with any ring\n"); |
| 556 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 557 | work->flip_queued_vblank, |
| 558 | work->flip_ready_vblank, |
| 559 | drm_vblank_count(dev, crtc->pipe)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 560 | if (work->enable_stall_check) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 561 | seq_puts(m, "Stall check enabled, "); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 562 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 563 | seq_puts(m, "Stall check waiting for page flip ioctl, "); |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 564 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 565 | |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 566 | if (INTEL_INFO(dev)->gen >= 4) |
| 567 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 568 | else |
| 569 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 570 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 571 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 572 | if (work->pending_flip_obj) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 573 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 574 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 575 | } |
| 576 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 577 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 578 | } |
| 579 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 580 | mutex_unlock(&dev->struct_mutex); |
| 581 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 582 | return 0; |
| 583 | } |
| 584 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 585 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 586 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 587 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 588 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 589 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 590 | struct intel_engine_cs *ring; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 591 | struct drm_i915_gem_request *gem_request; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 592 | int ret, count, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 593 | |
| 594 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 595 | if (ret) |
| 596 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 597 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 598 | count = 0; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 599 | for_each_ring(ring, dev_priv, i) { |
| 600 | if (list_empty(&ring->request_list)) |
| 601 | continue; |
| 602 | |
| 603 | seq_printf(m, "%s requests:\n", ring->name); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 604 | list_for_each_entry(gem_request, |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 605 | &ring->request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 606 | list) { |
| 607 | seq_printf(m, " %d @ %d\n", |
| 608 | gem_request->seqno, |
| 609 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 610 | } |
| 611 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 612 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 613 | mutex_unlock(&dev->struct_mutex); |
| 614 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 615 | if (count == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 616 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 617 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 618 | return 0; |
| 619 | } |
| 620 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 621 | static void i915_ring_seqno_info(struct seq_file *m, |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 622 | struct intel_engine_cs *ring) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 623 | { |
| 624 | if (ring->get_seqno) { |
Mika Kuoppala | 43a7b92 | 2012-12-04 15:12:01 +0200 | [diff] [blame] | 625 | seq_printf(m, "Current sequence (%s): %u\n", |
Chris Wilson | b2eadbc | 2012-08-09 10:58:30 +0100 | [diff] [blame] | 626 | ring->name, ring->get_seqno(ring, false)); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 630 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 631 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 632 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 633 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 634 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 635 | struct intel_engine_cs *ring; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 636 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 637 | |
| 638 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 639 | if (ret) |
| 640 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 641 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 642 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 643 | for_each_ring(ring, dev_priv, i) |
| 644 | i915_ring_seqno_info(m, ring); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 645 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 646 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 647 | mutex_unlock(&dev->struct_mutex); |
| 648 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | |
| 653 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 654 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 655 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 656 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 657 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 658 | struct intel_engine_cs *ring; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 659 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 660 | |
| 661 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 662 | if (ret) |
| 663 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 664 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 665 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 666 | if (IS_CHERRYVIEW(dev)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 667 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 668 | I915_READ(GEN8_MASTER_IRQ)); |
| 669 | |
| 670 | seq_printf(m, "Display IER:\t%08x\n", |
| 671 | I915_READ(VLV_IER)); |
| 672 | seq_printf(m, "Display IIR:\t%08x\n", |
| 673 | I915_READ(VLV_IIR)); |
| 674 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 675 | I915_READ(VLV_IIR_RW)); |
| 676 | seq_printf(m, "Display IMR:\t%08x\n", |
| 677 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 678 | for_each_pipe(dev_priv, pipe) |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 679 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 680 | pipe_name(pipe), |
| 681 | I915_READ(PIPESTAT(pipe))); |
| 682 | |
| 683 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 684 | I915_READ(PORT_HOTPLUG_EN)); |
| 685 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 686 | I915_READ(VLV_DPFLIPSTAT)); |
| 687 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 688 | I915_READ(DPINVGTT)); |
| 689 | |
| 690 | for (i = 0; i < 4; i++) { |
| 691 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 692 | i, I915_READ(GEN8_GT_IMR(i))); |
| 693 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 694 | i, I915_READ(GEN8_GT_IIR(i))); |
| 695 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 696 | i, I915_READ(GEN8_GT_IER(i))); |
| 697 | } |
| 698 | |
| 699 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 700 | I915_READ(GEN8_PCU_IMR)); |
| 701 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 702 | I915_READ(GEN8_PCU_IIR)); |
| 703 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 704 | I915_READ(GEN8_PCU_IER)); |
| 705 | } else if (INTEL_INFO(dev)->gen >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 706 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 707 | I915_READ(GEN8_MASTER_IRQ)); |
| 708 | |
| 709 | for (i = 0; i < 4; i++) { |
| 710 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 711 | i, I915_READ(GEN8_GT_IMR(i))); |
| 712 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 713 | i, I915_READ(GEN8_GT_IIR(i))); |
| 714 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 715 | i, I915_READ(GEN8_GT_IER(i))); |
| 716 | } |
| 717 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 718 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 719 | if (!intel_display_power_is_enabled(dev_priv, |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 720 | POWER_DOMAIN_PIPE(pipe))) { |
| 721 | seq_printf(m, "Pipe %c power disabled\n", |
| 722 | pipe_name(pipe)); |
| 723 | continue; |
| 724 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 725 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 726 | pipe_name(pipe), |
| 727 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 728 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 729 | pipe_name(pipe), |
| 730 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 731 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 732 | pipe_name(pipe), |
| 733 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 737 | I915_READ(GEN8_DE_PORT_IMR)); |
| 738 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 739 | I915_READ(GEN8_DE_PORT_IIR)); |
| 740 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 741 | I915_READ(GEN8_DE_PORT_IER)); |
| 742 | |
| 743 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 744 | I915_READ(GEN8_DE_MISC_IMR)); |
| 745 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 746 | I915_READ(GEN8_DE_MISC_IIR)); |
| 747 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 748 | I915_READ(GEN8_DE_MISC_IER)); |
| 749 | |
| 750 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 751 | I915_READ(GEN8_PCU_IMR)); |
| 752 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 753 | I915_READ(GEN8_PCU_IIR)); |
| 754 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 755 | I915_READ(GEN8_PCU_IER)); |
| 756 | } else if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 757 | seq_printf(m, "Display IER:\t%08x\n", |
| 758 | I915_READ(VLV_IER)); |
| 759 | seq_printf(m, "Display IIR:\t%08x\n", |
| 760 | I915_READ(VLV_IIR)); |
| 761 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 762 | I915_READ(VLV_IIR_RW)); |
| 763 | seq_printf(m, "Display IMR:\t%08x\n", |
| 764 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 765 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 766 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 767 | pipe_name(pipe), |
| 768 | I915_READ(PIPESTAT(pipe))); |
| 769 | |
| 770 | seq_printf(m, "Master IER:\t%08x\n", |
| 771 | I915_READ(VLV_MASTER_IER)); |
| 772 | |
| 773 | seq_printf(m, "Render IER:\t%08x\n", |
| 774 | I915_READ(GTIER)); |
| 775 | seq_printf(m, "Render IIR:\t%08x\n", |
| 776 | I915_READ(GTIIR)); |
| 777 | seq_printf(m, "Render IMR:\t%08x\n", |
| 778 | I915_READ(GTIMR)); |
| 779 | |
| 780 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 781 | I915_READ(GEN6_PMIER)); |
| 782 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 783 | I915_READ(GEN6_PMIIR)); |
| 784 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 785 | I915_READ(GEN6_PMIMR)); |
| 786 | |
| 787 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 788 | I915_READ(PORT_HOTPLUG_EN)); |
| 789 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 790 | I915_READ(VLV_DPFLIPSTAT)); |
| 791 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 792 | I915_READ(DPINVGTT)); |
| 793 | |
| 794 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 795 | seq_printf(m, "Interrupt enable: %08x\n", |
| 796 | I915_READ(IER)); |
| 797 | seq_printf(m, "Interrupt identity: %08x\n", |
| 798 | I915_READ(IIR)); |
| 799 | seq_printf(m, "Interrupt mask: %08x\n", |
| 800 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 801 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 802 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 803 | pipe_name(pipe), |
| 804 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 805 | } else { |
| 806 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 807 | I915_READ(DEIER)); |
| 808 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 809 | I915_READ(DEIIR)); |
| 810 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 811 | I915_READ(DEIMR)); |
| 812 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 813 | I915_READ(SDEIER)); |
| 814 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 815 | I915_READ(SDEIIR)); |
| 816 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 817 | I915_READ(SDEIMR)); |
| 818 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 819 | I915_READ(GTIER)); |
| 820 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 821 | I915_READ(GTIIR)); |
| 822 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 823 | I915_READ(GTIMR)); |
| 824 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 825 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 826 | if (INTEL_INFO(dev)->gen >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 827 | seq_printf(m, |
| 828 | "Graphics Interrupt mask (%s): %08x\n", |
| 829 | ring->name, I915_READ_IMR(ring)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 830 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 831 | i915_ring_seqno_info(m, ring); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 832 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 833 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 834 | mutex_unlock(&dev->struct_mutex); |
| 835 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 836 | return 0; |
| 837 | } |
| 838 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 839 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 840 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 841 | struct drm_info_node *node = m->private; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 842 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 843 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 844 | int i, ret; |
| 845 | |
| 846 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 847 | if (ret) |
| 848 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 849 | |
| 850 | seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start); |
| 851 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 852 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 853 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 854 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 855 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 856 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 857 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 858 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 859 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 860 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 861 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 862 | } |
| 863 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 864 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 865 | return 0; |
| 866 | } |
| 867 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 868 | static int i915_hws_info(struct seq_file *m, void *data) |
| 869 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 870 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 871 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 872 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 873 | struct intel_engine_cs *ring; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 874 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 875 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 876 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 877 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 878 | hws = ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 879 | if (hws == NULL) |
| 880 | return 0; |
| 881 | |
| 882 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 883 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 884 | i * 4, |
| 885 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 886 | } |
| 887 | return 0; |
| 888 | } |
| 889 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 890 | static ssize_t |
| 891 | i915_error_state_write(struct file *filp, |
| 892 | const char __user *ubuf, |
| 893 | size_t cnt, |
| 894 | loff_t *ppos) |
| 895 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 896 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 897 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 898 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 899 | |
| 900 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 901 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 902 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 903 | if (ret) |
| 904 | return ret; |
| 905 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 906 | i915_destroy_error_state(dev); |
| 907 | mutex_unlock(&dev->struct_mutex); |
| 908 | |
| 909 | return cnt; |
| 910 | } |
| 911 | |
| 912 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 913 | { |
| 914 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 915 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 916 | |
| 917 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 918 | if (!error_priv) |
| 919 | return -ENOMEM; |
| 920 | |
| 921 | error_priv->dev = dev; |
| 922 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 923 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 924 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 925 | file->private_data = error_priv; |
| 926 | |
| 927 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 931 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 932 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 933 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 934 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 935 | kfree(error_priv); |
| 936 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 941 | size_t count, loff_t *pos) |
| 942 | { |
| 943 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 944 | struct drm_i915_error_state_buf error_str; |
| 945 | loff_t tmp_pos = 0; |
| 946 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 947 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 948 | |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 949 | ret = i915_error_state_buf_init(&error_str, to_i915(error_priv->dev), count, *pos); |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 950 | if (ret) |
| 951 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 952 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 953 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 954 | if (ret) |
| 955 | goto out; |
| 956 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 957 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 958 | error_str.buf, |
| 959 | error_str.bytes); |
| 960 | |
| 961 | if (ret_count < 0) |
| 962 | ret = ret_count; |
| 963 | else |
| 964 | *pos = error_str.start + ret_count; |
| 965 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 966 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 967 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | static const struct file_operations i915_error_state_fops = { |
| 971 | .owner = THIS_MODULE, |
| 972 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 973 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 974 | .write = i915_error_state_write, |
| 975 | .llseek = default_llseek, |
| 976 | .release = i915_error_state_release, |
| 977 | }; |
| 978 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 979 | static int |
| 980 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 981 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 982 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 983 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 984 | int ret; |
| 985 | |
| 986 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 987 | if (ret) |
| 988 | return ret; |
| 989 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 990 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 991 | mutex_unlock(&dev->struct_mutex); |
| 992 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 993 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 994 | } |
| 995 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 996 | static int |
| 997 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 998 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 999 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1000 | int ret; |
| 1001 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1002 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1003 | if (ret) |
| 1004 | return ret; |
| 1005 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 1006 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1007 | mutex_unlock(&dev->struct_mutex); |
| 1008 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1009 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1010 | } |
| 1011 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1012 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1013 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1014 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1015 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1016 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1017 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1018 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1019 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1020 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1021 | int ret = 0; |
| 1022 | |
| 1023 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1024 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1025 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1026 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1027 | if (IS_GEN5(dev)) { |
| 1028 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1029 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1030 | |
| 1031 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1032 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1033 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1034 | MEMSTAT_VID_SHIFT); |
| 1035 | seq_printf(m, "Current P-state: %d\n", |
| 1036 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1037 | } else if (IS_GEN6(dev) || (IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) || |
| 1038 | IS_BROADWELL(dev)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1039 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1040 | u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 1041 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1042 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1043 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1044 | u32 rpupei, rpcurup, rpprevup; |
| 1045 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1046 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1047 | int max_freq; |
| 1048 | |
| 1049 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1050 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1051 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1052 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1053 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 1054 | gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1055 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1056 | reqf = I915_READ(GEN6_RPNSWREQ); |
| 1057 | reqf &= ~GEN6_TURBO_DISABLE; |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1058 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1059 | reqf >>= 24; |
| 1060 | else |
| 1061 | reqf >>= 25; |
| 1062 | reqf *= GT_FREQUENCY_MULTIPLIER; |
| 1063 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1064 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1065 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1066 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1067 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1068 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 1069 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 1070 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 1071 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 1072 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 1073 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 1074 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1075 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1076 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1077 | else |
| 1078 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
| 1079 | cagf *= GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1080 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 1081 | gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1082 | mutex_unlock(&dev->struct_mutex); |
| 1083 | |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1084 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1085 | pm_ier = I915_READ(GEN6_PMIER); |
| 1086 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1087 | pm_isr = I915_READ(GEN6_PMISR); |
| 1088 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1089 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1090 | } else { |
| 1091 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1092 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1093 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1094 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1095 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1096 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1097 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n", |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1098 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1099 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1100 | seq_printf(m, "Render p-state ratio: %d\n", |
| 1101 | (gt_perf_status & 0xff00) >> 8); |
| 1102 | seq_printf(m, "Render p-state VID: %d\n", |
| 1103 | gt_perf_status & 0xff); |
| 1104 | seq_printf(m, "Render p-state limit: %d\n", |
| 1105 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1106 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1107 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1108 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1109 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1110 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1111 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1112 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 1113 | GEN6_CURICONT_MASK); |
| 1114 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 1115 | GEN6_CURBSYTAVG_MASK); |
| 1116 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 1117 | GEN6_CURBSYTAVG_MASK); |
| 1118 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 1119 | GEN6_CURIAVG_MASK); |
| 1120 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 1121 | GEN6_CURBSYTAVG_MASK); |
| 1122 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 1123 | GEN6_CURBSYTAVG_MASK); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1124 | |
| 1125 | max_freq = (rp_state_cap & 0xff0000) >> 16; |
| 1126 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 1127 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1128 | |
| 1129 | max_freq = (rp_state_cap & 0xff00) >> 8; |
| 1130 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 1131 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1132 | |
| 1133 | max_freq = rp_state_cap & 0xff; |
| 1134 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 1135 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1136 | |
| 1137 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1138 | dev_priv->rps.max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1139 | } else if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1140 | u32 freq_sts; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1141 | |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1142 | mutex_lock(&dev_priv->rps.hw_lock); |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 1143 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1144 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1145 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1146 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1147 | seq_printf(m, "max GPU freq: %d MHz\n", |
Deepak S | b2435c9 | 2014-07-17 14:21:14 +0530 | [diff] [blame] | 1148 | vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1149 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1150 | seq_printf(m, "min GPU freq: %d MHz\n", |
Deepak S | b2435c9 | 2014-07-17 14:21:14 +0530 | [diff] [blame] | 1151 | vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1152 | |
| 1153 | seq_printf(m, "efficient (RPe) frequency: %d MHz\n", |
Deepak S | b2435c9 | 2014-07-17 14:21:14 +0530 | [diff] [blame] | 1154 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1155 | |
| 1156 | seq_printf(m, "current GPU freq: %d MHz\n", |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 1157 | vlv_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1158 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1159 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1160 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1161 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1162 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1163 | out: |
| 1164 | intel_runtime_pm_put(dev_priv); |
| 1165 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1166 | } |
| 1167 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1168 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1169 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1170 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1171 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1172 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1173 | u32 rgvmodectl, rstdbyctl; |
| 1174 | u16 crstandvid; |
| 1175 | int ret; |
| 1176 | |
| 1177 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1178 | if (ret) |
| 1179 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1180 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1181 | |
| 1182 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1183 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1184 | crstandvid = I915_READ16(CRSTANDVID); |
| 1185 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1186 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1187 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1188 | |
| 1189 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1190 | "yes" : "no"); |
| 1191 | seq_printf(m, "Boost freq: %d\n", |
| 1192 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1193 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1194 | seq_printf(m, "HW control enabled: %s\n", |
| 1195 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1196 | seq_printf(m, "SW control enabled: %s\n", |
| 1197 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1198 | seq_printf(m, "Gated voltage change: %s\n", |
| 1199 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1200 | seq_printf(m, "Starting frequency: P%d\n", |
| 1201 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1202 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1203 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1204 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1205 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1206 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1207 | seq_printf(m, "Render standby enabled: %s\n", |
| 1208 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1209 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1210 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1211 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1212 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1213 | break; |
| 1214 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1215 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1216 | break; |
| 1217 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1218 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1219 | break; |
| 1220 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1221 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1222 | break; |
| 1223 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1224 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1225 | break; |
| 1226 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1227 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1228 | break; |
| 1229 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1230 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1231 | break; |
| 1232 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1233 | |
| 1234 | return 0; |
| 1235 | } |
| 1236 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1237 | static int vlv_drpc_info(struct seq_file *m) |
| 1238 | { |
| 1239 | |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1240 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1241 | struct drm_device *dev = node->minor->dev; |
| 1242 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame^] | 1243 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1244 | unsigned fw_rendercount = 0, fw_mediacount = 0; |
| 1245 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1246 | intel_runtime_pm_get(dev_priv); |
| 1247 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame^] | 1248 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1249 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1250 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1251 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1252 | intel_runtime_pm_put(dev_priv); |
| 1253 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1254 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1255 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1256 | seq_printf(m, "Turbo enabled: %s\n", |
| 1257 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1258 | seq_printf(m, "HW control enabled: %s\n", |
| 1259 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1260 | seq_printf(m, "SW control enabled: %s\n", |
| 1261 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1262 | GEN6_RP_MEDIA_SW_MODE)); |
| 1263 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1264 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1265 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1266 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame^] | 1267 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1268 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame^] | 1269 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1270 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1271 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1272 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1273 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1274 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1275 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1276 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1277 | fw_rendercount = dev_priv->uncore.fw_rendercount; |
| 1278 | fw_mediacount = dev_priv->uncore.fw_mediacount; |
| 1279 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1280 | |
| 1281 | seq_printf(m, "Forcewake Render Count = %u\n", fw_rendercount); |
| 1282 | seq_printf(m, "Forcewake Media Count = %u\n", fw_mediacount); |
| 1283 | |
| 1284 | |
| 1285 | return 0; |
| 1286 | } |
| 1287 | |
| 1288 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1289 | static int gen6_drpc_info(struct seq_file *m) |
| 1290 | { |
| 1291 | |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1292 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1293 | struct drm_device *dev = node->minor->dev; |
| 1294 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1295 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1296 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1297 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1298 | |
| 1299 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1300 | if (ret) |
| 1301 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1302 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1303 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1304 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1305 | forcewake_count = dev_priv->uncore.forcewake_count; |
| 1306 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1307 | |
| 1308 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1309 | seq_puts(m, "RC information inaccurate because somebody " |
| 1310 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1311 | } else { |
| 1312 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1313 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1314 | udelay(10); |
| 1315 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1316 | } |
| 1317 | |
| 1318 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1319 | 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] | 1320 | |
| 1321 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1322 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1323 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1324 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1325 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1326 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1327 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1328 | intel_runtime_pm_put(dev_priv); |
| 1329 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1330 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1331 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1332 | seq_printf(m, "HW control enabled: %s\n", |
| 1333 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1334 | seq_printf(m, "SW control enabled: %s\n", |
| 1335 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1336 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1337 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1338 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1339 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1340 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1341 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1342 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1343 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1344 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1345 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1346 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1347 | case GEN6_RC0: |
| 1348 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1349 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1350 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1351 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1352 | break; |
| 1353 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1354 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1355 | break; |
| 1356 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1357 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1358 | break; |
| 1359 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1360 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1361 | break; |
| 1362 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1363 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1364 | break; |
| 1365 | } |
| 1366 | |
| 1367 | seq_printf(m, "Core Power Down: %s\n", |
| 1368 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1369 | |
| 1370 | /* Not exactly sure what this is */ |
| 1371 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1372 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1373 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1374 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1375 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1376 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1377 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1378 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1379 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1380 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1381 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1382 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1383 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1384 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1385 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1386 | return 0; |
| 1387 | } |
| 1388 | |
| 1389 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1390 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1391 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1392 | struct drm_device *dev = node->minor->dev; |
| 1393 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1394 | if (IS_VALLEYVIEW(dev)) |
| 1395 | return vlv_drpc_info(m); |
Vedang Patel | ac66cf4 | 2014-08-26 10:42:51 -0700 | [diff] [blame] | 1396 | else if (INTEL_INFO(dev)->gen >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1397 | return gen6_drpc_info(m); |
| 1398 | else |
| 1399 | return ironlake_drpc_info(m); |
| 1400 | } |
| 1401 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1402 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1403 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1404 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1405 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1406 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1407 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1408 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1409 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1410 | return 0; |
| 1411 | } |
| 1412 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1413 | intel_runtime_pm_get(dev_priv); |
| 1414 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1415 | if (intel_fbc_enabled(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1416 | seq_puts(m, "FBC enabled\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1417 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1418 | seq_puts(m, "FBC disabled: "); |
Ben Widawsky | 5c3fe8b | 2013-06-27 16:30:21 -0700 | [diff] [blame] | 1419 | switch (dev_priv->fbc.no_fbc_reason) { |
Chris Wilson | 29ebf90 | 2013-07-27 17:23:55 +0100 | [diff] [blame] | 1420 | case FBC_OK: |
| 1421 | seq_puts(m, "FBC actived, but currently disabled in hardware"); |
| 1422 | break; |
| 1423 | case FBC_UNSUPPORTED: |
| 1424 | seq_puts(m, "unsupported by this chipset"); |
| 1425 | break; |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1426 | case FBC_NO_OUTPUT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1427 | seq_puts(m, "no outputs"); |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1428 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1429 | case FBC_STOLEN_TOO_SMALL: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1430 | seq_puts(m, "not enough stolen memory"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1431 | break; |
| 1432 | case FBC_UNSUPPORTED_MODE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1433 | seq_puts(m, "mode not supported"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1434 | break; |
| 1435 | case FBC_MODE_TOO_LARGE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1436 | seq_puts(m, "mode too large"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1437 | break; |
| 1438 | case FBC_BAD_PLANE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1439 | seq_puts(m, "FBC unsupported on plane"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1440 | break; |
| 1441 | case FBC_NOT_TILED: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1442 | seq_puts(m, "scanout buffer not tiled"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1443 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1444 | case FBC_MULTIPLE_PIPES: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1445 | seq_puts(m, "multiple pipes are enabled"); |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1446 | break; |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1447 | case FBC_MODULE_PARAM: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1448 | seq_puts(m, "disabled per module param (default off)"); |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1449 | break; |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1450 | case FBC_CHIP_DEFAULT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1451 | seq_puts(m, "disabled per chip default"); |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1452 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1453 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1454 | seq_puts(m, "unknown reason"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1455 | } |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1456 | seq_putc(m, '\n'); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1457 | } |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1458 | |
| 1459 | intel_runtime_pm_put(dev_priv); |
| 1460 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1461 | return 0; |
| 1462 | } |
| 1463 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1464 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1465 | { |
| 1466 | struct drm_device *dev = data; |
| 1467 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1468 | |
| 1469 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1470 | return -ENODEV; |
| 1471 | |
| 1472 | drm_modeset_lock_all(dev); |
| 1473 | *val = dev_priv->fbc.false_color; |
| 1474 | drm_modeset_unlock_all(dev); |
| 1475 | |
| 1476 | return 0; |
| 1477 | } |
| 1478 | |
| 1479 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1480 | { |
| 1481 | struct drm_device *dev = data; |
| 1482 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1483 | u32 reg; |
| 1484 | |
| 1485 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1486 | return -ENODEV; |
| 1487 | |
| 1488 | drm_modeset_lock_all(dev); |
| 1489 | |
| 1490 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1491 | dev_priv->fbc.false_color = val; |
| 1492 | |
| 1493 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1494 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1495 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1496 | |
| 1497 | drm_modeset_unlock_all(dev); |
| 1498 | return 0; |
| 1499 | } |
| 1500 | |
| 1501 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1502 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1503 | "%llu\n"); |
| 1504 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1505 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1506 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1507 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1508 | struct drm_device *dev = node->minor->dev; |
| 1509 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1510 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1511 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1512 | seq_puts(m, "not supported\n"); |
| 1513 | return 0; |
| 1514 | } |
| 1515 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1516 | intel_runtime_pm_get(dev_priv); |
| 1517 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1518 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1519 | yesno(i915.enable_ips)); |
| 1520 | |
| 1521 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1522 | seq_puts(m, "Currently: unknown\n"); |
| 1523 | } else { |
| 1524 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1525 | seq_puts(m, "Currently: enabled\n"); |
| 1526 | else |
| 1527 | seq_puts(m, "Currently: disabled\n"); |
| 1528 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1529 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1530 | intel_runtime_pm_put(dev_priv); |
| 1531 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1532 | return 0; |
| 1533 | } |
| 1534 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1535 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1536 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1537 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1538 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1539 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1540 | bool sr_enabled = false; |
| 1541 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1542 | intel_runtime_pm_get(dev_priv); |
| 1543 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1544 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1545 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1546 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1547 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1548 | else if (IS_I915GM(dev)) |
| 1549 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1550 | else if (IS_PINEVIEW(dev)) |
| 1551 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1552 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1553 | intel_runtime_pm_put(dev_priv); |
| 1554 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1555 | seq_printf(m, "self-refresh: %s\n", |
| 1556 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1557 | |
| 1558 | return 0; |
| 1559 | } |
| 1560 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1561 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1562 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1563 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1564 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1565 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1566 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1567 | int ret; |
| 1568 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1569 | if (!IS_GEN5(dev)) |
| 1570 | return -ENODEV; |
| 1571 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1572 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1573 | if (ret) |
| 1574 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1575 | |
| 1576 | temp = i915_mch_val(dev_priv); |
| 1577 | chipset = i915_chipset_val(dev_priv); |
| 1578 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1579 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1580 | |
| 1581 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1582 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1583 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1584 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1585 | |
| 1586 | return 0; |
| 1587 | } |
| 1588 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1589 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1590 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1591 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1592 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1593 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1594 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1595 | int gpu_freq, ia_freq; |
| 1596 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1597 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1598 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1599 | return 0; |
| 1600 | } |
| 1601 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1602 | intel_runtime_pm_get(dev_priv); |
| 1603 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1604 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1605 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1606 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1607 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1608 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1609 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1610 | 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] | 1611 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1612 | for (gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1613 | gpu_freq <= dev_priv->rps.max_freq_softlimit; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1614 | gpu_freq++) { |
Ben Widawsky | 42c0526 | 2012-09-26 10:34:00 -0700 | [diff] [blame] | 1615 | ia_freq = gpu_freq; |
| 1616 | sandybridge_pcode_read(dev_priv, |
| 1617 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1618 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1619 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", |
| 1620 | gpu_freq * GT_FREQUENCY_MULTIPLIER, |
| 1621 | ((ia_freq >> 0) & 0xff) * 100, |
| 1622 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1623 | } |
| 1624 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1625 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1626 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1627 | out: |
| 1628 | intel_runtime_pm_put(dev_priv); |
| 1629 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1630 | } |
| 1631 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1632 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1633 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1634 | struct drm_info_node *node = m->private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1635 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1636 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1637 | struct intel_opregion *opregion = &dev_priv->opregion; |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1638 | void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1639 | int ret; |
| 1640 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1641 | if (data == NULL) |
| 1642 | return -ENOMEM; |
| 1643 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1644 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1645 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1646 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1647 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1648 | if (opregion->header) { |
| 1649 | memcpy_fromio(data, opregion->header, OPREGION_SIZE); |
| 1650 | seq_write(m, data, OPREGION_SIZE); |
| 1651 | } |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1652 | |
| 1653 | mutex_unlock(&dev->struct_mutex); |
| 1654 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1655 | out: |
| 1656 | kfree(data); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1657 | return 0; |
| 1658 | } |
| 1659 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1660 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1661 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1662 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1663 | struct drm_device *dev = node->minor->dev; |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1664 | struct intel_fbdev *ifbdev = NULL; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1665 | struct intel_framebuffer *fb; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1666 | |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1667 | #ifdef CONFIG_DRM_I915_FBDEV |
| 1668 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1669 | |
| 1670 | ifbdev = dev_priv->fbdev; |
| 1671 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1672 | |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1673 | 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] | 1674 | fb->base.width, |
| 1675 | fb->base.height, |
| 1676 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1677 | fb->base.bits_per_pixel, |
| 1678 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1679 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1680 | seq_putc(m, '\n'); |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1681 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1682 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1683 | mutex_lock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1684 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
Daniel Vetter | 131a56d | 2013-10-17 14:35:31 +0200 | [diff] [blame] | 1685 | if (ifbdev && &fb->base == ifbdev->helper.fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1686 | continue; |
| 1687 | |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1688 | 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] | 1689 | fb->base.width, |
| 1690 | fb->base.height, |
| 1691 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1692 | fb->base.bits_per_pixel, |
| 1693 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1694 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1695 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1696 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1697 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1698 | |
| 1699 | return 0; |
| 1700 | } |
| 1701 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1702 | static void describe_ctx_ringbuf(struct seq_file *m, |
| 1703 | struct intel_ringbuffer *ringbuf) |
| 1704 | { |
| 1705 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
| 1706 | ringbuf->space, ringbuf->head, ringbuf->tail, |
| 1707 | ringbuf->last_retired_head); |
| 1708 | } |
| 1709 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1710 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1711 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1712 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1713 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1714 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1715 | struct intel_engine_cs *ring; |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1716 | struct intel_context *ctx; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1717 | int ret, i; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1718 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1719 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1720 | if (ret) |
| 1721 | return ret; |
| 1722 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1723 | if (dev_priv->ips.pwrctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1724 | seq_puts(m, "power context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1725 | describe_obj(m, dev_priv->ips.pwrctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1726 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1727 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1728 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1729 | if (dev_priv->ips.renderctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1730 | seq_puts(m, "render context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1731 | describe_obj(m, dev_priv->ips.renderctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1732 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1733 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1734 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1735 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1736 | if (!i915.enable_execlists && |
| 1737 | ctx->legacy_hw_ctx.rcs_state == NULL) |
Chris Wilson | b77f699 | 2014-04-30 08:30:00 +0100 | [diff] [blame] | 1738 | continue; |
| 1739 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1740 | seq_puts(m, "HW context "); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 1741 | describe_ctx(m, ctx); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1742 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1743 | if (ring->default_context == ctx) |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1744 | seq_printf(m, "(default context %s) ", |
| 1745 | ring->name); |
| 1746 | } |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1747 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1748 | if (i915.enable_execlists) { |
| 1749 | seq_putc(m, '\n'); |
| 1750 | for_each_ring(ring, dev_priv, i) { |
| 1751 | struct drm_i915_gem_object *ctx_obj = |
| 1752 | ctx->engine[i].state; |
| 1753 | struct intel_ringbuffer *ringbuf = |
| 1754 | ctx->engine[i].ringbuf; |
| 1755 | |
| 1756 | seq_printf(m, "%s: ", ring->name); |
| 1757 | if (ctx_obj) |
| 1758 | describe_obj(m, ctx_obj); |
| 1759 | if (ringbuf) |
| 1760 | describe_ctx_ringbuf(m, ringbuf); |
| 1761 | seq_putc(m, '\n'); |
| 1762 | } |
| 1763 | } else { |
| 1764 | describe_obj(m, ctx->legacy_hw_ctx.rcs_state); |
| 1765 | } |
| 1766 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1767 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1768 | } |
| 1769 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1770 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1771 | |
| 1772 | return 0; |
| 1773 | } |
| 1774 | |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1775 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 1776 | { |
| 1777 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1778 | struct drm_device *dev = node->minor->dev; |
| 1779 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1780 | struct intel_engine_cs *ring; |
| 1781 | struct intel_context *ctx; |
| 1782 | int ret, i; |
| 1783 | |
| 1784 | if (!i915.enable_execlists) { |
| 1785 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 1786 | return 0; |
| 1787 | } |
| 1788 | |
| 1789 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1790 | if (ret) |
| 1791 | return ret; |
| 1792 | |
| 1793 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
| 1794 | for_each_ring(ring, dev_priv, i) { |
| 1795 | struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state; |
| 1796 | |
| 1797 | if (ring->default_context == ctx) |
| 1798 | continue; |
| 1799 | |
| 1800 | if (ctx_obj) { |
Oscar Mateo | dcb4c12 | 2014-11-13 10:28:10 +0000 | [diff] [blame] | 1801 | struct page *page; |
| 1802 | uint32_t *reg_state; |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1803 | int j; |
| 1804 | |
Oscar Mateo | dcb4c12 | 2014-11-13 10:28:10 +0000 | [diff] [blame] | 1805 | i915_gem_obj_ggtt_pin(ctx_obj, |
| 1806 | GEN8_LR_CONTEXT_ALIGN, 0); |
| 1807 | |
| 1808 | page = i915_gem_object_get_page(ctx_obj, 1); |
| 1809 | reg_state = kmap_atomic(page); |
| 1810 | |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1811 | seq_printf(m, "CONTEXT: %s %u\n", ring->name, |
| 1812 | intel_execlists_ctx_id(ctx_obj)); |
| 1813 | |
| 1814 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 1815 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1816 | i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4), |
| 1817 | reg_state[j], reg_state[j + 1], |
| 1818 | reg_state[j + 2], reg_state[j + 3]); |
| 1819 | } |
| 1820 | kunmap_atomic(reg_state); |
| 1821 | |
Oscar Mateo | dcb4c12 | 2014-11-13 10:28:10 +0000 | [diff] [blame] | 1822 | i915_gem_object_ggtt_unpin(ctx_obj); |
| 1823 | |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1824 | seq_putc(m, '\n'); |
| 1825 | } |
| 1826 | } |
| 1827 | } |
| 1828 | |
| 1829 | mutex_unlock(&dev->struct_mutex); |
| 1830 | |
| 1831 | return 0; |
| 1832 | } |
| 1833 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1834 | static int i915_execlists(struct seq_file *m, void *data) |
| 1835 | { |
| 1836 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 1837 | struct drm_device *dev = node->minor->dev; |
| 1838 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1839 | struct intel_engine_cs *ring; |
| 1840 | u32 status_pointer; |
| 1841 | u8 read_pointer; |
| 1842 | u8 write_pointer; |
| 1843 | u32 status; |
| 1844 | u32 ctx_id; |
| 1845 | struct list_head *cursor; |
| 1846 | int ring_id, i; |
| 1847 | int ret; |
| 1848 | |
| 1849 | if (!i915.enable_execlists) { |
| 1850 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 1851 | return 0; |
| 1852 | } |
| 1853 | |
| 1854 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1855 | if (ret) |
| 1856 | return ret; |
| 1857 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 1858 | intel_runtime_pm_get(dev_priv); |
| 1859 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1860 | for_each_ring(ring, dev_priv, ring_id) { |
| 1861 | struct intel_ctx_submit_request *head_req = NULL; |
| 1862 | int count = 0; |
| 1863 | unsigned long flags; |
| 1864 | |
| 1865 | seq_printf(m, "%s\n", ring->name); |
| 1866 | |
| 1867 | status = I915_READ(RING_EXECLIST_STATUS(ring)); |
| 1868 | ctx_id = I915_READ(RING_EXECLIST_STATUS(ring) + 4); |
| 1869 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 1870 | status, ctx_id); |
| 1871 | |
| 1872 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring)); |
| 1873 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 1874 | |
| 1875 | read_pointer = ring->next_context_status_buffer; |
| 1876 | write_pointer = status_pointer & 0x07; |
| 1877 | if (read_pointer > write_pointer) |
| 1878 | write_pointer += 6; |
| 1879 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 1880 | read_pointer, write_pointer); |
| 1881 | |
| 1882 | for (i = 0; i < 6; i++) { |
| 1883 | status = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i); |
| 1884 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i + 4); |
| 1885 | |
| 1886 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 1887 | i, status, ctx_id); |
| 1888 | } |
| 1889 | |
| 1890 | spin_lock_irqsave(&ring->execlist_lock, flags); |
| 1891 | list_for_each(cursor, &ring->execlist_queue) |
| 1892 | count++; |
| 1893 | head_req = list_first_entry_or_null(&ring->execlist_queue, |
| 1894 | struct intel_ctx_submit_request, execlist_link); |
| 1895 | spin_unlock_irqrestore(&ring->execlist_lock, flags); |
| 1896 | |
| 1897 | seq_printf(m, "\t%d requests in queue\n", count); |
| 1898 | if (head_req) { |
| 1899 | struct drm_i915_gem_object *ctx_obj; |
| 1900 | |
| 1901 | ctx_obj = head_req->ctx->engine[ring_id].state; |
| 1902 | seq_printf(m, "\tHead request id: %u\n", |
| 1903 | intel_execlists_ctx_id(ctx_obj)); |
| 1904 | seq_printf(m, "\tHead request tail: %u\n", |
| 1905 | head_req->tail); |
| 1906 | } |
| 1907 | |
| 1908 | seq_putc(m, '\n'); |
| 1909 | } |
| 1910 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 1911 | intel_runtime_pm_put(dev_priv); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1912 | mutex_unlock(&dev->struct_mutex); |
| 1913 | |
| 1914 | return 0; |
| 1915 | } |
| 1916 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1917 | static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data) |
| 1918 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1919 | struct drm_info_node *node = m->private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1920 | struct drm_device *dev = node->minor->dev; |
| 1921 | struct drm_i915_private *dev_priv = dev->dev_private; |
Deepak S | 43709ba | 2013-11-23 14:55:44 +0530 | [diff] [blame] | 1922 | unsigned forcewake_count = 0, fw_rendercount = 0, fw_mediacount = 0; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1923 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1924 | spin_lock_irq(&dev_priv->uncore.lock); |
Deepak S | 43709ba | 2013-11-23 14:55:44 +0530 | [diff] [blame] | 1925 | if (IS_VALLEYVIEW(dev)) { |
| 1926 | fw_rendercount = dev_priv->uncore.fw_rendercount; |
| 1927 | fw_mediacount = dev_priv->uncore.fw_mediacount; |
| 1928 | } else |
| 1929 | forcewake_count = dev_priv->uncore.forcewake_count; |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1930 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 9f1f46a | 2011-12-14 13:57:03 +0100 | [diff] [blame] | 1931 | |
Deepak S | 43709ba | 2013-11-23 14:55:44 +0530 | [diff] [blame] | 1932 | if (IS_VALLEYVIEW(dev)) { |
| 1933 | seq_printf(m, "fw_rendercount = %u\n", fw_rendercount); |
| 1934 | seq_printf(m, "fw_mediacount = %u\n", fw_mediacount); |
| 1935 | } else |
| 1936 | seq_printf(m, "forcewake count = %u\n", forcewake_count); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1937 | |
| 1938 | return 0; |
| 1939 | } |
| 1940 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1941 | static const char *swizzle_string(unsigned swizzle) |
| 1942 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1943 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1944 | case I915_BIT_6_SWIZZLE_NONE: |
| 1945 | return "none"; |
| 1946 | case I915_BIT_6_SWIZZLE_9: |
| 1947 | return "bit9"; |
| 1948 | case I915_BIT_6_SWIZZLE_9_10: |
| 1949 | return "bit9/bit10"; |
| 1950 | case I915_BIT_6_SWIZZLE_9_11: |
| 1951 | return "bit9/bit11"; |
| 1952 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1953 | return "bit9/bit10/bit11"; |
| 1954 | case I915_BIT_6_SWIZZLE_9_17: |
| 1955 | return "bit9/bit17"; |
| 1956 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1957 | return "bit9/bit10/bit17"; |
| 1958 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1959 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1960 | } |
| 1961 | |
| 1962 | return "bug"; |
| 1963 | } |
| 1964 | |
| 1965 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1966 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1967 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1968 | struct drm_device *dev = node->minor->dev; |
| 1969 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1970 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1971 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1972 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1973 | if (ret) |
| 1974 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1975 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1976 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1977 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1978 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1979 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1980 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1981 | |
| 1982 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 1983 | seq_printf(m, "DDC = 0x%08x\n", |
| 1984 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1985 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 1986 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1987 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1988 | I915_READ16(C0DRB3)); |
| 1989 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1990 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 1991 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1992 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1993 | I915_READ(MAD_DIMM_C0)); |
| 1994 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1995 | I915_READ(MAD_DIMM_C1)); |
| 1996 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1997 | I915_READ(MAD_DIMM_C2)); |
| 1998 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1999 | I915_READ(TILECTL)); |
Robert Beckett | 5907f5f | 2014-01-23 14:23:14 +0000 | [diff] [blame] | 2000 | if (INTEL_INFO(dev)->gen >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2001 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2002 | I915_READ(GAMTARBMODE)); |
| 2003 | else |
| 2004 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2005 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2006 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2007 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2008 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2009 | |
| 2010 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2011 | seq_puts(m, "L-shaped memory detected\n"); |
| 2012 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2013 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2014 | mutex_unlock(&dev->struct_mutex); |
| 2015 | |
| 2016 | return 0; |
| 2017 | } |
| 2018 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2019 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2020 | { |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 2021 | struct intel_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2022 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2023 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2024 | |
| 2025 | if (!ppgtt) { |
| 2026 | seq_printf(m, " no ppgtt for context %d\n", |
| 2027 | ctx->user_handle); |
| 2028 | return 0; |
| 2029 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2030 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2031 | if (i915_gem_context_is_default(ctx)) |
| 2032 | seq_puts(m, " default context:\n"); |
| 2033 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2034 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2035 | ppgtt->debug_dump(ppgtt, m); |
| 2036 | |
| 2037 | return 0; |
| 2038 | } |
| 2039 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2040 | 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] | 2041 | { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2042 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2043 | struct intel_engine_cs *ring; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2044 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2045 | int unused, i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2046 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2047 | if (!ppgtt) |
| 2048 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2049 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2050 | seq_printf(m, "Page directories: %d\n", ppgtt->num_pd_pages); |
Ben Widawsky | 5abbcca | 2014-02-21 13:06:34 -0800 | [diff] [blame] | 2051 | seq_printf(m, "Page tables: %d\n", ppgtt->num_pd_entries); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2052 | for_each_ring(ring, dev_priv, unused) { |
| 2053 | seq_printf(m, "%s\n", ring->name); |
| 2054 | for (i = 0; i < 4; i++) { |
| 2055 | u32 offset = 0x270 + i * 8; |
| 2056 | u64 pdp = I915_READ(ring->mmio_base + offset + 4); |
| 2057 | pdp <<= 32; |
| 2058 | pdp |= I915_READ(ring->mmio_base + offset); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2059 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2060 | } |
| 2061 | } |
| 2062 | } |
| 2063 | |
| 2064 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2065 | { |
| 2066 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2067 | struct intel_engine_cs *ring; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2068 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2069 | int i; |
| 2070 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2071 | if (INTEL_INFO(dev)->gen == 6) |
| 2072 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2073 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 2074 | for_each_ring(ring, dev_priv, i) { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2075 | seq_printf(m, "%s\n", ring->name); |
| 2076 | if (INTEL_INFO(dev)->gen == 7) |
| 2077 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 2078 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 2079 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 2080 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 2081 | } |
| 2082 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2083 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2084 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2085 | seq_puts(m, "aliasing PPGTT:\n"); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2086 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2087 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2088 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2089 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2090 | |
| 2091 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2092 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2093 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2094 | seq_printf(m, "proc: %s\n", |
| 2095 | get_pid_task(file->pid, PIDTYPE_PID)->comm); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2096 | idr_for_each(&file_priv->context_idr, per_file_ctx, m); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2097 | } |
| 2098 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2099 | } |
| 2100 | |
| 2101 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2102 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2103 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2104 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2105 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2106 | |
| 2107 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2108 | if (ret) |
| 2109 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2110 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2111 | |
| 2112 | if (INTEL_INFO(dev)->gen >= 8) |
| 2113 | gen8_ppgtt_info(m, dev); |
| 2114 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2115 | gen6_ppgtt_info(m, dev); |
| 2116 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2117 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2118 | mutex_unlock(&dev->struct_mutex); |
| 2119 | |
| 2120 | return 0; |
| 2121 | } |
| 2122 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2123 | static int i915_llc(struct seq_file *m, void *data) |
| 2124 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2125 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2126 | struct drm_device *dev = node->minor->dev; |
| 2127 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2128 | |
| 2129 | /* Size calculation for LLC is a bit of a pain. Ignore for now. */ |
| 2130 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
| 2131 | seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size); |
| 2132 | |
| 2133 | return 0; |
| 2134 | } |
| 2135 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2136 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2137 | { |
| 2138 | struct drm_info_node *node = m->private; |
| 2139 | struct drm_device *dev = node->minor->dev; |
| 2140 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2141 | u32 psrperf = 0; |
| 2142 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2143 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2144 | intel_runtime_pm_get(dev_priv); |
| 2145 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2146 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2147 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2148 | seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok)); |
Daniel Vetter | 2807cf6 | 2014-07-11 10:30:11 -0700 | [diff] [blame] | 2149 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2150 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2151 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2152 | dev_priv->psr.busy_frontbuffer_bits); |
| 2153 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2154 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2155 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2156 | enabled = HAS_PSR(dev) && |
| 2157 | I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE; |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2158 | seq_printf(m, "HW Enabled & Active bit: %s\n", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2159 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2160 | if (HAS_PSR(dev)) |
| 2161 | psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) & |
| 2162 | EDP_PSR_PERF_CNT_MASK; |
| 2163 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2164 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2165 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2166 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2167 | return 0; |
| 2168 | } |
| 2169 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2170 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2171 | { |
| 2172 | struct drm_info_node *node = m->private; |
| 2173 | struct drm_device *dev = node->minor->dev; |
| 2174 | struct intel_encoder *encoder; |
| 2175 | struct intel_connector *connector; |
| 2176 | struct intel_dp *intel_dp = NULL; |
| 2177 | int ret; |
| 2178 | u8 crc[6]; |
| 2179 | |
| 2180 | drm_modeset_lock_all(dev); |
| 2181 | list_for_each_entry(connector, &dev->mode_config.connector_list, |
| 2182 | base.head) { |
| 2183 | |
| 2184 | if (connector->base.dpms != DRM_MODE_DPMS_ON) |
| 2185 | continue; |
| 2186 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2187 | if (!connector->base.encoder) |
| 2188 | continue; |
| 2189 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2190 | encoder = to_intel_encoder(connector->base.encoder); |
| 2191 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 2192 | continue; |
| 2193 | |
| 2194 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 2195 | |
| 2196 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2197 | if (ret) |
| 2198 | goto out; |
| 2199 | |
| 2200 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2201 | crc[0], crc[1], crc[2], |
| 2202 | crc[3], crc[4], crc[5]); |
| 2203 | goto out; |
| 2204 | } |
| 2205 | ret = -ENODEV; |
| 2206 | out: |
| 2207 | drm_modeset_unlock_all(dev); |
| 2208 | return ret; |
| 2209 | } |
| 2210 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2211 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2212 | { |
| 2213 | struct drm_info_node *node = m->private; |
| 2214 | struct drm_device *dev = node->minor->dev; |
| 2215 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2216 | u64 power; |
| 2217 | u32 units; |
| 2218 | |
| 2219 | if (INTEL_INFO(dev)->gen < 6) |
| 2220 | return -ENODEV; |
| 2221 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2222 | intel_runtime_pm_get(dev_priv); |
| 2223 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2224 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2225 | power = (power & 0x1f00) >> 8; |
| 2226 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2227 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2228 | power *= units; |
| 2229 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2230 | intel_runtime_pm_put(dev_priv); |
| 2231 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2232 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2233 | |
| 2234 | return 0; |
| 2235 | } |
| 2236 | |
| 2237 | static int i915_pc8_status(struct seq_file *m, void *unused) |
| 2238 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2239 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2240 | struct drm_device *dev = node->minor->dev; |
| 2241 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2242 | |
Zhenyu Wang | 85b8d5c | 2014-04-01 19:39:48 -0300 | [diff] [blame] | 2243 | if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2244 | seq_puts(m, "not supported\n"); |
| 2245 | return 0; |
| 2246 | } |
| 2247 | |
Paulo Zanoni | 86c4ec0 | 2014-02-21 13:52:24 -0300 | [diff] [blame] | 2248 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2249 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2250 | yesno(!intel_irqs_enabled(dev_priv))); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2251 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2252 | return 0; |
| 2253 | } |
| 2254 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2255 | static const char *power_domain_str(enum intel_display_power_domain domain) |
| 2256 | { |
| 2257 | switch (domain) { |
| 2258 | case POWER_DOMAIN_PIPE_A: |
| 2259 | return "PIPE_A"; |
| 2260 | case POWER_DOMAIN_PIPE_B: |
| 2261 | return "PIPE_B"; |
| 2262 | case POWER_DOMAIN_PIPE_C: |
| 2263 | return "PIPE_C"; |
| 2264 | case POWER_DOMAIN_PIPE_A_PANEL_FITTER: |
| 2265 | return "PIPE_A_PANEL_FITTER"; |
| 2266 | case POWER_DOMAIN_PIPE_B_PANEL_FITTER: |
| 2267 | return "PIPE_B_PANEL_FITTER"; |
| 2268 | case POWER_DOMAIN_PIPE_C_PANEL_FITTER: |
| 2269 | return "PIPE_C_PANEL_FITTER"; |
| 2270 | case POWER_DOMAIN_TRANSCODER_A: |
| 2271 | return "TRANSCODER_A"; |
| 2272 | case POWER_DOMAIN_TRANSCODER_B: |
| 2273 | return "TRANSCODER_B"; |
| 2274 | case POWER_DOMAIN_TRANSCODER_C: |
| 2275 | return "TRANSCODER_C"; |
| 2276 | case POWER_DOMAIN_TRANSCODER_EDP: |
| 2277 | return "TRANSCODER_EDP"; |
Imre Deak | 319be8a | 2014-03-04 19:22:57 +0200 | [diff] [blame] | 2278 | case POWER_DOMAIN_PORT_DDI_A_2_LANES: |
| 2279 | return "PORT_DDI_A_2_LANES"; |
| 2280 | case POWER_DOMAIN_PORT_DDI_A_4_LANES: |
| 2281 | return "PORT_DDI_A_4_LANES"; |
| 2282 | case POWER_DOMAIN_PORT_DDI_B_2_LANES: |
| 2283 | return "PORT_DDI_B_2_LANES"; |
| 2284 | case POWER_DOMAIN_PORT_DDI_B_4_LANES: |
| 2285 | return "PORT_DDI_B_4_LANES"; |
| 2286 | case POWER_DOMAIN_PORT_DDI_C_2_LANES: |
| 2287 | return "PORT_DDI_C_2_LANES"; |
| 2288 | case POWER_DOMAIN_PORT_DDI_C_4_LANES: |
| 2289 | return "PORT_DDI_C_4_LANES"; |
| 2290 | case POWER_DOMAIN_PORT_DDI_D_2_LANES: |
| 2291 | return "PORT_DDI_D_2_LANES"; |
| 2292 | case POWER_DOMAIN_PORT_DDI_D_4_LANES: |
| 2293 | return "PORT_DDI_D_4_LANES"; |
| 2294 | case POWER_DOMAIN_PORT_DSI: |
| 2295 | return "PORT_DSI"; |
| 2296 | case POWER_DOMAIN_PORT_CRT: |
| 2297 | return "PORT_CRT"; |
| 2298 | case POWER_DOMAIN_PORT_OTHER: |
| 2299 | return "PORT_OTHER"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2300 | case POWER_DOMAIN_VGA: |
| 2301 | return "VGA"; |
| 2302 | case POWER_DOMAIN_AUDIO: |
| 2303 | return "AUDIO"; |
Paulo Zanoni | bd2bb1b | 2014-07-04 11:27:38 -0300 | [diff] [blame] | 2304 | case POWER_DOMAIN_PLLS: |
| 2305 | return "PLLS"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2306 | case POWER_DOMAIN_INIT: |
| 2307 | return "INIT"; |
| 2308 | default: |
| 2309 | WARN_ON(1); |
| 2310 | return "?"; |
| 2311 | } |
| 2312 | } |
| 2313 | |
| 2314 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2315 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2316 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2317 | struct drm_device *dev = node->minor->dev; |
| 2318 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2319 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2320 | int i; |
| 2321 | |
| 2322 | mutex_lock(&power_domains->lock); |
| 2323 | |
| 2324 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2325 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2326 | struct i915_power_well *power_well; |
| 2327 | enum intel_display_power_domain power_domain; |
| 2328 | |
| 2329 | power_well = &power_domains->power_wells[i]; |
| 2330 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2331 | power_well->count); |
| 2332 | |
| 2333 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2334 | power_domain++) { |
| 2335 | if (!(BIT(power_domain) & power_well->domains)) |
| 2336 | continue; |
| 2337 | |
| 2338 | seq_printf(m, " %-23s %d\n", |
| 2339 | power_domain_str(power_domain), |
| 2340 | power_domains->domain_use_count[power_domain]); |
| 2341 | } |
| 2342 | } |
| 2343 | |
| 2344 | mutex_unlock(&power_domains->lock); |
| 2345 | |
| 2346 | return 0; |
| 2347 | } |
| 2348 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2349 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2350 | struct drm_display_mode *mode) |
| 2351 | { |
| 2352 | int i; |
| 2353 | |
| 2354 | for (i = 0; i < tabs; i++) |
| 2355 | seq_putc(m, '\t'); |
| 2356 | |
| 2357 | 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", |
| 2358 | mode->base.id, mode->name, |
| 2359 | mode->vrefresh, mode->clock, |
| 2360 | mode->hdisplay, mode->hsync_start, |
| 2361 | mode->hsync_end, mode->htotal, |
| 2362 | mode->vdisplay, mode->vsync_start, |
| 2363 | mode->vsync_end, mode->vtotal, |
| 2364 | mode->type, mode->flags); |
| 2365 | } |
| 2366 | |
| 2367 | static void intel_encoder_info(struct seq_file *m, |
| 2368 | struct intel_crtc *intel_crtc, |
| 2369 | struct intel_encoder *intel_encoder) |
| 2370 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2371 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2372 | struct drm_device *dev = node->minor->dev; |
| 2373 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2374 | struct intel_connector *intel_connector; |
| 2375 | struct drm_encoder *encoder; |
| 2376 | |
| 2377 | encoder = &intel_encoder->base; |
| 2378 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a0 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2379 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2380 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2381 | struct drm_connector *connector = &intel_connector->base; |
| 2382 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2383 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2384 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2385 | drm_get_connector_status_name(connector->status)); |
| 2386 | if (connector->status == connector_status_connected) { |
| 2387 | struct drm_display_mode *mode = &crtc->mode; |
| 2388 | seq_printf(m, ", mode:\n"); |
| 2389 | intel_seq_print_mode(m, 2, mode); |
| 2390 | } else { |
| 2391 | seq_putc(m, '\n'); |
| 2392 | } |
| 2393 | } |
| 2394 | } |
| 2395 | |
| 2396 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2397 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2398 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2399 | struct drm_device *dev = node->minor->dev; |
| 2400 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2401 | struct intel_encoder *intel_encoder; |
| 2402 | |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2403 | if (crtc->primary->fb) |
| 2404 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
| 2405 | crtc->primary->fb->base.id, crtc->x, crtc->y, |
| 2406 | crtc->primary->fb->width, crtc->primary->fb->height); |
| 2407 | else |
| 2408 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2409 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2410 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2411 | } |
| 2412 | |
| 2413 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2414 | { |
| 2415 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2416 | |
| 2417 | seq_printf(m, "\tfixed mode:\n"); |
| 2418 | intel_seq_print_mode(m, 2, mode); |
| 2419 | } |
| 2420 | |
| 2421 | static void intel_dp_info(struct seq_file *m, |
| 2422 | struct intel_connector *intel_connector) |
| 2423 | { |
| 2424 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2425 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2426 | |
| 2427 | seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); |
| 2428 | seq_printf(m, "\taudio support: %s\n", intel_dp->has_audio ? "yes" : |
| 2429 | "no"); |
| 2430 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2431 | intel_panel_info(m, &intel_connector->panel); |
| 2432 | } |
| 2433 | |
| 2434 | static void intel_hdmi_info(struct seq_file *m, |
| 2435 | struct intel_connector *intel_connector) |
| 2436 | { |
| 2437 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2438 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2439 | |
| 2440 | seq_printf(m, "\taudio support: %s\n", intel_hdmi->has_audio ? "yes" : |
| 2441 | "no"); |
| 2442 | } |
| 2443 | |
| 2444 | static void intel_lvds_info(struct seq_file *m, |
| 2445 | struct intel_connector *intel_connector) |
| 2446 | { |
| 2447 | intel_panel_info(m, &intel_connector->panel); |
| 2448 | } |
| 2449 | |
| 2450 | static void intel_connector_info(struct seq_file *m, |
| 2451 | struct drm_connector *connector) |
| 2452 | { |
| 2453 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2454 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2455 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2456 | |
| 2457 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2458 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2459 | drm_get_connector_status_name(connector->status)); |
| 2460 | if (connector->status == connector_status_connected) { |
| 2461 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2462 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2463 | connector->display_info.width_mm, |
| 2464 | connector->display_info.height_mm); |
| 2465 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2466 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2467 | seq_printf(m, "\tCEA rev: %d\n", |
| 2468 | connector->display_info.cea_rev); |
| 2469 | } |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2470 | if (intel_encoder) { |
| 2471 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2472 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2473 | intel_dp_info(m, intel_connector); |
| 2474 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2475 | intel_hdmi_info(m, intel_connector); |
| 2476 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2477 | intel_lvds_info(m, intel_connector); |
| 2478 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2479 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2480 | seq_printf(m, "\tmodes:\n"); |
| 2481 | list_for_each_entry(mode, &connector->modes, head) |
| 2482 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2483 | } |
| 2484 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2485 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 2486 | { |
| 2487 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2488 | u32 state; |
| 2489 | |
| 2490 | if (IS_845G(dev) || IS_I865G(dev)) |
| 2491 | state = I915_READ(_CURACNTR) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2492 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2493 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2494 | |
| 2495 | return state; |
| 2496 | } |
| 2497 | |
| 2498 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 2499 | { |
| 2500 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2501 | u32 pos; |
| 2502 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2503 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2504 | |
| 2505 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2506 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2507 | *x = -*x; |
| 2508 | |
| 2509 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2510 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2511 | *y = -*y; |
| 2512 | |
| 2513 | return cursor_active(dev, pipe); |
| 2514 | } |
| 2515 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2516 | static int i915_display_info(struct seq_file *m, void *unused) |
| 2517 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2518 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2519 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2520 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2521 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2522 | struct drm_connector *connector; |
| 2523 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2524 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2525 | drm_modeset_lock_all(dev); |
| 2526 | seq_printf(m, "CRTC info\n"); |
| 2527 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 2528 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2529 | bool active; |
| 2530 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2531 | |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2532 | seq_printf(m, "CRTC %d: pipe: %c, active=%s (size=%dx%d)\n", |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2533 | crtc->base.base.id, pipe_name(crtc->pipe), |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2534 | yesno(crtc->active), crtc->config.pipe_src_w, crtc->config.pipe_src_h); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2535 | if (crtc->active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2536 | intel_crtc_info(m, crtc); |
| 2537 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2538 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2539 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x, active? %s\n", |
Chris Wilson | 4b0e333 | 2014-05-30 16:35:26 +0300 | [diff] [blame] | 2540 | yesno(crtc->cursor_base), |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2541 | x, y, crtc->cursor_width, crtc->cursor_height, |
| 2542 | crtc->cursor_addr, yesno(active)); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2543 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 2544 | |
| 2545 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 2546 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 2547 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2548 | } |
| 2549 | |
| 2550 | seq_printf(m, "\n"); |
| 2551 | seq_printf(m, "Connector info\n"); |
| 2552 | seq_printf(m, "--------------\n"); |
| 2553 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 2554 | intel_connector_info(m, connector); |
| 2555 | } |
| 2556 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2557 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2558 | |
| 2559 | return 0; |
| 2560 | } |
| 2561 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2562 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 2563 | { |
| 2564 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2565 | struct drm_device *dev = node->minor->dev; |
| 2566 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2567 | struct intel_engine_cs *ring; |
| 2568 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
| 2569 | int i, j, ret; |
| 2570 | |
| 2571 | if (!i915_semaphore_is_enabled(dev)) { |
| 2572 | seq_puts(m, "Semaphores are disabled\n"); |
| 2573 | return 0; |
| 2574 | } |
| 2575 | |
| 2576 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2577 | if (ret) |
| 2578 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2579 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2580 | |
| 2581 | if (IS_BROADWELL(dev)) { |
| 2582 | struct page *page; |
| 2583 | uint64_t *seqno; |
| 2584 | |
| 2585 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 2586 | |
| 2587 | seqno = (uint64_t *)kmap_atomic(page); |
| 2588 | for_each_ring(ring, dev_priv, i) { |
| 2589 | uint64_t offset; |
| 2590 | |
| 2591 | seq_printf(m, "%s\n", ring->name); |
| 2592 | |
| 2593 | seq_puts(m, " Last signal:"); |
| 2594 | for (j = 0; j < num_rings; j++) { |
| 2595 | offset = i * I915_NUM_RINGS + j; |
| 2596 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2597 | seqno[offset], offset * 8); |
| 2598 | } |
| 2599 | seq_putc(m, '\n'); |
| 2600 | |
| 2601 | seq_puts(m, " Last wait: "); |
| 2602 | for (j = 0; j < num_rings; j++) { |
| 2603 | offset = i + (j * I915_NUM_RINGS); |
| 2604 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2605 | seqno[offset], offset * 8); |
| 2606 | } |
| 2607 | seq_putc(m, '\n'); |
| 2608 | |
| 2609 | } |
| 2610 | kunmap_atomic(seqno); |
| 2611 | } else { |
| 2612 | seq_puts(m, " Last signal:"); |
| 2613 | for_each_ring(ring, dev_priv, i) |
| 2614 | for (j = 0; j < num_rings; j++) |
| 2615 | seq_printf(m, "0x%08x\n", |
| 2616 | I915_READ(ring->semaphore.mbox.signal[j])); |
| 2617 | seq_putc(m, '\n'); |
| 2618 | } |
| 2619 | |
| 2620 | seq_puts(m, "\nSync seqno:\n"); |
| 2621 | for_each_ring(ring, dev_priv, i) { |
| 2622 | for (j = 0; j < num_rings; j++) { |
| 2623 | seq_printf(m, " 0x%08x ", ring->semaphore.sync_seqno[j]); |
| 2624 | } |
| 2625 | seq_putc(m, '\n'); |
| 2626 | } |
| 2627 | seq_putc(m, '\n'); |
| 2628 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2629 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2630 | mutex_unlock(&dev->struct_mutex); |
| 2631 | return 0; |
| 2632 | } |
| 2633 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2634 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 2635 | { |
| 2636 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2637 | struct drm_device *dev = node->minor->dev; |
| 2638 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2639 | int i; |
| 2640 | |
| 2641 | drm_modeset_lock_all(dev); |
| 2642 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 2643 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 2644 | |
| 2645 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); |
Ander Conselvan de Oliveira | 1e6f2dd | 2014-10-29 11:32:31 +0200 | [diff] [blame] | 2646 | seq_printf(m, " crtc_mask: 0x%08x, active: %d, on: %s\n", |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 2647 | pll->config.crtc_mask, pll->active, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2648 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 2649 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 2650 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 2651 | pll->config.hw_state.dpll_md); |
| 2652 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 2653 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 2654 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2655 | } |
| 2656 | drm_modeset_unlock_all(dev); |
| 2657 | |
| 2658 | return 0; |
| 2659 | } |
| 2660 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 2661 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2662 | { |
| 2663 | int i; |
| 2664 | int ret; |
| 2665 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2666 | struct drm_device *dev = node->minor->dev; |
| 2667 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2668 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2669 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2670 | if (ret) |
| 2671 | return ret; |
| 2672 | |
| 2673 | intel_runtime_pm_get(dev_priv); |
| 2674 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2675 | seq_printf(m, "Workarounds applied: %d\n", dev_priv->workarounds.count); |
| 2676 | for (i = 0; i < dev_priv->workarounds.count; ++i) { |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 2677 | u32 addr, mask, value, read; |
| 2678 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2679 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2680 | addr = dev_priv->workarounds.reg[i].addr; |
| 2681 | mask = dev_priv->workarounds.reg[i].mask; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 2682 | value = dev_priv->workarounds.reg[i].value; |
| 2683 | read = I915_READ(addr); |
| 2684 | ok = (value & mask) == (read & mask); |
| 2685 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n", |
| 2686 | addr, value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2687 | } |
| 2688 | |
| 2689 | intel_runtime_pm_put(dev_priv); |
| 2690 | mutex_unlock(&dev->struct_mutex); |
| 2691 | |
| 2692 | return 0; |
| 2693 | } |
| 2694 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2695 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 2696 | { |
| 2697 | struct drm_info_node *node = m->private; |
| 2698 | struct drm_device *dev = node->minor->dev; |
| 2699 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2700 | struct skl_ddb_allocation *ddb; |
| 2701 | struct skl_ddb_entry *entry; |
| 2702 | enum pipe pipe; |
| 2703 | int plane; |
| 2704 | |
| 2705 | drm_modeset_lock_all(dev); |
| 2706 | |
| 2707 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 2708 | |
| 2709 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 2710 | |
| 2711 | for_each_pipe(dev_priv, pipe) { |
| 2712 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 2713 | |
| 2714 | for_each_plane(pipe, plane) { |
| 2715 | entry = &ddb->plane[pipe][plane]; |
| 2716 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 2717 | entry->start, entry->end, |
| 2718 | skl_ddb_entry_size(entry)); |
| 2719 | } |
| 2720 | |
| 2721 | entry = &ddb->cursor[pipe]; |
| 2722 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 2723 | entry->end, skl_ddb_entry_size(entry)); |
| 2724 | } |
| 2725 | |
| 2726 | drm_modeset_unlock_all(dev); |
| 2727 | |
| 2728 | return 0; |
| 2729 | } |
| 2730 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2731 | struct pipe_crc_info { |
| 2732 | const char *name; |
| 2733 | struct drm_device *dev; |
| 2734 | enum pipe pipe; |
| 2735 | }; |
| 2736 | |
Dave Airlie | 11bed958 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 2737 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 2738 | { |
| 2739 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2740 | struct drm_device *dev = node->minor->dev; |
| 2741 | struct drm_encoder *encoder; |
| 2742 | struct intel_encoder *intel_encoder; |
| 2743 | struct intel_digital_port *intel_dig_port; |
| 2744 | drm_modeset_lock_all(dev); |
| 2745 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 2746 | intel_encoder = to_intel_encoder(encoder); |
| 2747 | if (intel_encoder->type != INTEL_OUTPUT_DISPLAYPORT) |
| 2748 | continue; |
| 2749 | intel_dig_port = enc_to_dig_port(encoder); |
| 2750 | if (!intel_dig_port->dp.can_mst) |
| 2751 | continue; |
| 2752 | |
| 2753 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 2754 | } |
| 2755 | drm_modeset_unlock_all(dev); |
| 2756 | return 0; |
| 2757 | } |
| 2758 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2759 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2760 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2761 | struct pipe_crc_info *info = inode->i_private; |
| 2762 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2763 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2764 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 2765 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 2766 | return -ENODEV; |
| 2767 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2768 | spin_lock_irq(&pipe_crc->lock); |
| 2769 | |
| 2770 | if (pipe_crc->opened) { |
| 2771 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2772 | return -EBUSY; /* already open */ |
| 2773 | } |
| 2774 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2775 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2776 | filep->private_data = inode->i_private; |
| 2777 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2778 | spin_unlock_irq(&pipe_crc->lock); |
| 2779 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2780 | return 0; |
| 2781 | } |
| 2782 | |
| 2783 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 2784 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2785 | struct pipe_crc_info *info = inode->i_private; |
| 2786 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2787 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2788 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2789 | spin_lock_irq(&pipe_crc->lock); |
| 2790 | pipe_crc->opened = false; |
| 2791 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2792 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2793 | return 0; |
| 2794 | } |
| 2795 | |
| 2796 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 2797 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 2798 | /* account for \'0' */ |
| 2799 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 2800 | |
| 2801 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 2802 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2803 | assert_spin_locked(&pipe_crc->lock); |
| 2804 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 2805 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2806 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2807 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2808 | static ssize_t |
| 2809 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 2810 | loff_t *pos) |
| 2811 | { |
| 2812 | struct pipe_crc_info *info = filep->private_data; |
| 2813 | struct drm_device *dev = info->dev; |
| 2814 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2815 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2816 | char buf[PIPE_CRC_BUFFER_LEN]; |
| 2817 | int head, tail, n_entries, n; |
| 2818 | ssize_t bytes_read; |
| 2819 | |
| 2820 | /* |
| 2821 | * Don't allow user space to provide buffers not big enough to hold |
| 2822 | * a line of data. |
| 2823 | */ |
| 2824 | if (count < PIPE_CRC_LINE_LEN) |
| 2825 | return -EINVAL; |
| 2826 | |
| 2827 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 2828 | return 0; |
| 2829 | |
| 2830 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2831 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2832 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2833 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2834 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2835 | if (filep->f_flags & O_NONBLOCK) { |
| 2836 | spin_unlock_irq(&pipe_crc->lock); |
| 2837 | return -EAGAIN; |
| 2838 | } |
| 2839 | |
| 2840 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 2841 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 2842 | if (ret) { |
| 2843 | spin_unlock_irq(&pipe_crc->lock); |
| 2844 | return ret; |
| 2845 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2846 | } |
| 2847 | |
| 2848 | /* We now have one or more entries to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2849 | head = pipe_crc->head; |
| 2850 | tail = pipe_crc->tail; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2851 | n_entries = min((size_t)CIRC_CNT(head, tail, INTEL_PIPE_CRC_ENTRIES_NR), |
| 2852 | count / PIPE_CRC_LINE_LEN); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2853 | spin_unlock_irq(&pipe_crc->lock); |
| 2854 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2855 | bytes_read = 0; |
| 2856 | n = 0; |
| 2857 | do { |
| 2858 | struct intel_pipe_crc_entry *entry = &pipe_crc->entries[tail]; |
| 2859 | int ret; |
| 2860 | |
| 2861 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 2862 | "%8u %8x %8x %8x %8x %8x\n", |
| 2863 | entry->frame, entry->crc[0], |
| 2864 | entry->crc[1], entry->crc[2], |
| 2865 | entry->crc[3], entry->crc[4]); |
| 2866 | |
| 2867 | ret = copy_to_user(user_buf + n * PIPE_CRC_LINE_LEN, |
| 2868 | buf, PIPE_CRC_LINE_LEN); |
| 2869 | if (ret == PIPE_CRC_LINE_LEN) |
| 2870 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 2871 | |
| 2872 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 2873 | tail = (tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2874 | n++; |
| 2875 | } while (--n_entries); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2876 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2877 | spin_lock_irq(&pipe_crc->lock); |
| 2878 | pipe_crc->tail = tail; |
| 2879 | spin_unlock_irq(&pipe_crc->lock); |
| 2880 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2881 | return bytes_read; |
| 2882 | } |
| 2883 | |
| 2884 | static const struct file_operations i915_pipe_crc_fops = { |
| 2885 | .owner = THIS_MODULE, |
| 2886 | .open = i915_pipe_crc_open, |
| 2887 | .read = i915_pipe_crc_read, |
| 2888 | .release = i915_pipe_crc_release, |
| 2889 | }; |
| 2890 | |
| 2891 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 2892 | { |
| 2893 | .name = "i915_pipe_A_crc", |
| 2894 | .pipe = PIPE_A, |
| 2895 | }, |
| 2896 | { |
| 2897 | .name = "i915_pipe_B_crc", |
| 2898 | .pipe = PIPE_B, |
| 2899 | }, |
| 2900 | { |
| 2901 | .name = "i915_pipe_C_crc", |
| 2902 | .pipe = PIPE_C, |
| 2903 | }, |
| 2904 | }; |
| 2905 | |
| 2906 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 2907 | enum pipe pipe) |
| 2908 | { |
| 2909 | struct drm_device *dev = minor->dev; |
| 2910 | struct dentry *ent; |
| 2911 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 2912 | |
| 2913 | info->dev = dev; |
| 2914 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 2915 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 2916 | if (!ent) |
| 2917 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2918 | |
| 2919 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2920 | } |
| 2921 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 2922 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2923 | "none", |
| 2924 | "plane1", |
| 2925 | "plane2", |
| 2926 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2927 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2928 | "TV", |
| 2929 | "DP-B", |
| 2930 | "DP-C", |
| 2931 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2932 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2933 | }; |
| 2934 | |
| 2935 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 2936 | { |
| 2937 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 2938 | return pipe_crc_sources[source]; |
| 2939 | } |
| 2940 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2941 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2942 | { |
| 2943 | struct drm_device *dev = m->private; |
| 2944 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2945 | int i; |
| 2946 | |
| 2947 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 2948 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 2949 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 2950 | |
| 2951 | return 0; |
| 2952 | } |
| 2953 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2954 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2955 | { |
| 2956 | struct drm_device *dev = inode->i_private; |
| 2957 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2958 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2959 | } |
| 2960 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2961 | 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] | 2962 | uint32_t *val) |
| 2963 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2964 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 2965 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2966 | |
| 2967 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 2968 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2969 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 2970 | break; |
| 2971 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 2972 | *val = 0; |
| 2973 | break; |
| 2974 | default: |
| 2975 | return -EINVAL; |
| 2976 | } |
| 2977 | |
| 2978 | return 0; |
| 2979 | } |
| 2980 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2981 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 2982 | enum intel_pipe_crc_source *source) |
| 2983 | { |
| 2984 | struct intel_encoder *encoder; |
| 2985 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 2986 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2987 | int ret = 0; |
| 2988 | |
| 2989 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2990 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 2991 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 2992 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2993 | if (!encoder->base.crtc) |
| 2994 | continue; |
| 2995 | |
| 2996 | crtc = to_intel_crtc(encoder->base.crtc); |
| 2997 | |
| 2998 | if (crtc->pipe != pipe) |
| 2999 | continue; |
| 3000 | |
| 3001 | switch (encoder->type) { |
| 3002 | case INTEL_OUTPUT_TVOUT: |
| 3003 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3004 | break; |
| 3005 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3006 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3007 | dig_port = enc_to_dig_port(&encoder->base); |
| 3008 | switch (dig_port->port) { |
| 3009 | case PORT_B: |
| 3010 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3011 | break; |
| 3012 | case PORT_C: |
| 3013 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3014 | break; |
| 3015 | case PORT_D: |
| 3016 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3017 | break; |
| 3018 | default: |
| 3019 | WARN(1, "nonexisting DP port %c\n", |
| 3020 | port_name(dig_port->port)); |
| 3021 | break; |
| 3022 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3023 | break; |
Paulo Zanoni | 6847d71 | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3024 | default: |
| 3025 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3026 | } |
| 3027 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3028 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3029 | |
| 3030 | return ret; |
| 3031 | } |
| 3032 | |
| 3033 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3034 | enum pipe pipe, |
| 3035 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3036 | uint32_t *val) |
| 3037 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3038 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3039 | bool need_stable_symbols = false; |
| 3040 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3041 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3042 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3043 | if (ret) |
| 3044 | return ret; |
| 3045 | } |
| 3046 | |
| 3047 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3048 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3049 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3050 | break; |
| 3051 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3052 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3053 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3054 | break; |
| 3055 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3056 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3057 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3058 | break; |
| 3059 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3060 | *val = 0; |
| 3061 | break; |
| 3062 | default: |
| 3063 | return -EINVAL; |
| 3064 | } |
| 3065 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3066 | /* |
| 3067 | * When the pipe CRC tap point is after the transcoders we need |
| 3068 | * to tweak symbol-level features to produce a deterministic series of |
| 3069 | * symbols for a given frame. We need to reset those features only once |
| 3070 | * a frame (instead of every nth symbol): |
| 3071 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3072 | * link (SDVO) |
| 3073 | * - DisplayPort scrambling: used for EMI reduction |
| 3074 | */ |
| 3075 | if (need_stable_symbols) { |
| 3076 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3077 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3078 | tmp |= DC_BALANCE_RESET_VLV; |
| 3079 | if (pipe == PIPE_A) |
| 3080 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3081 | else |
| 3082 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3083 | |
| 3084 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3085 | } |
| 3086 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3087 | return 0; |
| 3088 | } |
| 3089 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3090 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3091 | enum pipe pipe, |
| 3092 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3093 | uint32_t *val) |
| 3094 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3095 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3096 | bool need_stable_symbols = false; |
| 3097 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3098 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3099 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3100 | if (ret) |
| 3101 | return ret; |
| 3102 | } |
| 3103 | |
| 3104 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3105 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3106 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3107 | break; |
| 3108 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 3109 | if (!SUPPORTS_TV(dev)) |
| 3110 | return -EINVAL; |
| 3111 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3112 | break; |
| 3113 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3114 | if (!IS_G4X(dev)) |
| 3115 | return -EINVAL; |
| 3116 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3117 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3118 | break; |
| 3119 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3120 | if (!IS_G4X(dev)) |
| 3121 | return -EINVAL; |
| 3122 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3123 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3124 | break; |
| 3125 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3126 | if (!IS_G4X(dev)) |
| 3127 | return -EINVAL; |
| 3128 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3129 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3130 | break; |
| 3131 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3132 | *val = 0; |
| 3133 | break; |
| 3134 | default: |
| 3135 | return -EINVAL; |
| 3136 | } |
| 3137 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3138 | /* |
| 3139 | * When the pipe CRC tap point is after the transcoders we need |
| 3140 | * to tweak symbol-level features to produce a deterministic series of |
| 3141 | * symbols for a given frame. We need to reset those features only once |
| 3142 | * a frame (instead of every nth symbol): |
| 3143 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3144 | * link (SDVO) |
| 3145 | * - DisplayPort scrambling: used for EMI reduction |
| 3146 | */ |
| 3147 | if (need_stable_symbols) { |
| 3148 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3149 | |
| 3150 | WARN_ON(!IS_G4X(dev)); |
| 3151 | |
| 3152 | I915_WRITE(PORT_DFT_I9XX, |
| 3153 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3154 | |
| 3155 | if (pipe == PIPE_A) |
| 3156 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3157 | else |
| 3158 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3159 | |
| 3160 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3161 | } |
| 3162 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3163 | return 0; |
| 3164 | } |
| 3165 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3166 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3167 | enum pipe pipe) |
| 3168 | { |
| 3169 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3170 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3171 | |
| 3172 | if (pipe == PIPE_A) |
| 3173 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3174 | else |
| 3175 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3176 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3177 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3178 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3179 | |
| 3180 | } |
| 3181 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3182 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3183 | enum pipe pipe) |
| 3184 | { |
| 3185 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3186 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3187 | |
| 3188 | if (pipe == PIPE_A) |
| 3189 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3190 | else |
| 3191 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3192 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3193 | |
| 3194 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3195 | I915_WRITE(PORT_DFT_I9XX, |
| 3196 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3197 | } |
| 3198 | } |
| 3199 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3200 | 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] | 3201 | uint32_t *val) |
| 3202 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3203 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3204 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3205 | |
| 3206 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3207 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3208 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 3209 | break; |
| 3210 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3211 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 3212 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3213 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3214 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 3215 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3216 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3217 | *val = 0; |
| 3218 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3219 | default: |
| 3220 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3221 | } |
| 3222 | |
| 3223 | return 0; |
| 3224 | } |
| 3225 | |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3226 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3227 | { |
| 3228 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3229 | struct intel_crtc *crtc = |
| 3230 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
| 3231 | |
| 3232 | drm_modeset_lock_all(dev); |
| 3233 | /* |
| 3234 | * If we use the eDP transcoder we need to make sure that we don't |
| 3235 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3236 | * relevant on hsw with pipe A when using the always-on power well |
| 3237 | * routing. |
| 3238 | */ |
| 3239 | if (crtc->config.cpu_transcoder == TRANSCODER_EDP && |
| 3240 | !crtc->config.pch_pfit.enabled) { |
| 3241 | crtc->config.pch_pfit.force_thru = true; |
| 3242 | |
| 3243 | intel_display_power_get(dev_priv, |
| 3244 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3245 | |
| 3246 | dev_priv->display.crtc_disable(&crtc->base); |
| 3247 | dev_priv->display.crtc_enable(&crtc->base); |
| 3248 | } |
| 3249 | drm_modeset_unlock_all(dev); |
| 3250 | } |
| 3251 | |
| 3252 | static void hsw_undo_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3253 | { |
| 3254 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3255 | struct intel_crtc *crtc = |
| 3256 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
| 3257 | |
| 3258 | drm_modeset_lock_all(dev); |
| 3259 | /* |
| 3260 | * If we use the eDP transcoder we need to make sure that we don't |
| 3261 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3262 | * relevant on hsw with pipe A when using the always-on power well |
| 3263 | * routing. |
| 3264 | */ |
| 3265 | if (crtc->config.pch_pfit.force_thru) { |
| 3266 | crtc->config.pch_pfit.force_thru = false; |
| 3267 | |
| 3268 | dev_priv->display.crtc_disable(&crtc->base); |
| 3269 | dev_priv->display.crtc_enable(&crtc->base); |
| 3270 | |
| 3271 | intel_display_power_put(dev_priv, |
| 3272 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3273 | } |
| 3274 | drm_modeset_unlock_all(dev); |
| 3275 | } |
| 3276 | |
| 3277 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3278 | enum pipe pipe, |
| 3279 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3280 | uint32_t *val) |
| 3281 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3282 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3283 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 3284 | |
| 3285 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3286 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3287 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 3288 | break; |
| 3289 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3290 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 3291 | break; |
| 3292 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3293 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3294 | hsw_trans_edp_pipe_A_crc_wa(dev); |
| 3295 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3296 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 3297 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3298 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3299 | *val = 0; |
| 3300 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3301 | default: |
| 3302 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3303 | } |
| 3304 | |
| 3305 | return 0; |
| 3306 | } |
| 3307 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3308 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 3309 | enum intel_pipe_crc_source source) |
| 3310 | { |
| 3311 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3312 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3313 | struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, |
| 3314 | pipe)); |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 3315 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3316 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3317 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3318 | if (pipe_crc->source == source) |
| 3319 | return 0; |
| 3320 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 3321 | /* forbid changing the source without going back to 'none' */ |
| 3322 | if (pipe_crc->source && source) |
| 3323 | return -EINVAL; |
| 3324 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3325 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3326 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3327 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3328 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3329 | else if (IS_VALLEYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3330 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3331 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3332 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3333 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3334 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3335 | |
| 3336 | if (ret != 0) |
| 3337 | return ret; |
| 3338 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3339 | /* none -> real source transition */ |
| 3340 | if (source) { |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3341 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 3342 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 3343 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3344 | pipe_crc->entries = kzalloc(sizeof(*pipe_crc->entries) * |
| 3345 | INTEL_PIPE_CRC_ENTRIES_NR, |
| 3346 | GFP_KERNEL); |
| 3347 | if (!pipe_crc->entries) |
| 3348 | return -ENOMEM; |
| 3349 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3350 | /* |
| 3351 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 3352 | * enabled and disabled dynamically based on package C states, |
| 3353 | * user space can't make reliable use of the CRCs, so let's just |
| 3354 | * completely disable it. |
| 3355 | */ |
| 3356 | hsw_disable_ips(crtc); |
| 3357 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3358 | spin_lock_irq(&pipe_crc->lock); |
| 3359 | pipe_crc->head = 0; |
| 3360 | pipe_crc->tail = 0; |
| 3361 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3362 | } |
| 3363 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3364 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3365 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3366 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 3367 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 3368 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3369 | /* real source -> none transition */ |
| 3370 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3371 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3372 | struct intel_crtc *crtc = |
| 3373 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3374 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3375 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 3376 | pipe_name(pipe)); |
| 3377 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3378 | drm_modeset_lock(&crtc->base.mutex, NULL); |
| 3379 | if (crtc->active) |
| 3380 | intel_wait_for_vblank(dev, pipe); |
| 3381 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 3382 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3383 | spin_lock_irq(&pipe_crc->lock); |
| 3384 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3385 | pipe_crc->entries = NULL; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3386 | spin_unlock_irq(&pipe_crc->lock); |
| 3387 | |
| 3388 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3389 | |
| 3390 | if (IS_G4X(dev)) |
| 3391 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3392 | else if (IS_VALLEYVIEW(dev)) |
| 3393 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3394 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3395 | hsw_undo_trans_edp_pipe_A_crc_wa(dev); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3396 | |
| 3397 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3398 | } |
| 3399 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3400 | return 0; |
| 3401 | } |
| 3402 | |
| 3403 | /* |
| 3404 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3405 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 3406 | * object: 'pipe' |
| 3407 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3408 | * source: (none | plane1 | plane2 | pf) |
| 3409 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 3410 | * |
| 3411 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3412 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 3413 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3414 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3415 | 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] | 3416 | { |
| 3417 | int n_words = 0; |
| 3418 | |
| 3419 | while (*buf) { |
| 3420 | char *end; |
| 3421 | |
| 3422 | /* skip leading white space */ |
| 3423 | buf = skip_spaces(buf); |
| 3424 | if (!*buf) |
| 3425 | break; /* end of buffer */ |
| 3426 | |
| 3427 | /* find end of word */ |
| 3428 | for (end = buf; *end && !isspace(*end); end++) |
| 3429 | ; |
| 3430 | |
| 3431 | if (n_words == max_words) { |
| 3432 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 3433 | max_words); |
| 3434 | return -EINVAL; /* ran out of words[] before bytes */ |
| 3435 | } |
| 3436 | |
| 3437 | if (*end) |
| 3438 | *end++ = '\0'; |
| 3439 | words[n_words++] = buf; |
| 3440 | buf = end; |
| 3441 | } |
| 3442 | |
| 3443 | return n_words; |
| 3444 | } |
| 3445 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3446 | enum intel_pipe_crc_object { |
| 3447 | PIPE_CRC_OBJECT_PIPE, |
| 3448 | }; |
| 3449 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3450 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3451 | "pipe", |
| 3452 | }; |
| 3453 | |
| 3454 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3455 | 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] | 3456 | { |
| 3457 | int i; |
| 3458 | |
| 3459 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 3460 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3461 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3462 | return 0; |
| 3463 | } |
| 3464 | |
| 3465 | return -EINVAL; |
| 3466 | } |
| 3467 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3468 | 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] | 3469 | { |
| 3470 | const char name = buf[0]; |
| 3471 | |
| 3472 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 3473 | return -EINVAL; |
| 3474 | |
| 3475 | *pipe = name - 'A'; |
| 3476 | |
| 3477 | return 0; |
| 3478 | } |
| 3479 | |
| 3480 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3481 | 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] | 3482 | { |
| 3483 | int i; |
| 3484 | |
| 3485 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 3486 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3487 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3488 | return 0; |
| 3489 | } |
| 3490 | |
| 3491 | return -EINVAL; |
| 3492 | } |
| 3493 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3494 | 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] | 3495 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3496 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3497 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3498 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3499 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3500 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3501 | enum intel_pipe_crc_source source; |
| 3502 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3503 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3504 | if (n_words != N_WORDS) { |
| 3505 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 3506 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3507 | return -EINVAL; |
| 3508 | } |
| 3509 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3510 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3511 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3512 | return -EINVAL; |
| 3513 | } |
| 3514 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3515 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3516 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 3517 | return -EINVAL; |
| 3518 | } |
| 3519 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3520 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3521 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3522 | return -EINVAL; |
| 3523 | } |
| 3524 | |
| 3525 | return pipe_crc_set_source(dev, pipe, source); |
| 3526 | } |
| 3527 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3528 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 3529 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3530 | { |
| 3531 | struct seq_file *m = file->private_data; |
| 3532 | struct drm_device *dev = m->private; |
| 3533 | char *tmpbuf; |
| 3534 | int ret; |
| 3535 | |
| 3536 | if (len == 0) |
| 3537 | return 0; |
| 3538 | |
| 3539 | if (len > PAGE_SIZE - 1) { |
| 3540 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 3541 | PAGE_SIZE); |
| 3542 | return -E2BIG; |
| 3543 | } |
| 3544 | |
| 3545 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 3546 | if (!tmpbuf) |
| 3547 | return -ENOMEM; |
| 3548 | |
| 3549 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 3550 | ret = -EFAULT; |
| 3551 | goto out; |
| 3552 | } |
| 3553 | tmpbuf[len] = '\0'; |
| 3554 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3555 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3556 | |
| 3557 | out: |
| 3558 | kfree(tmpbuf); |
| 3559 | if (ret < 0) |
| 3560 | return ret; |
| 3561 | |
| 3562 | *offp += len; |
| 3563 | return len; |
| 3564 | } |
| 3565 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3566 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3567 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3568 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3569 | .read = seq_read, |
| 3570 | .llseek = seq_lseek, |
| 3571 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3572 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3573 | }; |
| 3574 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3575 | static void wm_latency_show(struct seq_file *m, const uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3576 | { |
| 3577 | struct drm_device *dev = m->private; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 3578 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3579 | int level; |
| 3580 | |
| 3581 | drm_modeset_lock_all(dev); |
| 3582 | |
| 3583 | for (level = 0; level < num_levels; level++) { |
| 3584 | unsigned int latency = wm[level]; |
| 3585 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3586 | /* |
| 3587 | * - WM1+ latency values in 0.5us units |
| 3588 | * - latencies are in us on gen9 |
| 3589 | */ |
| 3590 | if (INTEL_INFO(dev)->gen >= 9) |
| 3591 | latency *= 10; |
| 3592 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3593 | latency *= 5; |
| 3594 | |
| 3595 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3596 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3597 | } |
| 3598 | |
| 3599 | drm_modeset_unlock_all(dev); |
| 3600 | } |
| 3601 | |
| 3602 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3603 | { |
| 3604 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3605 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3606 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3607 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3608 | if (INTEL_INFO(dev)->gen >= 9) |
| 3609 | latencies = dev_priv->wm.skl_latency; |
| 3610 | else |
| 3611 | latencies = to_i915(dev)->wm.pri_latency; |
| 3612 | |
| 3613 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3614 | |
| 3615 | return 0; |
| 3616 | } |
| 3617 | |
| 3618 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3619 | { |
| 3620 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3621 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3622 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3623 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3624 | if (INTEL_INFO(dev)->gen >= 9) |
| 3625 | latencies = dev_priv->wm.skl_latency; |
| 3626 | else |
| 3627 | latencies = to_i915(dev)->wm.spr_latency; |
| 3628 | |
| 3629 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3630 | |
| 3631 | return 0; |
| 3632 | } |
| 3633 | |
| 3634 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3635 | { |
| 3636 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3637 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3638 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3639 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3640 | if (INTEL_INFO(dev)->gen >= 9) |
| 3641 | latencies = dev_priv->wm.skl_latency; |
| 3642 | else |
| 3643 | latencies = to_i915(dev)->wm.cur_latency; |
| 3644 | |
| 3645 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3646 | |
| 3647 | return 0; |
| 3648 | } |
| 3649 | |
| 3650 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3651 | { |
| 3652 | struct drm_device *dev = inode->i_private; |
| 3653 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3654 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3655 | return -ENODEV; |
| 3656 | |
| 3657 | return single_open(file, pri_wm_latency_show, dev); |
| 3658 | } |
| 3659 | |
| 3660 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3661 | { |
| 3662 | struct drm_device *dev = inode->i_private; |
| 3663 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3664 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3665 | return -ENODEV; |
| 3666 | |
| 3667 | return single_open(file, spr_wm_latency_show, dev); |
| 3668 | } |
| 3669 | |
| 3670 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3671 | { |
| 3672 | struct drm_device *dev = inode->i_private; |
| 3673 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3674 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3675 | return -ENODEV; |
| 3676 | |
| 3677 | return single_open(file, cur_wm_latency_show, dev); |
| 3678 | } |
| 3679 | |
| 3680 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3681 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3682 | { |
| 3683 | struct seq_file *m = file->private_data; |
| 3684 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3685 | uint16_t new[8] = { 0 }; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 3686 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3687 | int level; |
| 3688 | int ret; |
| 3689 | char tmp[32]; |
| 3690 | |
| 3691 | if (len >= sizeof(tmp)) |
| 3692 | return -EINVAL; |
| 3693 | |
| 3694 | if (copy_from_user(tmp, ubuf, len)) |
| 3695 | return -EFAULT; |
| 3696 | |
| 3697 | tmp[len] = '\0'; |
| 3698 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3699 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3700 | &new[0], &new[1], &new[2], &new[3], |
| 3701 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3702 | if (ret != num_levels) |
| 3703 | return -EINVAL; |
| 3704 | |
| 3705 | drm_modeset_lock_all(dev); |
| 3706 | |
| 3707 | for (level = 0; level < num_levels; level++) |
| 3708 | wm[level] = new[level]; |
| 3709 | |
| 3710 | drm_modeset_unlock_all(dev); |
| 3711 | |
| 3712 | return len; |
| 3713 | } |
| 3714 | |
| 3715 | |
| 3716 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3717 | size_t len, loff_t *offp) |
| 3718 | { |
| 3719 | struct seq_file *m = file->private_data; |
| 3720 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3721 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3722 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3723 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3724 | if (INTEL_INFO(dev)->gen >= 9) |
| 3725 | latencies = dev_priv->wm.skl_latency; |
| 3726 | else |
| 3727 | latencies = to_i915(dev)->wm.pri_latency; |
| 3728 | |
| 3729 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3730 | } |
| 3731 | |
| 3732 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3733 | size_t len, loff_t *offp) |
| 3734 | { |
| 3735 | struct seq_file *m = file->private_data; |
| 3736 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3737 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3738 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3739 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3740 | if (INTEL_INFO(dev)->gen >= 9) |
| 3741 | latencies = dev_priv->wm.skl_latency; |
| 3742 | else |
| 3743 | latencies = to_i915(dev)->wm.spr_latency; |
| 3744 | |
| 3745 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3749 | size_t len, loff_t *offp) |
| 3750 | { |
| 3751 | struct seq_file *m = file->private_data; |
| 3752 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3753 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3754 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3755 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3756 | if (INTEL_INFO(dev)->gen >= 9) |
| 3757 | latencies = dev_priv->wm.skl_latency; |
| 3758 | else |
| 3759 | latencies = to_i915(dev)->wm.cur_latency; |
| 3760 | |
| 3761 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3762 | } |
| 3763 | |
| 3764 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3765 | .owner = THIS_MODULE, |
| 3766 | .open = pri_wm_latency_open, |
| 3767 | .read = seq_read, |
| 3768 | .llseek = seq_lseek, |
| 3769 | .release = single_release, |
| 3770 | .write = pri_wm_latency_write |
| 3771 | }; |
| 3772 | |
| 3773 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3774 | .owner = THIS_MODULE, |
| 3775 | .open = spr_wm_latency_open, |
| 3776 | .read = seq_read, |
| 3777 | .llseek = seq_lseek, |
| 3778 | .release = single_release, |
| 3779 | .write = spr_wm_latency_write |
| 3780 | }; |
| 3781 | |
| 3782 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3783 | .owner = THIS_MODULE, |
| 3784 | .open = cur_wm_latency_open, |
| 3785 | .read = seq_read, |
| 3786 | .llseek = seq_lseek, |
| 3787 | .release = single_release, |
| 3788 | .write = cur_wm_latency_write |
| 3789 | }; |
| 3790 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3791 | static int |
| 3792 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3793 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3794 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3795 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3796 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3797 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3798 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3799 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3800 | } |
| 3801 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3802 | static int |
| 3803 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3804 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3805 | struct drm_device *dev = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3806 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3807 | |
| 3808 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3809 | |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 3810 | i915_handle_error(dev, val, |
| 3811 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3812 | |
| 3813 | intel_runtime_pm_put(dev_priv); |
| 3814 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3815 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3816 | } |
| 3817 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3818 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3819 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3820 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3821 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3822 | static int |
| 3823 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3824 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3825 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3826 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3827 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3828 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3829 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3830 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3831 | } |
| 3832 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3833 | static int |
| 3834 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3835 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3836 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3837 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3838 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3839 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3840 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3841 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 3842 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3843 | if (ret) |
| 3844 | return ret; |
| 3845 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 3846 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3847 | mutex_unlock(&dev->struct_mutex); |
| 3848 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3849 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3850 | } |
| 3851 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3852 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 3853 | i915_ring_stop_get, i915_ring_stop_set, |
| 3854 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 3855 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3856 | static int |
| 3857 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 3858 | { |
| 3859 | struct drm_device *dev = data; |
| 3860 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3861 | |
| 3862 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 3863 | return 0; |
| 3864 | } |
| 3865 | |
| 3866 | static int |
| 3867 | i915_ring_missed_irq_set(void *data, u64 val) |
| 3868 | { |
| 3869 | struct drm_device *dev = data; |
| 3870 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3871 | int ret; |
| 3872 | |
| 3873 | /* Lock against concurrent debugfs callers */ |
| 3874 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3875 | if (ret) |
| 3876 | return ret; |
| 3877 | dev_priv->gpu_error.missed_irq_rings = val; |
| 3878 | mutex_unlock(&dev->struct_mutex); |
| 3879 | |
| 3880 | return 0; |
| 3881 | } |
| 3882 | |
| 3883 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 3884 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 3885 | "0x%08llx\n"); |
| 3886 | |
| 3887 | static int |
| 3888 | i915_ring_test_irq_get(void *data, u64 *val) |
| 3889 | { |
| 3890 | struct drm_device *dev = data; |
| 3891 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3892 | |
| 3893 | *val = dev_priv->gpu_error.test_irq_rings; |
| 3894 | |
| 3895 | return 0; |
| 3896 | } |
| 3897 | |
| 3898 | static int |
| 3899 | i915_ring_test_irq_set(void *data, u64 val) |
| 3900 | { |
| 3901 | struct drm_device *dev = data; |
| 3902 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3903 | int ret; |
| 3904 | |
| 3905 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 3906 | |
| 3907 | /* Lock against concurrent debugfs callers */ |
| 3908 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3909 | if (ret) |
| 3910 | return ret; |
| 3911 | |
| 3912 | dev_priv->gpu_error.test_irq_rings = val; |
| 3913 | mutex_unlock(&dev->struct_mutex); |
| 3914 | |
| 3915 | return 0; |
| 3916 | } |
| 3917 | |
| 3918 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 3919 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 3920 | "0x%08llx\n"); |
| 3921 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3922 | #define DROP_UNBOUND 0x1 |
| 3923 | #define DROP_BOUND 0x2 |
| 3924 | #define DROP_RETIRE 0x4 |
| 3925 | #define DROP_ACTIVE 0x8 |
| 3926 | #define DROP_ALL (DROP_UNBOUND | \ |
| 3927 | DROP_BOUND | \ |
| 3928 | DROP_RETIRE | \ |
| 3929 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3930 | static int |
| 3931 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3932 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3933 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3934 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3935 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3936 | } |
| 3937 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3938 | static int |
| 3939 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3940 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3941 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3942 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3943 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3944 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 3945 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3946 | |
| 3947 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 3948 | * on ioctls on -EAGAIN. */ |
| 3949 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3950 | if (ret) |
| 3951 | return ret; |
| 3952 | |
| 3953 | if (val & DROP_ACTIVE) { |
| 3954 | ret = i915_gpu_idle(dev); |
| 3955 | if (ret) |
| 3956 | goto unlock; |
| 3957 | } |
| 3958 | |
| 3959 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 3960 | i915_gem_retire_requests(dev); |
| 3961 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3962 | if (val & DROP_BOUND) |
| 3963 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 3964 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3965 | if (val & DROP_UNBOUND) |
| 3966 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3967 | |
| 3968 | unlock: |
| 3969 | mutex_unlock(&dev->struct_mutex); |
| 3970 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3971 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3972 | } |
| 3973 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3974 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 3975 | i915_drop_caches_get, i915_drop_caches_set, |
| 3976 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3977 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3978 | static int |
| 3979 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3980 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3981 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3982 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3983 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3984 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 3985 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3986 | return -ENODEV; |
| 3987 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3988 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3989 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3990 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3991 | if (ret) |
| 3992 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3993 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3994 | if (IS_VALLEYVIEW(dev)) |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3995 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3996 | else |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3997 | *val = dev_priv->rps.max_freq_softlimit * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3998 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3999 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4000 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4001 | } |
| 4002 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4003 | static int |
| 4004 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4005 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4006 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4007 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4008 | u32 rp_state_cap, hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4009 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4010 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4011 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4012 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4013 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4014 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4015 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4016 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4017 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4018 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4019 | if (ret) |
| 4020 | return ret; |
| 4021 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4022 | /* |
| 4023 | * Turbo will still be enabled, but won't go above the set value. |
| 4024 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4025 | if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 4026 | val = vlv_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4027 | |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 4028 | hw_max = dev_priv->rps.max_freq; |
| 4029 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4030 | } else { |
| 4031 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4032 | |
| 4033 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4034 | hw_max = dev_priv->rps.max_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4035 | hw_min = (rp_state_cap >> 16) & 0xff; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4036 | } |
| 4037 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4038 | if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4039 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4040 | return -EINVAL; |
| 4041 | } |
| 4042 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4043 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4044 | |
| 4045 | if (IS_VALLEYVIEW(dev)) |
| 4046 | valleyview_set_rps(dev, val); |
| 4047 | else |
| 4048 | gen6_set_rps(dev, val); |
| 4049 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4050 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4051 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4052 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4053 | } |
| 4054 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4055 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4056 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4057 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4058 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4059 | static int |
| 4060 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4061 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4062 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4063 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4064 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4065 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4066 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4067 | return -ENODEV; |
| 4068 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4069 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4070 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4071 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4072 | if (ret) |
| 4073 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4074 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4075 | if (IS_VALLEYVIEW(dev)) |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4076 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4077 | else |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4078 | *val = dev_priv->rps.min_freq_softlimit * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4079 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4080 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4081 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4082 | } |
| 4083 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4084 | static int |
| 4085 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4086 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4087 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4088 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4089 | u32 rp_state_cap, hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4090 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4091 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4092 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4093 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4094 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4095 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4096 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4097 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4098 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4099 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4100 | if (ret) |
| 4101 | return ret; |
| 4102 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4103 | /* |
| 4104 | * Turbo will still be enabled, but won't go below the set value. |
| 4105 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4106 | if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 4107 | val = vlv_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4108 | |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 4109 | hw_max = dev_priv->rps.max_freq; |
| 4110 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4111 | } else { |
| 4112 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4113 | |
| 4114 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4115 | hw_max = dev_priv->rps.max_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4116 | hw_min = (rp_state_cap >> 16) & 0xff; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4117 | } |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4118 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4119 | if (val < hw_min || val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4120 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4121 | return -EINVAL; |
| 4122 | } |
| 4123 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4124 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4125 | |
| 4126 | if (IS_VALLEYVIEW(dev)) |
| 4127 | valleyview_set_rps(dev, val); |
| 4128 | else |
| 4129 | gen6_set_rps(dev, val); |
| 4130 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4131 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4132 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4133 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4134 | } |
| 4135 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4136 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4137 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4138 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4139 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4140 | static int |
| 4141 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4142 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4143 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4144 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4145 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4146 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4147 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4148 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4149 | return -ENODEV; |
| 4150 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4151 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4152 | if (ret) |
| 4153 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4154 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4155 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4156 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4157 | |
| 4158 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4159 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 4160 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4161 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4162 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4163 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4164 | } |
| 4165 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4166 | static int |
| 4167 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4168 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4169 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4170 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4171 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4172 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4173 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4174 | return -ENODEV; |
| 4175 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4176 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4177 | return -EINVAL; |
| 4178 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4179 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4180 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4181 | |
| 4182 | /* Update the cache sharing policy here as well */ |
| 4183 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4184 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4185 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4186 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4187 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4188 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4189 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4190 | } |
| 4191 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4192 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4193 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4194 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4195 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4196 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4197 | { |
| 4198 | struct drm_device *dev = inode->i_private; |
| 4199 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4200 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4201 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4202 | return 0; |
| 4203 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 4204 | gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4205 | |
| 4206 | return 0; |
| 4207 | } |
| 4208 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4209 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4210 | { |
| 4211 | struct drm_device *dev = inode->i_private; |
| 4212 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4213 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4214 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4215 | return 0; |
| 4216 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 4217 | gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4218 | |
| 4219 | return 0; |
| 4220 | } |
| 4221 | |
| 4222 | static const struct file_operations i915_forcewake_fops = { |
| 4223 | .owner = THIS_MODULE, |
| 4224 | .open = i915_forcewake_open, |
| 4225 | .release = i915_forcewake_release, |
| 4226 | }; |
| 4227 | |
| 4228 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 4229 | { |
| 4230 | struct drm_device *dev = minor->dev; |
| 4231 | struct dentry *ent; |
| 4232 | |
| 4233 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4234 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4235 | root, dev, |
| 4236 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4237 | if (!ent) |
| 4238 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4239 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4240 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4241 | } |
| 4242 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4243 | static int i915_debugfs_create(struct dentry *root, |
| 4244 | struct drm_minor *minor, |
| 4245 | const char *name, |
| 4246 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4247 | { |
| 4248 | struct drm_device *dev = minor->dev; |
| 4249 | struct dentry *ent; |
| 4250 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4251 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4252 | S_IRUGO | S_IWUSR, |
| 4253 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4254 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4255 | if (!ent) |
| 4256 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4257 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4258 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4259 | } |
| 4260 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4261 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4262 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4263 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4264 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 4265 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 4266 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 4267 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4268 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4269 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4270 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4271 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4272 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4273 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 4274 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 4275 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 4276 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 4277 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4278 | {"i915_frequency_info", i915_frequency_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4279 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4280 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4281 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4282 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4283 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4284 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4285 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4286 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4287 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4288 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 4289 | {"i915_execlists", i915_execlists, 0}, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4290 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4291 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4292 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4293 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4294 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4295 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4296 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 4297 | {"i915_pc8_status", i915_pc8_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4298 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4299 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4300 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4301 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed958 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4302 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4303 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4304 | {"i915_ddb_info", i915_ddb_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4305 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4306 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4307 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4308 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4309 | const char *name; |
| 4310 | const struct file_operations *fops; |
| 4311 | } i915_debugfs_files[] = { |
| 4312 | {"i915_wedged", &i915_wedged_fops}, |
| 4313 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4314 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4315 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 4316 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4317 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4318 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4319 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 4320 | {"i915_error_state", &i915_error_state_fops}, |
| 4321 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4322 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4323 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4324 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4325 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 4326 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4327 | }; |
| 4328 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4329 | void intel_display_crc_init(struct drm_device *dev) |
| 4330 | { |
| 4331 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 4332 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4333 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4334 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 4335 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4336 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4337 | pipe_crc->opened = false; |
| 4338 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4339 | init_waitqueue_head(&pipe_crc->wq); |
| 4340 | } |
| 4341 | } |
| 4342 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4343 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4344 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4345 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4346 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4347 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 4348 | if (ret) |
| 4349 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4350 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4351 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 4352 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 4353 | if (ret) |
| 4354 | return ret; |
| 4355 | } |
| 4356 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4357 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4358 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 4359 | i915_debugfs_files[i].name, |
| 4360 | i915_debugfs_files[i].fops); |
| 4361 | if (ret) |
| 4362 | return ret; |
| 4363 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4364 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4365 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4366 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4367 | minor->debugfs_root, minor); |
| 4368 | } |
| 4369 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4370 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4371 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4372 | int i; |
| 4373 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4374 | drm_debugfs_remove_files(i915_debugfs_list, |
| 4375 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4376 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4377 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 4378 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4379 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 4380 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4381 | struct drm_info_list *info_list = |
| 4382 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 4383 | |
| 4384 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4385 | } |
| 4386 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4387 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4388 | struct drm_info_list *info_list = |
| 4389 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 4390 | |
| 4391 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4392 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4393 | } |