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