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"); |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 156 | seq_printf(m, "gtt offset: %08llx, size: %08llx, type: %u)", |
Tvrtko Ursulin | fe14d5f | 2014-12-10 17:27:58 +0000 | [diff] [blame] | 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) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 161 | seq_printf(m, " (stolen: %08llx)", 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; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1227 | struct drm_device *dev = node->minor->dev; |
| 1228 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1229 | struct intel_engine_cs *ring; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1230 | u64 acthd[I915_NUM_RINGS]; |
| 1231 | u32 seqno[I915_NUM_RINGS]; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1232 | int i; |
| 1233 | |
| 1234 | if (!i915.enable_hangcheck) { |
| 1235 | seq_printf(m, "Hangcheck disabled\n"); |
| 1236 | return 0; |
| 1237 | } |
| 1238 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1239 | intel_runtime_pm_get(dev_priv); |
| 1240 | |
| 1241 | for_each_ring(ring, dev_priv, i) { |
| 1242 | seqno[i] = ring->get_seqno(ring, false); |
| 1243 | acthd[i] = intel_ring_get_active_head(ring); |
| 1244 | } |
| 1245 | |
| 1246 | intel_runtime_pm_put(dev_priv); |
| 1247 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1248 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1249 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1250 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1251 | jiffies)); |
| 1252 | } else |
| 1253 | seq_printf(m, "Hangcheck inactive\n"); |
| 1254 | |
| 1255 | for_each_ring(ring, dev_priv, i) { |
| 1256 | seq_printf(m, "%s:\n", ring->name); |
| 1257 | seq_printf(m, "\tseqno = %x [current %x]\n", |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1258 | ring->hangcheck.seqno, seqno[i]); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1259 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
| 1260 | (long long)ring->hangcheck.acthd, |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1261 | (long long)acthd[i]); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1262 | seq_printf(m, "\tmax ACTHD = 0x%08llx\n", |
| 1263 | (long long)ring->hangcheck.max_acthd); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1264 | seq_printf(m, "\tscore = %d\n", ring->hangcheck.score); |
| 1265 | seq_printf(m, "\taction = %d\n", ring->hangcheck.action); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | return 0; |
| 1269 | } |
| 1270 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1271 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1272 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1273 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1274 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1275 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1276 | u32 rgvmodectl, rstdbyctl; |
| 1277 | u16 crstandvid; |
| 1278 | int ret; |
| 1279 | |
| 1280 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1281 | if (ret) |
| 1282 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1283 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1284 | |
| 1285 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1286 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1287 | crstandvid = I915_READ16(CRSTANDVID); |
| 1288 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1289 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1290 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1291 | |
| 1292 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1293 | "yes" : "no"); |
| 1294 | seq_printf(m, "Boost freq: %d\n", |
| 1295 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1296 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1297 | seq_printf(m, "HW control enabled: %s\n", |
| 1298 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1299 | seq_printf(m, "SW control enabled: %s\n", |
| 1300 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1301 | seq_printf(m, "Gated voltage change: %s\n", |
| 1302 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1303 | seq_printf(m, "Starting frequency: P%d\n", |
| 1304 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1305 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1306 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1307 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1308 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1309 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1310 | seq_printf(m, "Render standby enabled: %s\n", |
| 1311 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1312 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1313 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1314 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1315 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1316 | break; |
| 1317 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1318 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1319 | break; |
| 1320 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1321 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1322 | break; |
| 1323 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1324 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1325 | break; |
| 1326 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1327 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1328 | break; |
| 1329 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1330 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1331 | break; |
| 1332 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1333 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1334 | break; |
| 1335 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1336 | |
| 1337 | return 0; |
| 1338 | } |
| 1339 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1340 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1341 | { |
| 1342 | struct drm_info_node *node = m->private; |
| 1343 | struct drm_device *dev = node->minor->dev; |
| 1344 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1345 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1346 | int i; |
| 1347 | |
| 1348 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1349 | for_each_fw_domain(fw_domain, dev_priv, i) { |
| 1350 | seq_printf(m, "%s.wake_count = %u\n", |
Mika Kuoppala | 05a2fb1 | 2015-01-19 16:20:43 +0200 | [diff] [blame] | 1351 | intel_uncore_forcewake_domain_to_str(i), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1352 | fw_domain->wake_count); |
| 1353 | } |
| 1354 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1355 | |
| 1356 | return 0; |
| 1357 | } |
| 1358 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1359 | static int vlv_drpc_info(struct seq_file *m) |
| 1360 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1361 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1362 | struct drm_device *dev = node->minor->dev; |
| 1363 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1364 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1365 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1366 | intel_runtime_pm_get(dev_priv); |
| 1367 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1368 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1369 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1370 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1371 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1372 | intel_runtime_pm_put(dev_priv); |
| 1373 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1374 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1375 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1376 | seq_printf(m, "Turbo enabled: %s\n", |
| 1377 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1378 | seq_printf(m, "HW control enabled: %s\n", |
| 1379 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1380 | seq_printf(m, "SW control enabled: %s\n", |
| 1381 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1382 | GEN6_RP_MEDIA_SW_MODE)); |
| 1383 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1384 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1385 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1386 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1387 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1388 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1389 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1390 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1391 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1392 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1393 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1394 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1395 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1396 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1397 | } |
| 1398 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1399 | static int gen6_drpc_info(struct seq_file *m) |
| 1400 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1401 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1402 | struct drm_device *dev = node->minor->dev; |
| 1403 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1404 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1405 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1406 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1407 | |
| 1408 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1409 | if (ret) |
| 1410 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1411 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1412 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1413 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1414 | 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] | 1415 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1416 | |
| 1417 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1418 | seq_puts(m, "RC information inaccurate because somebody " |
| 1419 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1420 | } else { |
| 1421 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1422 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1423 | udelay(10); |
| 1424 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1425 | } |
| 1426 | |
| 1427 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1428 | 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] | 1429 | |
| 1430 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1431 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1432 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1433 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1434 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1435 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1436 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1437 | intel_runtime_pm_put(dev_priv); |
| 1438 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1439 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1440 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1441 | seq_printf(m, "HW control enabled: %s\n", |
| 1442 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1443 | seq_printf(m, "SW control enabled: %s\n", |
| 1444 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1445 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1446 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1447 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1448 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1449 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1450 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1451 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1452 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1453 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1454 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1455 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1456 | case GEN6_RC0: |
| 1457 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1458 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1459 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1460 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1461 | break; |
| 1462 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1463 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1464 | break; |
| 1465 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1466 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1467 | break; |
| 1468 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1469 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1470 | break; |
| 1471 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1472 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1473 | break; |
| 1474 | } |
| 1475 | |
| 1476 | seq_printf(m, "Core Power Down: %s\n", |
| 1477 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1478 | |
| 1479 | /* Not exactly sure what this is */ |
| 1480 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1481 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1482 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1483 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1484 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1485 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1486 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1487 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1488 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1489 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1490 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1491 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1492 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1493 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1494 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1495 | return 0; |
| 1496 | } |
| 1497 | |
| 1498 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1499 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1500 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1501 | struct drm_device *dev = node->minor->dev; |
| 1502 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1503 | if (IS_VALLEYVIEW(dev)) |
| 1504 | return vlv_drpc_info(m); |
Vedang Patel | ac66cf4 | 2014-08-26 10:42:51 -0700 | [diff] [blame] | 1505 | else if (INTEL_INFO(dev)->gen >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1506 | return gen6_drpc_info(m); |
| 1507 | else |
| 1508 | return ironlake_drpc_info(m); |
| 1509 | } |
| 1510 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1511 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1512 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1513 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1514 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1515 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1516 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1517 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1518 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1519 | return 0; |
| 1520 | } |
| 1521 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1522 | intel_runtime_pm_get(dev_priv); |
| 1523 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1524 | if (intel_fbc_enabled(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1525 | seq_puts(m, "FBC enabled\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1526 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1527 | seq_puts(m, "FBC disabled: "); |
Ben Widawsky | 5c3fe8b | 2013-06-27 16:30:21 -0700 | [diff] [blame] | 1528 | switch (dev_priv->fbc.no_fbc_reason) { |
Chris Wilson | 29ebf90 | 2013-07-27 17:23:55 +0100 | [diff] [blame] | 1529 | case FBC_OK: |
| 1530 | seq_puts(m, "FBC actived, but currently disabled in hardware"); |
| 1531 | break; |
| 1532 | case FBC_UNSUPPORTED: |
| 1533 | seq_puts(m, "unsupported by this chipset"); |
| 1534 | break; |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1535 | case FBC_NO_OUTPUT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1536 | seq_puts(m, "no outputs"); |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1537 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1538 | case FBC_STOLEN_TOO_SMALL: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1539 | seq_puts(m, "not enough stolen memory"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1540 | break; |
| 1541 | case FBC_UNSUPPORTED_MODE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1542 | seq_puts(m, "mode not supported"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1543 | break; |
| 1544 | case FBC_MODE_TOO_LARGE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1545 | seq_puts(m, "mode too large"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1546 | break; |
| 1547 | case FBC_BAD_PLANE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1548 | seq_puts(m, "FBC unsupported on plane"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1549 | break; |
| 1550 | case FBC_NOT_TILED: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1551 | seq_puts(m, "scanout buffer not tiled"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1552 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1553 | case FBC_MULTIPLE_PIPES: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1554 | seq_puts(m, "multiple pipes are enabled"); |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1555 | break; |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1556 | case FBC_MODULE_PARAM: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1557 | seq_puts(m, "disabled per module param (default off)"); |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1558 | break; |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1559 | case FBC_CHIP_DEFAULT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1560 | seq_puts(m, "disabled per chip default"); |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1561 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1562 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1563 | seq_puts(m, "unknown reason"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1564 | } |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1565 | seq_putc(m, '\n'); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1566 | } |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1567 | |
| 1568 | intel_runtime_pm_put(dev_priv); |
| 1569 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1570 | return 0; |
| 1571 | } |
| 1572 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1573 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1574 | { |
| 1575 | struct drm_device *dev = data; |
| 1576 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1577 | |
| 1578 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1579 | return -ENODEV; |
| 1580 | |
| 1581 | drm_modeset_lock_all(dev); |
| 1582 | *val = dev_priv->fbc.false_color; |
| 1583 | drm_modeset_unlock_all(dev); |
| 1584 | |
| 1585 | return 0; |
| 1586 | } |
| 1587 | |
| 1588 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1589 | { |
| 1590 | struct drm_device *dev = data; |
| 1591 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1592 | u32 reg; |
| 1593 | |
| 1594 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1595 | return -ENODEV; |
| 1596 | |
| 1597 | drm_modeset_lock_all(dev); |
| 1598 | |
| 1599 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1600 | dev_priv->fbc.false_color = val; |
| 1601 | |
| 1602 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1603 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1604 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1605 | |
| 1606 | drm_modeset_unlock_all(dev); |
| 1607 | return 0; |
| 1608 | } |
| 1609 | |
| 1610 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1611 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1612 | "%llu\n"); |
| 1613 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1614 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1615 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1616 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1617 | struct drm_device *dev = node->minor->dev; |
| 1618 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1619 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1620 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1621 | seq_puts(m, "not supported\n"); |
| 1622 | return 0; |
| 1623 | } |
| 1624 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1625 | intel_runtime_pm_get(dev_priv); |
| 1626 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1627 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1628 | yesno(i915.enable_ips)); |
| 1629 | |
| 1630 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1631 | seq_puts(m, "Currently: unknown\n"); |
| 1632 | } else { |
| 1633 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1634 | seq_puts(m, "Currently: enabled\n"); |
| 1635 | else |
| 1636 | seq_puts(m, "Currently: disabled\n"); |
| 1637 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1638 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1639 | intel_runtime_pm_put(dev_priv); |
| 1640 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1641 | return 0; |
| 1642 | } |
| 1643 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1644 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1645 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1646 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1647 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1648 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1649 | bool sr_enabled = false; |
| 1650 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1651 | intel_runtime_pm_get(dev_priv); |
| 1652 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1653 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1654 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1655 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1656 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1657 | else if (IS_I915GM(dev)) |
| 1658 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1659 | else if (IS_PINEVIEW(dev)) |
| 1660 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1661 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1662 | intel_runtime_pm_put(dev_priv); |
| 1663 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1664 | seq_printf(m, "self-refresh: %s\n", |
| 1665 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1666 | |
| 1667 | return 0; |
| 1668 | } |
| 1669 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1670 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1671 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1672 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1673 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1674 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1675 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1676 | int ret; |
| 1677 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1678 | if (!IS_GEN5(dev)) |
| 1679 | return -ENODEV; |
| 1680 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1681 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1682 | if (ret) |
| 1683 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1684 | |
| 1685 | temp = i915_mch_val(dev_priv); |
| 1686 | chipset = i915_chipset_val(dev_priv); |
| 1687 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1688 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1689 | |
| 1690 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1691 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1692 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1693 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1694 | |
| 1695 | return 0; |
| 1696 | } |
| 1697 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1698 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1699 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1700 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1701 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1702 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1703 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1704 | int gpu_freq, ia_freq; |
| 1705 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1706 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1707 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1708 | return 0; |
| 1709 | } |
| 1710 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1711 | intel_runtime_pm_get(dev_priv); |
| 1712 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1713 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1714 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1715 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1716 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1717 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1718 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1719 | 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] | 1720 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1721 | for (gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1722 | gpu_freq <= dev_priv->rps.max_freq_softlimit; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1723 | gpu_freq++) { |
Ben Widawsky | 42c0526 | 2012-09-26 10:34:00 -0700 | [diff] [blame] | 1724 | ia_freq = gpu_freq; |
| 1725 | sandybridge_pcode_read(dev_priv, |
| 1726 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1727 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1728 | 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] | 1729 | intel_gpu_freq(dev_priv, gpu_freq), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1730 | ((ia_freq >> 0) & 0xff) * 100, |
| 1731 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1732 | } |
| 1733 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1734 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1735 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1736 | out: |
| 1737 | intel_runtime_pm_put(dev_priv); |
| 1738 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1739 | } |
| 1740 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1741 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1742 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1743 | struct drm_info_node *node = m->private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1744 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1745 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1746 | struct intel_opregion *opregion = &dev_priv->opregion; |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1747 | void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1748 | int ret; |
| 1749 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1750 | if (data == NULL) |
| 1751 | return -ENOMEM; |
| 1752 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1753 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1754 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1755 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1756 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1757 | if (opregion->header) { |
| 1758 | memcpy_fromio(data, opregion->header, OPREGION_SIZE); |
| 1759 | seq_write(m, data, OPREGION_SIZE); |
| 1760 | } |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1761 | |
| 1762 | mutex_unlock(&dev->struct_mutex); |
| 1763 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1764 | out: |
| 1765 | kfree(data); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1766 | return 0; |
| 1767 | } |
| 1768 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1769 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1770 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1771 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1772 | struct drm_device *dev = node->minor->dev; |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1773 | struct intel_fbdev *ifbdev = NULL; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1774 | struct intel_framebuffer *fb; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1775 | |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1776 | #ifdef CONFIG_DRM_I915_FBDEV |
| 1777 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1778 | |
| 1779 | ifbdev = dev_priv->fbdev; |
| 1780 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1781 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1782 | 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] | 1783 | fb->base.width, |
| 1784 | fb->base.height, |
| 1785 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1786 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1787 | fb->base.modifier[0], |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1788 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1789 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1790 | seq_putc(m, '\n'); |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1791 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1792 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1793 | mutex_lock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1794 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
Daniel Vetter | 131a56d | 2013-10-17 14:35:31 +0200 | [diff] [blame] | 1795 | if (ifbdev && &fb->base == ifbdev->helper.fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1796 | continue; |
| 1797 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1798 | 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] | 1799 | fb->base.width, |
| 1800 | fb->base.height, |
| 1801 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1802 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1803 | fb->base.modifier[0], |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1804 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1805 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1806 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1807 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1808 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1809 | |
| 1810 | return 0; |
| 1811 | } |
| 1812 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1813 | static void describe_ctx_ringbuf(struct seq_file *m, |
| 1814 | struct intel_ringbuffer *ringbuf) |
| 1815 | { |
| 1816 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
| 1817 | ringbuf->space, ringbuf->head, ringbuf->tail, |
| 1818 | ringbuf->last_retired_head); |
| 1819 | } |
| 1820 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1821 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1822 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1823 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1824 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1825 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1826 | struct intel_engine_cs *ring; |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1827 | struct intel_context *ctx; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1828 | int ret, i; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1829 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1830 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1831 | if (ret) |
| 1832 | return ret; |
| 1833 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1834 | if (dev_priv->ips.pwrctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1835 | seq_puts(m, "power context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1836 | describe_obj(m, dev_priv->ips.pwrctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1837 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1838 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1839 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1840 | if (dev_priv->ips.renderctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1841 | seq_puts(m, "render context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1842 | describe_obj(m, dev_priv->ips.renderctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1843 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1844 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1845 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1846 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1847 | if (!i915.enable_execlists && |
| 1848 | ctx->legacy_hw_ctx.rcs_state == NULL) |
Chris Wilson | b77f699 | 2014-04-30 08:30:00 +0100 | [diff] [blame] | 1849 | continue; |
| 1850 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1851 | seq_puts(m, "HW context "); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 1852 | describe_ctx(m, ctx); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1853 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1854 | if (ring->default_context == ctx) |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1855 | seq_printf(m, "(default context %s) ", |
| 1856 | ring->name); |
| 1857 | } |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1858 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1859 | if (i915.enable_execlists) { |
| 1860 | seq_putc(m, '\n'); |
| 1861 | for_each_ring(ring, dev_priv, i) { |
| 1862 | struct drm_i915_gem_object *ctx_obj = |
| 1863 | ctx->engine[i].state; |
| 1864 | struct intel_ringbuffer *ringbuf = |
| 1865 | ctx->engine[i].ringbuf; |
| 1866 | |
| 1867 | seq_printf(m, "%s: ", ring->name); |
| 1868 | if (ctx_obj) |
| 1869 | describe_obj(m, ctx_obj); |
| 1870 | if (ringbuf) |
| 1871 | describe_ctx_ringbuf(m, ringbuf); |
| 1872 | seq_putc(m, '\n'); |
| 1873 | } |
| 1874 | } else { |
| 1875 | describe_obj(m, ctx->legacy_hw_ctx.rcs_state); |
| 1876 | } |
| 1877 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1878 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1879 | } |
| 1880 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1881 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1882 | |
| 1883 | return 0; |
| 1884 | } |
| 1885 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1886 | static void i915_dump_lrc_obj(struct seq_file *m, |
| 1887 | struct intel_engine_cs *ring, |
| 1888 | struct drm_i915_gem_object *ctx_obj) |
| 1889 | { |
| 1890 | struct page *page; |
| 1891 | uint32_t *reg_state; |
| 1892 | int j; |
| 1893 | unsigned long ggtt_offset = 0; |
| 1894 | |
| 1895 | if (ctx_obj == NULL) { |
| 1896 | seq_printf(m, "Context on %s with no gem object\n", |
| 1897 | ring->name); |
| 1898 | return; |
| 1899 | } |
| 1900 | |
| 1901 | seq_printf(m, "CONTEXT: %s %u\n", ring->name, |
| 1902 | intel_execlists_ctx_id(ctx_obj)); |
| 1903 | |
| 1904 | if (!i915_gem_obj_ggtt_bound(ctx_obj)) |
| 1905 | seq_puts(m, "\tNot bound in GGTT\n"); |
| 1906 | else |
| 1907 | ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj); |
| 1908 | |
| 1909 | if (i915_gem_object_get_pages(ctx_obj)) { |
| 1910 | seq_puts(m, "\tFailed to get pages for context object\n"); |
| 1911 | return; |
| 1912 | } |
| 1913 | |
| 1914 | page = i915_gem_object_get_page(ctx_obj, 1); |
| 1915 | if (!WARN_ON(page == NULL)) { |
| 1916 | reg_state = kmap_atomic(page); |
| 1917 | |
| 1918 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 1919 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1920 | ggtt_offset + 4096 + (j * 4), |
| 1921 | reg_state[j], reg_state[j + 1], |
| 1922 | reg_state[j + 2], reg_state[j + 3]); |
| 1923 | } |
| 1924 | kunmap_atomic(reg_state); |
| 1925 | } |
| 1926 | |
| 1927 | seq_putc(m, '\n'); |
| 1928 | } |
| 1929 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1930 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 1931 | { |
| 1932 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1933 | struct drm_device *dev = node->minor->dev; |
| 1934 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1935 | struct intel_engine_cs *ring; |
| 1936 | struct intel_context *ctx; |
| 1937 | int ret, i; |
| 1938 | |
| 1939 | if (!i915.enable_execlists) { |
| 1940 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 1941 | return 0; |
| 1942 | } |
| 1943 | |
| 1944 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1945 | if (ret) |
| 1946 | return ret; |
| 1947 | |
| 1948 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
| 1949 | for_each_ring(ring, dev_priv, i) { |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1950 | if (ring->default_context != ctx) |
| 1951 | i915_dump_lrc_obj(m, ring, |
| 1952 | ctx->engine[i].state); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1953 | } |
| 1954 | } |
| 1955 | |
| 1956 | mutex_unlock(&dev->struct_mutex); |
| 1957 | |
| 1958 | return 0; |
| 1959 | } |
| 1960 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1961 | static int i915_execlists(struct seq_file *m, void *data) |
| 1962 | { |
| 1963 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 1964 | struct drm_device *dev = node->minor->dev; |
| 1965 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1966 | struct intel_engine_cs *ring; |
| 1967 | u32 status_pointer; |
| 1968 | u8 read_pointer; |
| 1969 | u8 write_pointer; |
| 1970 | u32 status; |
| 1971 | u32 ctx_id; |
| 1972 | struct list_head *cursor; |
| 1973 | int ring_id, i; |
| 1974 | int ret; |
| 1975 | |
| 1976 | if (!i915.enable_execlists) { |
| 1977 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 1978 | return 0; |
| 1979 | } |
| 1980 | |
| 1981 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1982 | if (ret) |
| 1983 | return ret; |
| 1984 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 1985 | intel_runtime_pm_get(dev_priv); |
| 1986 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1987 | for_each_ring(ring, dev_priv, ring_id) { |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 1988 | struct drm_i915_gem_request *head_req = NULL; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1989 | int count = 0; |
| 1990 | unsigned long flags; |
| 1991 | |
| 1992 | seq_printf(m, "%s\n", ring->name); |
| 1993 | |
| 1994 | status = I915_READ(RING_EXECLIST_STATUS(ring)); |
| 1995 | ctx_id = I915_READ(RING_EXECLIST_STATUS(ring) + 4); |
| 1996 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 1997 | status, ctx_id); |
| 1998 | |
| 1999 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring)); |
| 2000 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 2001 | |
| 2002 | read_pointer = ring->next_context_status_buffer; |
| 2003 | write_pointer = status_pointer & 0x07; |
| 2004 | if (read_pointer > write_pointer) |
| 2005 | write_pointer += 6; |
| 2006 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 2007 | read_pointer, write_pointer); |
| 2008 | |
| 2009 | for (i = 0; i < 6; i++) { |
| 2010 | status = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i); |
| 2011 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i + 4); |
| 2012 | |
| 2013 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 2014 | i, status, ctx_id); |
| 2015 | } |
| 2016 | |
| 2017 | spin_lock_irqsave(&ring->execlist_lock, flags); |
| 2018 | list_for_each(cursor, &ring->execlist_queue) |
| 2019 | count++; |
| 2020 | head_req = list_first_entry_or_null(&ring->execlist_queue, |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2021 | struct drm_i915_gem_request, execlist_link); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2022 | spin_unlock_irqrestore(&ring->execlist_lock, flags); |
| 2023 | |
| 2024 | seq_printf(m, "\t%d requests in queue\n", count); |
| 2025 | if (head_req) { |
| 2026 | struct drm_i915_gem_object *ctx_obj; |
| 2027 | |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2028 | ctx_obj = head_req->ctx->engine[ring_id].state; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2029 | seq_printf(m, "\tHead request id: %u\n", |
| 2030 | intel_execlists_ctx_id(ctx_obj)); |
| 2031 | seq_printf(m, "\tHead request tail: %u\n", |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2032 | head_req->tail); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2033 | } |
| 2034 | |
| 2035 | seq_putc(m, '\n'); |
| 2036 | } |
| 2037 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2038 | intel_runtime_pm_put(dev_priv); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2039 | mutex_unlock(&dev->struct_mutex); |
| 2040 | |
| 2041 | return 0; |
| 2042 | } |
| 2043 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2044 | static const char *swizzle_string(unsigned swizzle) |
| 2045 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2046 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2047 | case I915_BIT_6_SWIZZLE_NONE: |
| 2048 | return "none"; |
| 2049 | case I915_BIT_6_SWIZZLE_9: |
| 2050 | return "bit9"; |
| 2051 | case I915_BIT_6_SWIZZLE_9_10: |
| 2052 | return "bit9/bit10"; |
| 2053 | case I915_BIT_6_SWIZZLE_9_11: |
| 2054 | return "bit9/bit11"; |
| 2055 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2056 | return "bit9/bit10/bit11"; |
| 2057 | case I915_BIT_6_SWIZZLE_9_17: |
| 2058 | return "bit9/bit17"; |
| 2059 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2060 | return "bit9/bit10/bit17"; |
| 2061 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2062 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2063 | } |
| 2064 | |
| 2065 | return "bug"; |
| 2066 | } |
| 2067 | |
| 2068 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2069 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2070 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2071 | struct drm_device *dev = node->minor->dev; |
| 2072 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2073 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2074 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2075 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2076 | if (ret) |
| 2077 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2078 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2079 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2080 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2081 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2082 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2083 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2084 | |
| 2085 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 2086 | seq_printf(m, "DDC = 0x%08x\n", |
| 2087 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2088 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2089 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2090 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2091 | I915_READ16(C0DRB3)); |
| 2092 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2093 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2094 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2095 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2096 | I915_READ(MAD_DIMM_C0)); |
| 2097 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2098 | I915_READ(MAD_DIMM_C1)); |
| 2099 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2100 | I915_READ(MAD_DIMM_C2)); |
| 2101 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2102 | I915_READ(TILECTL)); |
Robert Beckett | 5907f5f | 2014-01-23 14:23:14 +0000 | [diff] [blame] | 2103 | if (INTEL_INFO(dev)->gen >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2104 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2105 | I915_READ(GAMTARBMODE)); |
| 2106 | else |
| 2107 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2108 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2109 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2110 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2111 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2112 | |
| 2113 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2114 | seq_puts(m, "L-shaped memory detected\n"); |
| 2115 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2116 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2117 | mutex_unlock(&dev->struct_mutex); |
| 2118 | |
| 2119 | return 0; |
| 2120 | } |
| 2121 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2122 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2123 | { |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 2124 | struct intel_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2125 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2126 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2127 | |
| 2128 | if (!ppgtt) { |
| 2129 | seq_printf(m, " no ppgtt for context %d\n", |
| 2130 | ctx->user_handle); |
| 2131 | return 0; |
| 2132 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2133 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2134 | if (i915_gem_context_is_default(ctx)) |
| 2135 | seq_puts(m, " default context:\n"); |
| 2136 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2137 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2138 | ppgtt->debug_dump(ppgtt, m); |
| 2139 | |
| 2140 | return 0; |
| 2141 | } |
| 2142 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2143 | 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] | 2144 | { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2145 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2146 | struct intel_engine_cs *ring; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2147 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2148 | int unused, i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2149 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2150 | if (!ppgtt) |
| 2151 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2152 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2153 | seq_printf(m, "Page directories: %d\n", ppgtt->num_pd_pages); |
Ben Widawsky | 5abbcca | 2014-02-21 13:06:34 -0800 | [diff] [blame] | 2154 | seq_printf(m, "Page tables: %d\n", ppgtt->num_pd_entries); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2155 | for_each_ring(ring, dev_priv, unused) { |
| 2156 | seq_printf(m, "%s\n", ring->name); |
| 2157 | for (i = 0; i < 4; i++) { |
| 2158 | u32 offset = 0x270 + i * 8; |
| 2159 | u64 pdp = I915_READ(ring->mmio_base + offset + 4); |
| 2160 | pdp <<= 32; |
| 2161 | pdp |= I915_READ(ring->mmio_base + offset); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2162 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2163 | } |
| 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2168 | { |
| 2169 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2170 | struct intel_engine_cs *ring; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2171 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2172 | int i; |
| 2173 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2174 | if (INTEL_INFO(dev)->gen == 6) |
| 2175 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2176 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 2177 | for_each_ring(ring, dev_priv, i) { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2178 | seq_printf(m, "%s\n", ring->name); |
| 2179 | if (INTEL_INFO(dev)->gen == 7) |
| 2180 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 2181 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 2182 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 2183 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 2184 | } |
| 2185 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2186 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2187 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2188 | seq_puts(m, "aliasing PPGTT:\n"); |
Ben Widawsky | 7324cc0 | 2015-02-24 16:22:35 +0000 | [diff] [blame] | 2189 | 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] | 2190 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2191 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2192 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2193 | |
| 2194 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2195 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2196 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2197 | seq_printf(m, "proc: %s\n", |
| 2198 | get_pid_task(file->pid, PIDTYPE_PID)->comm); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2199 | idr_for_each(&file_priv->context_idr, per_file_ctx, m); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2200 | } |
| 2201 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2202 | } |
| 2203 | |
| 2204 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2205 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2206 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2207 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2208 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2209 | |
| 2210 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2211 | if (ret) |
| 2212 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2213 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2214 | |
| 2215 | if (INTEL_INFO(dev)->gen >= 8) |
| 2216 | gen8_ppgtt_info(m, dev); |
| 2217 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2218 | gen6_ppgtt_info(m, dev); |
| 2219 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2220 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2221 | mutex_unlock(&dev->struct_mutex); |
| 2222 | |
| 2223 | return 0; |
| 2224 | } |
| 2225 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2226 | static int i915_llc(struct seq_file *m, void *data) |
| 2227 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2228 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2229 | struct drm_device *dev = node->minor->dev; |
| 2230 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2231 | |
| 2232 | /* Size calculation for LLC is a bit of a pain. Ignore for now. */ |
| 2233 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
| 2234 | seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size); |
| 2235 | |
| 2236 | return 0; |
| 2237 | } |
| 2238 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2239 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2240 | { |
| 2241 | struct drm_info_node *node = m->private; |
| 2242 | struct drm_device *dev = node->minor->dev; |
| 2243 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2244 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2245 | u32 stat[3]; |
| 2246 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2247 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2248 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2249 | intel_runtime_pm_get(dev_priv); |
| 2250 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2251 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2252 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2253 | 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] | 2254 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2255 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2256 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2257 | dev_priv->psr.busy_frontbuffer_bits); |
| 2258 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2259 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2260 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2261 | if (HAS_PSR(dev)) { |
| 2262 | if (HAS_DDI(dev)) |
| 2263 | enabled = I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE; |
| 2264 | else { |
| 2265 | for_each_pipe(dev_priv, pipe) { |
| 2266 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2267 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2268 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2269 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2270 | enabled = true; |
| 2271 | } |
| 2272 | } |
| 2273 | } |
| 2274 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2275 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2276 | if (!HAS_DDI(dev)) |
| 2277 | for_each_pipe(dev_priv, pipe) { |
| 2278 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2279 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2280 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2281 | } |
| 2282 | seq_puts(m, "\n"); |
| 2283 | |
Rodrigo Vivi | fb49581 | 2015-01-12 10:14:33 -0800 | [diff] [blame] | 2284 | seq_printf(m, "Link standby: %s\n", |
| 2285 | yesno((bool)dev_priv->psr.link_standby)); |
| 2286 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2287 | /* CHV PSR has no kind of performance counter */ |
| 2288 | if (HAS_PSR(dev) && HAS_DDI(dev)) { |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2289 | psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) & |
| 2290 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2291 | |
| 2292 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2293 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2294 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2295 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2296 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2297 | return 0; |
| 2298 | } |
| 2299 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2300 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2301 | { |
| 2302 | struct drm_info_node *node = m->private; |
| 2303 | struct drm_device *dev = node->minor->dev; |
| 2304 | struct intel_encoder *encoder; |
| 2305 | struct intel_connector *connector; |
| 2306 | struct intel_dp *intel_dp = NULL; |
| 2307 | int ret; |
| 2308 | u8 crc[6]; |
| 2309 | |
| 2310 | drm_modeset_lock_all(dev); |
Ander Conselvan de Oliveira | 3a3371f | 2015-03-03 15:21:56 +0200 | [diff] [blame^] | 2311 | for_each_intel_encoder(dev, connector) { |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2312 | |
| 2313 | if (connector->base.dpms != DRM_MODE_DPMS_ON) |
| 2314 | continue; |
| 2315 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2316 | if (!connector->base.encoder) |
| 2317 | continue; |
| 2318 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2319 | encoder = to_intel_encoder(connector->base.encoder); |
| 2320 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 2321 | continue; |
| 2322 | |
| 2323 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 2324 | |
| 2325 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2326 | if (ret) |
| 2327 | goto out; |
| 2328 | |
| 2329 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2330 | crc[0], crc[1], crc[2], |
| 2331 | crc[3], crc[4], crc[5]); |
| 2332 | goto out; |
| 2333 | } |
| 2334 | ret = -ENODEV; |
| 2335 | out: |
| 2336 | drm_modeset_unlock_all(dev); |
| 2337 | return ret; |
| 2338 | } |
| 2339 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2340 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2341 | { |
| 2342 | struct drm_info_node *node = m->private; |
| 2343 | struct drm_device *dev = node->minor->dev; |
| 2344 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2345 | u64 power; |
| 2346 | u32 units; |
| 2347 | |
| 2348 | if (INTEL_INFO(dev)->gen < 6) |
| 2349 | return -ENODEV; |
| 2350 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2351 | intel_runtime_pm_get(dev_priv); |
| 2352 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2353 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2354 | power = (power & 0x1f00) >> 8; |
| 2355 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2356 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2357 | power *= units; |
| 2358 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2359 | intel_runtime_pm_put(dev_priv); |
| 2360 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2361 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2362 | |
| 2363 | return 0; |
| 2364 | } |
| 2365 | |
| 2366 | static int i915_pc8_status(struct seq_file *m, void *unused) |
| 2367 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2368 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2369 | struct drm_device *dev = node->minor->dev; |
| 2370 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2371 | |
Zhenyu Wang | 85b8d5c | 2014-04-01 19:39:48 -0300 | [diff] [blame] | 2372 | if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2373 | seq_puts(m, "not supported\n"); |
| 2374 | return 0; |
| 2375 | } |
| 2376 | |
Paulo Zanoni | 86c4ec0 | 2014-02-21 13:52:24 -0300 | [diff] [blame] | 2377 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2378 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2379 | yesno(!intel_irqs_enabled(dev_priv))); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2380 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2381 | return 0; |
| 2382 | } |
| 2383 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2384 | static const char *power_domain_str(enum intel_display_power_domain domain) |
| 2385 | { |
| 2386 | switch (domain) { |
| 2387 | case POWER_DOMAIN_PIPE_A: |
| 2388 | return "PIPE_A"; |
| 2389 | case POWER_DOMAIN_PIPE_B: |
| 2390 | return "PIPE_B"; |
| 2391 | case POWER_DOMAIN_PIPE_C: |
| 2392 | return "PIPE_C"; |
| 2393 | case POWER_DOMAIN_PIPE_A_PANEL_FITTER: |
| 2394 | return "PIPE_A_PANEL_FITTER"; |
| 2395 | case POWER_DOMAIN_PIPE_B_PANEL_FITTER: |
| 2396 | return "PIPE_B_PANEL_FITTER"; |
| 2397 | case POWER_DOMAIN_PIPE_C_PANEL_FITTER: |
| 2398 | return "PIPE_C_PANEL_FITTER"; |
| 2399 | case POWER_DOMAIN_TRANSCODER_A: |
| 2400 | return "TRANSCODER_A"; |
| 2401 | case POWER_DOMAIN_TRANSCODER_B: |
| 2402 | return "TRANSCODER_B"; |
| 2403 | case POWER_DOMAIN_TRANSCODER_C: |
| 2404 | return "TRANSCODER_C"; |
| 2405 | case POWER_DOMAIN_TRANSCODER_EDP: |
| 2406 | return "TRANSCODER_EDP"; |
Imre Deak | 319be8a | 2014-03-04 19:22:57 +0200 | [diff] [blame] | 2407 | case POWER_DOMAIN_PORT_DDI_A_2_LANES: |
| 2408 | return "PORT_DDI_A_2_LANES"; |
| 2409 | case POWER_DOMAIN_PORT_DDI_A_4_LANES: |
| 2410 | return "PORT_DDI_A_4_LANES"; |
| 2411 | case POWER_DOMAIN_PORT_DDI_B_2_LANES: |
| 2412 | return "PORT_DDI_B_2_LANES"; |
| 2413 | case POWER_DOMAIN_PORT_DDI_B_4_LANES: |
| 2414 | return "PORT_DDI_B_4_LANES"; |
| 2415 | case POWER_DOMAIN_PORT_DDI_C_2_LANES: |
| 2416 | return "PORT_DDI_C_2_LANES"; |
| 2417 | case POWER_DOMAIN_PORT_DDI_C_4_LANES: |
| 2418 | return "PORT_DDI_C_4_LANES"; |
| 2419 | case POWER_DOMAIN_PORT_DDI_D_2_LANES: |
| 2420 | return "PORT_DDI_D_2_LANES"; |
| 2421 | case POWER_DOMAIN_PORT_DDI_D_4_LANES: |
| 2422 | return "PORT_DDI_D_4_LANES"; |
| 2423 | case POWER_DOMAIN_PORT_DSI: |
| 2424 | return "PORT_DSI"; |
| 2425 | case POWER_DOMAIN_PORT_CRT: |
| 2426 | return "PORT_CRT"; |
| 2427 | case POWER_DOMAIN_PORT_OTHER: |
| 2428 | return "PORT_OTHER"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2429 | case POWER_DOMAIN_VGA: |
| 2430 | return "VGA"; |
| 2431 | case POWER_DOMAIN_AUDIO: |
| 2432 | return "AUDIO"; |
Paulo Zanoni | bd2bb1b | 2014-07-04 11:27:38 -0300 | [diff] [blame] | 2433 | case POWER_DOMAIN_PLLS: |
| 2434 | return "PLLS"; |
Satheeshakrishna M | 1407121 | 2015-01-16 15:57:51 +0000 | [diff] [blame] | 2435 | case POWER_DOMAIN_AUX_A: |
| 2436 | return "AUX_A"; |
| 2437 | case POWER_DOMAIN_AUX_B: |
| 2438 | return "AUX_B"; |
| 2439 | case POWER_DOMAIN_AUX_C: |
| 2440 | return "AUX_C"; |
| 2441 | case POWER_DOMAIN_AUX_D: |
| 2442 | return "AUX_D"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2443 | case POWER_DOMAIN_INIT: |
| 2444 | return "INIT"; |
| 2445 | default: |
Daniel Vetter | 5f77eeb | 2014-12-08 16:40:10 +0100 | [diff] [blame] | 2446 | MISSING_CASE(domain); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2447 | return "?"; |
| 2448 | } |
| 2449 | } |
| 2450 | |
| 2451 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2452 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2453 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2454 | struct drm_device *dev = node->minor->dev; |
| 2455 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2456 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2457 | int i; |
| 2458 | |
| 2459 | mutex_lock(&power_domains->lock); |
| 2460 | |
| 2461 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2462 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2463 | struct i915_power_well *power_well; |
| 2464 | enum intel_display_power_domain power_domain; |
| 2465 | |
| 2466 | power_well = &power_domains->power_wells[i]; |
| 2467 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2468 | power_well->count); |
| 2469 | |
| 2470 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2471 | power_domain++) { |
| 2472 | if (!(BIT(power_domain) & power_well->domains)) |
| 2473 | continue; |
| 2474 | |
| 2475 | seq_printf(m, " %-23s %d\n", |
| 2476 | power_domain_str(power_domain), |
| 2477 | power_domains->domain_use_count[power_domain]); |
| 2478 | } |
| 2479 | } |
| 2480 | |
| 2481 | mutex_unlock(&power_domains->lock); |
| 2482 | |
| 2483 | return 0; |
| 2484 | } |
| 2485 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2486 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2487 | struct drm_display_mode *mode) |
| 2488 | { |
| 2489 | int i; |
| 2490 | |
| 2491 | for (i = 0; i < tabs; i++) |
| 2492 | seq_putc(m, '\t'); |
| 2493 | |
| 2494 | 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", |
| 2495 | mode->base.id, mode->name, |
| 2496 | mode->vrefresh, mode->clock, |
| 2497 | mode->hdisplay, mode->hsync_start, |
| 2498 | mode->hsync_end, mode->htotal, |
| 2499 | mode->vdisplay, mode->vsync_start, |
| 2500 | mode->vsync_end, mode->vtotal, |
| 2501 | mode->type, mode->flags); |
| 2502 | } |
| 2503 | |
| 2504 | static void intel_encoder_info(struct seq_file *m, |
| 2505 | struct intel_crtc *intel_crtc, |
| 2506 | struct intel_encoder *intel_encoder) |
| 2507 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2508 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2509 | struct drm_device *dev = node->minor->dev; |
| 2510 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2511 | struct intel_connector *intel_connector; |
| 2512 | struct drm_encoder *encoder; |
| 2513 | |
| 2514 | encoder = &intel_encoder->base; |
| 2515 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2516 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2517 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2518 | struct drm_connector *connector = &intel_connector->base; |
| 2519 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2520 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2521 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2522 | drm_get_connector_status_name(connector->status)); |
| 2523 | if (connector->status == connector_status_connected) { |
| 2524 | struct drm_display_mode *mode = &crtc->mode; |
| 2525 | seq_printf(m, ", mode:\n"); |
| 2526 | intel_seq_print_mode(m, 2, mode); |
| 2527 | } else { |
| 2528 | seq_putc(m, '\n'); |
| 2529 | } |
| 2530 | } |
| 2531 | } |
| 2532 | |
| 2533 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2534 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2535 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2536 | struct drm_device *dev = node->minor->dev; |
| 2537 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2538 | struct intel_encoder *intel_encoder; |
| 2539 | |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2540 | if (crtc->primary->fb) |
| 2541 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
| 2542 | crtc->primary->fb->base.id, crtc->x, crtc->y, |
| 2543 | crtc->primary->fb->width, crtc->primary->fb->height); |
| 2544 | else |
| 2545 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2546 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2547 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2548 | } |
| 2549 | |
| 2550 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2551 | { |
| 2552 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2553 | |
| 2554 | seq_printf(m, "\tfixed mode:\n"); |
| 2555 | intel_seq_print_mode(m, 2, mode); |
| 2556 | } |
| 2557 | |
| 2558 | static void intel_dp_info(struct seq_file *m, |
| 2559 | struct intel_connector *intel_connector) |
| 2560 | { |
| 2561 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2562 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2563 | |
| 2564 | seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); |
| 2565 | seq_printf(m, "\taudio support: %s\n", intel_dp->has_audio ? "yes" : |
| 2566 | "no"); |
| 2567 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2568 | intel_panel_info(m, &intel_connector->panel); |
| 2569 | } |
| 2570 | |
| 2571 | static void intel_hdmi_info(struct seq_file *m, |
| 2572 | struct intel_connector *intel_connector) |
| 2573 | { |
| 2574 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2575 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2576 | |
| 2577 | seq_printf(m, "\taudio support: %s\n", intel_hdmi->has_audio ? "yes" : |
| 2578 | "no"); |
| 2579 | } |
| 2580 | |
| 2581 | static void intel_lvds_info(struct seq_file *m, |
| 2582 | struct intel_connector *intel_connector) |
| 2583 | { |
| 2584 | intel_panel_info(m, &intel_connector->panel); |
| 2585 | } |
| 2586 | |
| 2587 | static void intel_connector_info(struct seq_file *m, |
| 2588 | struct drm_connector *connector) |
| 2589 | { |
| 2590 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2591 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2592 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2593 | |
| 2594 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2595 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2596 | drm_get_connector_status_name(connector->status)); |
| 2597 | if (connector->status == connector_status_connected) { |
| 2598 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2599 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2600 | connector->display_info.width_mm, |
| 2601 | connector->display_info.height_mm); |
| 2602 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2603 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2604 | seq_printf(m, "\tCEA rev: %d\n", |
| 2605 | connector->display_info.cea_rev); |
| 2606 | } |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2607 | if (intel_encoder) { |
| 2608 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2609 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2610 | intel_dp_info(m, intel_connector); |
| 2611 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2612 | intel_hdmi_info(m, intel_connector); |
| 2613 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2614 | intel_lvds_info(m, intel_connector); |
| 2615 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2616 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2617 | seq_printf(m, "\tmodes:\n"); |
| 2618 | list_for_each_entry(mode, &connector->modes, head) |
| 2619 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2620 | } |
| 2621 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2622 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 2623 | { |
| 2624 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2625 | u32 state; |
| 2626 | |
| 2627 | if (IS_845G(dev) || IS_I865G(dev)) |
| 2628 | state = I915_READ(_CURACNTR) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2629 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2630 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2631 | |
| 2632 | return state; |
| 2633 | } |
| 2634 | |
| 2635 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 2636 | { |
| 2637 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2638 | u32 pos; |
| 2639 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2640 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2641 | |
| 2642 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2643 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2644 | *x = -*x; |
| 2645 | |
| 2646 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2647 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2648 | *y = -*y; |
| 2649 | |
| 2650 | return cursor_active(dev, pipe); |
| 2651 | } |
| 2652 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2653 | static int i915_display_info(struct seq_file *m, void *unused) |
| 2654 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2655 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2656 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2657 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2658 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2659 | struct drm_connector *connector; |
| 2660 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2661 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2662 | drm_modeset_lock_all(dev); |
| 2663 | seq_printf(m, "CRTC info\n"); |
| 2664 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 2665 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2666 | bool active; |
| 2667 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2668 | |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2669 | seq_printf(m, "CRTC %d: pipe: %c, active=%s (size=%dx%d)\n", |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2670 | crtc->base.base.id, pipe_name(crtc->pipe), |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 2671 | yesno(crtc->active), crtc->config->pipe_src_w, |
| 2672 | crtc->config->pipe_src_h); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2673 | if (crtc->active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2674 | intel_crtc_info(m, crtc); |
| 2675 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2676 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2677 | 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] | 2678 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 2679 | x, y, crtc->base.cursor->state->crtc_w, |
| 2680 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2681 | crtc->cursor_addr, yesno(active)); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2682 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 2683 | |
| 2684 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 2685 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 2686 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2687 | } |
| 2688 | |
| 2689 | seq_printf(m, "\n"); |
| 2690 | seq_printf(m, "Connector info\n"); |
| 2691 | seq_printf(m, "--------------\n"); |
| 2692 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 2693 | intel_connector_info(m, connector); |
| 2694 | } |
| 2695 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2696 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2697 | |
| 2698 | return 0; |
| 2699 | } |
| 2700 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2701 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 2702 | { |
| 2703 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2704 | struct drm_device *dev = node->minor->dev; |
| 2705 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2706 | struct intel_engine_cs *ring; |
| 2707 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
| 2708 | int i, j, ret; |
| 2709 | |
| 2710 | if (!i915_semaphore_is_enabled(dev)) { |
| 2711 | seq_puts(m, "Semaphores are disabled\n"); |
| 2712 | return 0; |
| 2713 | } |
| 2714 | |
| 2715 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2716 | if (ret) |
| 2717 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2718 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2719 | |
| 2720 | if (IS_BROADWELL(dev)) { |
| 2721 | struct page *page; |
| 2722 | uint64_t *seqno; |
| 2723 | |
| 2724 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 2725 | |
| 2726 | seqno = (uint64_t *)kmap_atomic(page); |
| 2727 | for_each_ring(ring, dev_priv, i) { |
| 2728 | uint64_t offset; |
| 2729 | |
| 2730 | seq_printf(m, "%s\n", ring->name); |
| 2731 | |
| 2732 | seq_puts(m, " Last signal:"); |
| 2733 | for (j = 0; j < num_rings; j++) { |
| 2734 | offset = i * I915_NUM_RINGS + j; |
| 2735 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2736 | seqno[offset], offset * 8); |
| 2737 | } |
| 2738 | seq_putc(m, '\n'); |
| 2739 | |
| 2740 | seq_puts(m, " Last wait: "); |
| 2741 | for (j = 0; j < num_rings; j++) { |
| 2742 | offset = i + (j * I915_NUM_RINGS); |
| 2743 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2744 | seqno[offset], offset * 8); |
| 2745 | } |
| 2746 | seq_putc(m, '\n'); |
| 2747 | |
| 2748 | } |
| 2749 | kunmap_atomic(seqno); |
| 2750 | } else { |
| 2751 | seq_puts(m, " Last signal:"); |
| 2752 | for_each_ring(ring, dev_priv, i) |
| 2753 | for (j = 0; j < num_rings; j++) |
| 2754 | seq_printf(m, "0x%08x\n", |
| 2755 | I915_READ(ring->semaphore.mbox.signal[j])); |
| 2756 | seq_putc(m, '\n'); |
| 2757 | } |
| 2758 | |
| 2759 | seq_puts(m, "\nSync seqno:\n"); |
| 2760 | for_each_ring(ring, dev_priv, i) { |
| 2761 | for (j = 0; j < num_rings; j++) { |
| 2762 | seq_printf(m, " 0x%08x ", ring->semaphore.sync_seqno[j]); |
| 2763 | } |
| 2764 | seq_putc(m, '\n'); |
| 2765 | } |
| 2766 | seq_putc(m, '\n'); |
| 2767 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2768 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2769 | mutex_unlock(&dev->struct_mutex); |
| 2770 | return 0; |
| 2771 | } |
| 2772 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2773 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 2774 | { |
| 2775 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2776 | struct drm_device *dev = node->minor->dev; |
| 2777 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2778 | int i; |
| 2779 | |
| 2780 | drm_modeset_lock_all(dev); |
| 2781 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 2782 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 2783 | |
| 2784 | 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] | 2785 | 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] | 2786 | pll->config.crtc_mask, pll->active, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2787 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 2788 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 2789 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 2790 | pll->config.hw_state.dpll_md); |
| 2791 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 2792 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 2793 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2794 | } |
| 2795 | drm_modeset_unlock_all(dev); |
| 2796 | |
| 2797 | return 0; |
| 2798 | } |
| 2799 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 2800 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2801 | { |
| 2802 | int i; |
| 2803 | int ret; |
| 2804 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2805 | struct drm_device *dev = node->minor->dev; |
| 2806 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2807 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2808 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2809 | if (ret) |
| 2810 | return ret; |
| 2811 | |
| 2812 | intel_runtime_pm_get(dev_priv); |
| 2813 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2814 | seq_printf(m, "Workarounds applied: %d\n", dev_priv->workarounds.count); |
| 2815 | for (i = 0; i < dev_priv->workarounds.count; ++i) { |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 2816 | u32 addr, mask, value, read; |
| 2817 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2818 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2819 | addr = dev_priv->workarounds.reg[i].addr; |
| 2820 | mask = dev_priv->workarounds.reg[i].mask; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 2821 | value = dev_priv->workarounds.reg[i].value; |
| 2822 | read = I915_READ(addr); |
| 2823 | ok = (value & mask) == (read & mask); |
| 2824 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n", |
| 2825 | addr, value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2826 | } |
| 2827 | |
| 2828 | intel_runtime_pm_put(dev_priv); |
| 2829 | mutex_unlock(&dev->struct_mutex); |
| 2830 | |
| 2831 | return 0; |
| 2832 | } |
| 2833 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2834 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 2835 | { |
| 2836 | struct drm_info_node *node = m->private; |
| 2837 | struct drm_device *dev = node->minor->dev; |
| 2838 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2839 | struct skl_ddb_allocation *ddb; |
| 2840 | struct skl_ddb_entry *entry; |
| 2841 | enum pipe pipe; |
| 2842 | int plane; |
| 2843 | |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 2844 | if (INTEL_INFO(dev)->gen < 9) |
| 2845 | return 0; |
| 2846 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2847 | drm_modeset_lock_all(dev); |
| 2848 | |
| 2849 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 2850 | |
| 2851 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 2852 | |
| 2853 | for_each_pipe(dev_priv, pipe) { |
| 2854 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 2855 | |
Damien Lespiau | dd74078 | 2015-02-28 14:54:08 +0000 | [diff] [blame] | 2856 | for_each_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2857 | entry = &ddb->plane[pipe][plane]; |
| 2858 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 2859 | entry->start, entry->end, |
| 2860 | skl_ddb_entry_size(entry)); |
| 2861 | } |
| 2862 | |
| 2863 | entry = &ddb->cursor[pipe]; |
| 2864 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 2865 | entry->end, skl_ddb_entry_size(entry)); |
| 2866 | } |
| 2867 | |
| 2868 | drm_modeset_unlock_all(dev); |
| 2869 | |
| 2870 | return 0; |
| 2871 | } |
| 2872 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2873 | struct pipe_crc_info { |
| 2874 | const char *name; |
| 2875 | struct drm_device *dev; |
| 2876 | enum pipe pipe; |
| 2877 | }; |
| 2878 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 2879 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 2880 | { |
| 2881 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2882 | struct drm_device *dev = node->minor->dev; |
| 2883 | struct drm_encoder *encoder; |
| 2884 | struct intel_encoder *intel_encoder; |
| 2885 | struct intel_digital_port *intel_dig_port; |
| 2886 | drm_modeset_lock_all(dev); |
| 2887 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 2888 | intel_encoder = to_intel_encoder(encoder); |
| 2889 | if (intel_encoder->type != INTEL_OUTPUT_DISPLAYPORT) |
| 2890 | continue; |
| 2891 | intel_dig_port = enc_to_dig_port(encoder); |
| 2892 | if (!intel_dig_port->dp.can_mst) |
| 2893 | continue; |
| 2894 | |
| 2895 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 2896 | } |
| 2897 | drm_modeset_unlock_all(dev); |
| 2898 | return 0; |
| 2899 | } |
| 2900 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2901 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2902 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2903 | struct pipe_crc_info *info = inode->i_private; |
| 2904 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2905 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2906 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 2907 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 2908 | return -ENODEV; |
| 2909 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2910 | spin_lock_irq(&pipe_crc->lock); |
| 2911 | |
| 2912 | if (pipe_crc->opened) { |
| 2913 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2914 | return -EBUSY; /* already open */ |
| 2915 | } |
| 2916 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2917 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2918 | filep->private_data = inode->i_private; |
| 2919 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2920 | spin_unlock_irq(&pipe_crc->lock); |
| 2921 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2922 | return 0; |
| 2923 | } |
| 2924 | |
| 2925 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 2926 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2927 | struct pipe_crc_info *info = inode->i_private; |
| 2928 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2929 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2930 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2931 | spin_lock_irq(&pipe_crc->lock); |
| 2932 | pipe_crc->opened = false; |
| 2933 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2934 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2935 | return 0; |
| 2936 | } |
| 2937 | |
| 2938 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 2939 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 2940 | /* account for \'0' */ |
| 2941 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 2942 | |
| 2943 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 2944 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2945 | assert_spin_locked(&pipe_crc->lock); |
| 2946 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 2947 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2948 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2949 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2950 | static ssize_t |
| 2951 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 2952 | loff_t *pos) |
| 2953 | { |
| 2954 | struct pipe_crc_info *info = filep->private_data; |
| 2955 | struct drm_device *dev = info->dev; |
| 2956 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2957 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2958 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 2959 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2960 | ssize_t bytes_read; |
| 2961 | |
| 2962 | /* |
| 2963 | * Don't allow user space to provide buffers not big enough to hold |
| 2964 | * a line of data. |
| 2965 | */ |
| 2966 | if (count < PIPE_CRC_LINE_LEN) |
| 2967 | return -EINVAL; |
| 2968 | |
| 2969 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 2970 | return 0; |
| 2971 | |
| 2972 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2973 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2974 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2975 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2976 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2977 | if (filep->f_flags & O_NONBLOCK) { |
| 2978 | spin_unlock_irq(&pipe_crc->lock); |
| 2979 | return -EAGAIN; |
| 2980 | } |
| 2981 | |
| 2982 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 2983 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 2984 | if (ret) { |
| 2985 | spin_unlock_irq(&pipe_crc->lock); |
| 2986 | return ret; |
| 2987 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2988 | } |
| 2989 | |
| 2990 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 2991 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2992 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2993 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 2994 | while (n_entries > 0) { |
| 2995 | struct intel_pipe_crc_entry *entry = |
| 2996 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2997 | int ret; |
| 2998 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 2999 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3000 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3001 | break; |
| 3002 | |
| 3003 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3004 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3005 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3006 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3007 | "%8u %8x %8x %8x %8x %8x\n", |
| 3008 | entry->frame, entry->crc[0], |
| 3009 | entry->crc[1], entry->crc[2], |
| 3010 | entry->crc[3], entry->crc[4]); |
| 3011 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3012 | spin_unlock_irq(&pipe_crc->lock); |
| 3013 | |
| 3014 | ret = copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3015 | if (ret == PIPE_CRC_LINE_LEN) |
| 3016 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3017 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3018 | user_buf += PIPE_CRC_LINE_LEN; |
| 3019 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3020 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3021 | spin_lock_irq(&pipe_crc->lock); |
| 3022 | } |
| 3023 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3024 | spin_unlock_irq(&pipe_crc->lock); |
| 3025 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3026 | return bytes_read; |
| 3027 | } |
| 3028 | |
| 3029 | static const struct file_operations i915_pipe_crc_fops = { |
| 3030 | .owner = THIS_MODULE, |
| 3031 | .open = i915_pipe_crc_open, |
| 3032 | .read = i915_pipe_crc_read, |
| 3033 | .release = i915_pipe_crc_release, |
| 3034 | }; |
| 3035 | |
| 3036 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3037 | { |
| 3038 | .name = "i915_pipe_A_crc", |
| 3039 | .pipe = PIPE_A, |
| 3040 | }, |
| 3041 | { |
| 3042 | .name = "i915_pipe_B_crc", |
| 3043 | .pipe = PIPE_B, |
| 3044 | }, |
| 3045 | { |
| 3046 | .name = "i915_pipe_C_crc", |
| 3047 | .pipe = PIPE_C, |
| 3048 | }, |
| 3049 | }; |
| 3050 | |
| 3051 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3052 | enum pipe pipe) |
| 3053 | { |
| 3054 | struct drm_device *dev = minor->dev; |
| 3055 | struct dentry *ent; |
| 3056 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3057 | |
| 3058 | info->dev = dev; |
| 3059 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3060 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3061 | if (!ent) |
| 3062 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3063 | |
| 3064 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3065 | } |
| 3066 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3067 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3068 | "none", |
| 3069 | "plane1", |
| 3070 | "plane2", |
| 3071 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3072 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3073 | "TV", |
| 3074 | "DP-B", |
| 3075 | "DP-C", |
| 3076 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3077 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3078 | }; |
| 3079 | |
| 3080 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3081 | { |
| 3082 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3083 | return pipe_crc_sources[source]; |
| 3084 | } |
| 3085 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3086 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3087 | { |
| 3088 | struct drm_device *dev = m->private; |
| 3089 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3090 | int i; |
| 3091 | |
| 3092 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3093 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3094 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3095 | |
| 3096 | return 0; |
| 3097 | } |
| 3098 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3099 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3100 | { |
| 3101 | struct drm_device *dev = inode->i_private; |
| 3102 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3103 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3104 | } |
| 3105 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3106 | 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] | 3107 | uint32_t *val) |
| 3108 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3109 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3110 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3111 | |
| 3112 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3113 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3114 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3115 | break; |
| 3116 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3117 | *val = 0; |
| 3118 | break; |
| 3119 | default: |
| 3120 | return -EINVAL; |
| 3121 | } |
| 3122 | |
| 3123 | return 0; |
| 3124 | } |
| 3125 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3126 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 3127 | enum intel_pipe_crc_source *source) |
| 3128 | { |
| 3129 | struct intel_encoder *encoder; |
| 3130 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3131 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3132 | int ret = 0; |
| 3133 | |
| 3134 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3135 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3136 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3137 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3138 | if (!encoder->base.crtc) |
| 3139 | continue; |
| 3140 | |
| 3141 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3142 | |
| 3143 | if (crtc->pipe != pipe) |
| 3144 | continue; |
| 3145 | |
| 3146 | switch (encoder->type) { |
| 3147 | case INTEL_OUTPUT_TVOUT: |
| 3148 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3149 | break; |
| 3150 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3151 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3152 | dig_port = enc_to_dig_port(&encoder->base); |
| 3153 | switch (dig_port->port) { |
| 3154 | case PORT_B: |
| 3155 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3156 | break; |
| 3157 | case PORT_C: |
| 3158 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3159 | break; |
| 3160 | case PORT_D: |
| 3161 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3162 | break; |
| 3163 | default: |
| 3164 | WARN(1, "nonexisting DP port %c\n", |
| 3165 | port_name(dig_port->port)); |
| 3166 | break; |
| 3167 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3168 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3169 | default: |
| 3170 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3171 | } |
| 3172 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3173 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3174 | |
| 3175 | return ret; |
| 3176 | } |
| 3177 | |
| 3178 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3179 | enum pipe pipe, |
| 3180 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3181 | uint32_t *val) |
| 3182 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3183 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3184 | bool need_stable_symbols = false; |
| 3185 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3186 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3187 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3188 | if (ret) |
| 3189 | return ret; |
| 3190 | } |
| 3191 | |
| 3192 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3193 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3194 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3195 | break; |
| 3196 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3197 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3198 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3199 | break; |
| 3200 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3201 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3202 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3203 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3204 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3205 | if (!IS_CHERRYVIEW(dev)) |
| 3206 | return -EINVAL; |
| 3207 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3208 | need_stable_symbols = true; |
| 3209 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3210 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3211 | *val = 0; |
| 3212 | break; |
| 3213 | default: |
| 3214 | return -EINVAL; |
| 3215 | } |
| 3216 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3217 | /* |
| 3218 | * When the pipe CRC tap point is after the transcoders we need |
| 3219 | * to tweak symbol-level features to produce a deterministic series of |
| 3220 | * symbols for a given frame. We need to reset those features only once |
| 3221 | * a frame (instead of every nth symbol): |
| 3222 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3223 | * link (SDVO) |
| 3224 | * - DisplayPort scrambling: used for EMI reduction |
| 3225 | */ |
| 3226 | if (need_stable_symbols) { |
| 3227 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3228 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3229 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3230 | switch (pipe) { |
| 3231 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3232 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3233 | break; |
| 3234 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3235 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3236 | break; |
| 3237 | case PIPE_C: |
| 3238 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3239 | break; |
| 3240 | default: |
| 3241 | return -EINVAL; |
| 3242 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3243 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3244 | } |
| 3245 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3246 | return 0; |
| 3247 | } |
| 3248 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3249 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3250 | enum pipe pipe, |
| 3251 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3252 | uint32_t *val) |
| 3253 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3254 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3255 | bool need_stable_symbols = false; |
| 3256 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3257 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3258 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3259 | if (ret) |
| 3260 | return ret; |
| 3261 | } |
| 3262 | |
| 3263 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3264 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3265 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3266 | break; |
| 3267 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 3268 | if (!SUPPORTS_TV(dev)) |
| 3269 | return -EINVAL; |
| 3270 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3271 | break; |
| 3272 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3273 | if (!IS_G4X(dev)) |
| 3274 | return -EINVAL; |
| 3275 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_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_DP_C: |
| 3279 | if (!IS_G4X(dev)) |
| 3280 | return -EINVAL; |
| 3281 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3282 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3283 | break; |
| 3284 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3285 | if (!IS_G4X(dev)) |
| 3286 | return -EINVAL; |
| 3287 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3288 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3289 | break; |
| 3290 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3291 | *val = 0; |
| 3292 | break; |
| 3293 | default: |
| 3294 | return -EINVAL; |
| 3295 | } |
| 3296 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3297 | /* |
| 3298 | * When the pipe CRC tap point is after the transcoders we need |
| 3299 | * to tweak symbol-level features to produce a deterministic series of |
| 3300 | * symbols for a given frame. We need to reset those features only once |
| 3301 | * a frame (instead of every nth symbol): |
| 3302 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3303 | * link (SDVO) |
| 3304 | * - DisplayPort scrambling: used for EMI reduction |
| 3305 | */ |
| 3306 | if (need_stable_symbols) { |
| 3307 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3308 | |
| 3309 | WARN_ON(!IS_G4X(dev)); |
| 3310 | |
| 3311 | I915_WRITE(PORT_DFT_I9XX, |
| 3312 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3313 | |
| 3314 | if (pipe == PIPE_A) |
| 3315 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3316 | else |
| 3317 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3318 | |
| 3319 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3320 | } |
| 3321 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3322 | return 0; |
| 3323 | } |
| 3324 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3325 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3326 | enum pipe pipe) |
| 3327 | { |
| 3328 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3329 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3330 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3331 | switch (pipe) { |
| 3332 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3333 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3334 | break; |
| 3335 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3336 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3337 | break; |
| 3338 | case PIPE_C: |
| 3339 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 3340 | break; |
| 3341 | default: |
| 3342 | return; |
| 3343 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3344 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3345 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3346 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3347 | |
| 3348 | } |
| 3349 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3350 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3351 | enum pipe pipe) |
| 3352 | { |
| 3353 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3354 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3355 | |
| 3356 | if (pipe == PIPE_A) |
| 3357 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3358 | else |
| 3359 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3360 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3361 | |
| 3362 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3363 | I915_WRITE(PORT_DFT_I9XX, |
| 3364 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3365 | } |
| 3366 | } |
| 3367 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3368 | 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] | 3369 | uint32_t *val) |
| 3370 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3371 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3372 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3373 | |
| 3374 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3375 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3376 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 3377 | break; |
| 3378 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3379 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 3380 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3381 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3382 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 3383 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3384 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3385 | *val = 0; |
| 3386 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3387 | default: |
| 3388 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3389 | } |
| 3390 | |
| 3391 | return 0; |
| 3392 | } |
| 3393 | |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3394 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3395 | { |
| 3396 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3397 | struct intel_crtc *crtc = |
| 3398 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
| 3399 | |
| 3400 | drm_modeset_lock_all(dev); |
| 3401 | /* |
| 3402 | * If we use the eDP transcoder we need to make sure that we don't |
| 3403 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3404 | * relevant on hsw with pipe A when using the always-on power well |
| 3405 | * routing. |
| 3406 | */ |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 3407 | if (crtc->config->cpu_transcoder == TRANSCODER_EDP && |
| 3408 | !crtc->config->pch_pfit.enabled) { |
| 3409 | crtc->config->pch_pfit.force_thru = true; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3410 | |
| 3411 | intel_display_power_get(dev_priv, |
| 3412 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3413 | |
| 3414 | dev_priv->display.crtc_disable(&crtc->base); |
| 3415 | dev_priv->display.crtc_enable(&crtc->base); |
| 3416 | } |
| 3417 | drm_modeset_unlock_all(dev); |
| 3418 | } |
| 3419 | |
| 3420 | static void hsw_undo_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3421 | { |
| 3422 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3423 | struct intel_crtc *crtc = |
| 3424 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
| 3425 | |
| 3426 | drm_modeset_lock_all(dev); |
| 3427 | /* |
| 3428 | * If we use the eDP transcoder we need to make sure that we don't |
| 3429 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3430 | * relevant on hsw with pipe A when using the always-on power well |
| 3431 | * routing. |
| 3432 | */ |
Ander Conselvan de Oliveira | 6e3c971 | 2015-01-15 14:55:25 +0200 | [diff] [blame] | 3433 | if (crtc->config->pch_pfit.force_thru) { |
| 3434 | crtc->config->pch_pfit.force_thru = false; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3435 | |
| 3436 | dev_priv->display.crtc_disable(&crtc->base); |
| 3437 | dev_priv->display.crtc_enable(&crtc->base); |
| 3438 | |
| 3439 | intel_display_power_put(dev_priv, |
| 3440 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3441 | } |
| 3442 | drm_modeset_unlock_all(dev); |
| 3443 | } |
| 3444 | |
| 3445 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3446 | enum pipe pipe, |
| 3447 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3448 | uint32_t *val) |
| 3449 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3450 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3451 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 3452 | |
| 3453 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3454 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3455 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 3456 | break; |
| 3457 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3458 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 3459 | break; |
| 3460 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3461 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3462 | hsw_trans_edp_pipe_A_crc_wa(dev); |
| 3463 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3464 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 3465 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3466 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3467 | *val = 0; |
| 3468 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3469 | default: |
| 3470 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3471 | } |
| 3472 | |
| 3473 | return 0; |
| 3474 | } |
| 3475 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3476 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 3477 | enum intel_pipe_crc_source source) |
| 3478 | { |
| 3479 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3480 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3481 | struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, |
| 3482 | pipe)); |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 3483 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3484 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3485 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3486 | if (pipe_crc->source == source) |
| 3487 | return 0; |
| 3488 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 3489 | /* forbid changing the source without going back to 'none' */ |
| 3490 | if (pipe_crc->source && source) |
| 3491 | return -EINVAL; |
| 3492 | |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 3493 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PIPE(pipe))) { |
| 3494 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 3495 | return -EIO; |
| 3496 | } |
| 3497 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3498 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3499 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3500 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3501 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3502 | else if (IS_VALLEYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3503 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3504 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3505 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3506 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3507 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3508 | |
| 3509 | if (ret != 0) |
| 3510 | return ret; |
| 3511 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3512 | /* none -> real source transition */ |
| 3513 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3514 | struct intel_pipe_crc_entry *entries; |
| 3515 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3516 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 3517 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 3518 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 3519 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 3520 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3521 | GFP_KERNEL); |
| 3522 | if (!entries) |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3523 | return -ENOMEM; |
| 3524 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3525 | /* |
| 3526 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 3527 | * enabled and disabled dynamically based on package C states, |
| 3528 | * user space can't make reliable use of the CRCs, so let's just |
| 3529 | * completely disable it. |
| 3530 | */ |
| 3531 | hsw_disable_ips(crtc); |
| 3532 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3533 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 3534 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3535 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3536 | pipe_crc->head = 0; |
| 3537 | pipe_crc->tail = 0; |
| 3538 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3539 | } |
| 3540 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3541 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3542 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3543 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 3544 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 3545 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3546 | /* real source -> none transition */ |
| 3547 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3548 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3549 | struct intel_crtc *crtc = |
| 3550 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3551 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3552 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 3553 | pipe_name(pipe)); |
| 3554 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3555 | drm_modeset_lock(&crtc->base.mutex, NULL); |
| 3556 | if (crtc->active) |
| 3557 | intel_wait_for_vblank(dev, pipe); |
| 3558 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 3559 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3560 | spin_lock_irq(&pipe_crc->lock); |
| 3561 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3562 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3563 | pipe_crc->head = 0; |
| 3564 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3565 | spin_unlock_irq(&pipe_crc->lock); |
| 3566 | |
| 3567 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3568 | |
| 3569 | if (IS_G4X(dev)) |
| 3570 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3571 | else if (IS_VALLEYVIEW(dev)) |
| 3572 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3573 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3574 | hsw_undo_trans_edp_pipe_A_crc_wa(dev); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3575 | |
| 3576 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3577 | } |
| 3578 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3579 | return 0; |
| 3580 | } |
| 3581 | |
| 3582 | /* |
| 3583 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3584 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 3585 | * object: 'pipe' |
| 3586 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3587 | * source: (none | plane1 | plane2 | pf) |
| 3588 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 3589 | * |
| 3590 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3591 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 3592 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3593 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3594 | 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] | 3595 | { |
| 3596 | int n_words = 0; |
| 3597 | |
| 3598 | while (*buf) { |
| 3599 | char *end; |
| 3600 | |
| 3601 | /* skip leading white space */ |
| 3602 | buf = skip_spaces(buf); |
| 3603 | if (!*buf) |
| 3604 | break; /* end of buffer */ |
| 3605 | |
| 3606 | /* find end of word */ |
| 3607 | for (end = buf; *end && !isspace(*end); end++) |
| 3608 | ; |
| 3609 | |
| 3610 | if (n_words == max_words) { |
| 3611 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 3612 | max_words); |
| 3613 | return -EINVAL; /* ran out of words[] before bytes */ |
| 3614 | } |
| 3615 | |
| 3616 | if (*end) |
| 3617 | *end++ = '\0'; |
| 3618 | words[n_words++] = buf; |
| 3619 | buf = end; |
| 3620 | } |
| 3621 | |
| 3622 | return n_words; |
| 3623 | } |
| 3624 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3625 | enum intel_pipe_crc_object { |
| 3626 | PIPE_CRC_OBJECT_PIPE, |
| 3627 | }; |
| 3628 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3629 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3630 | "pipe", |
| 3631 | }; |
| 3632 | |
| 3633 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3634 | 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] | 3635 | { |
| 3636 | int i; |
| 3637 | |
| 3638 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 3639 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3640 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3641 | return 0; |
| 3642 | } |
| 3643 | |
| 3644 | return -EINVAL; |
| 3645 | } |
| 3646 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3647 | 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] | 3648 | { |
| 3649 | const char name = buf[0]; |
| 3650 | |
| 3651 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 3652 | return -EINVAL; |
| 3653 | |
| 3654 | *pipe = name - 'A'; |
| 3655 | |
| 3656 | return 0; |
| 3657 | } |
| 3658 | |
| 3659 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3660 | 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] | 3661 | { |
| 3662 | int i; |
| 3663 | |
| 3664 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 3665 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3666 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3667 | return 0; |
| 3668 | } |
| 3669 | |
| 3670 | return -EINVAL; |
| 3671 | } |
| 3672 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3673 | 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] | 3674 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3675 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3676 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3677 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3678 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3679 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3680 | enum intel_pipe_crc_source source; |
| 3681 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3682 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3683 | if (n_words != N_WORDS) { |
| 3684 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 3685 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3686 | return -EINVAL; |
| 3687 | } |
| 3688 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3689 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3690 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3691 | return -EINVAL; |
| 3692 | } |
| 3693 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3694 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3695 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 3696 | return -EINVAL; |
| 3697 | } |
| 3698 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3699 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3700 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3701 | return -EINVAL; |
| 3702 | } |
| 3703 | |
| 3704 | return pipe_crc_set_source(dev, pipe, source); |
| 3705 | } |
| 3706 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3707 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 3708 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3709 | { |
| 3710 | struct seq_file *m = file->private_data; |
| 3711 | struct drm_device *dev = m->private; |
| 3712 | char *tmpbuf; |
| 3713 | int ret; |
| 3714 | |
| 3715 | if (len == 0) |
| 3716 | return 0; |
| 3717 | |
| 3718 | if (len > PAGE_SIZE - 1) { |
| 3719 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 3720 | PAGE_SIZE); |
| 3721 | return -E2BIG; |
| 3722 | } |
| 3723 | |
| 3724 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 3725 | if (!tmpbuf) |
| 3726 | return -ENOMEM; |
| 3727 | |
| 3728 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 3729 | ret = -EFAULT; |
| 3730 | goto out; |
| 3731 | } |
| 3732 | tmpbuf[len] = '\0'; |
| 3733 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3734 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3735 | |
| 3736 | out: |
| 3737 | kfree(tmpbuf); |
| 3738 | if (ret < 0) |
| 3739 | return ret; |
| 3740 | |
| 3741 | *offp += len; |
| 3742 | return len; |
| 3743 | } |
| 3744 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3745 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3746 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3747 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3748 | .read = seq_read, |
| 3749 | .llseek = seq_lseek, |
| 3750 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3751 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3752 | }; |
| 3753 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3754 | 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] | 3755 | { |
| 3756 | struct drm_device *dev = m->private; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 3757 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3758 | int level; |
| 3759 | |
| 3760 | drm_modeset_lock_all(dev); |
| 3761 | |
| 3762 | for (level = 0; level < num_levels; level++) { |
| 3763 | unsigned int latency = wm[level]; |
| 3764 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3765 | /* |
| 3766 | * - WM1+ latency values in 0.5us units |
| 3767 | * - latencies are in us on gen9 |
| 3768 | */ |
| 3769 | if (INTEL_INFO(dev)->gen >= 9) |
| 3770 | latency *= 10; |
| 3771 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3772 | latency *= 5; |
| 3773 | |
| 3774 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3775 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3776 | } |
| 3777 | |
| 3778 | drm_modeset_unlock_all(dev); |
| 3779 | } |
| 3780 | |
| 3781 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3782 | { |
| 3783 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3784 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3785 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3786 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3787 | if (INTEL_INFO(dev)->gen >= 9) |
| 3788 | latencies = dev_priv->wm.skl_latency; |
| 3789 | else |
| 3790 | latencies = to_i915(dev)->wm.pri_latency; |
| 3791 | |
| 3792 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3793 | |
| 3794 | return 0; |
| 3795 | } |
| 3796 | |
| 3797 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3798 | { |
| 3799 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3800 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3801 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3802 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3803 | if (INTEL_INFO(dev)->gen >= 9) |
| 3804 | latencies = dev_priv->wm.skl_latency; |
| 3805 | else |
| 3806 | latencies = to_i915(dev)->wm.spr_latency; |
| 3807 | |
| 3808 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3809 | |
| 3810 | return 0; |
| 3811 | } |
| 3812 | |
| 3813 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3814 | { |
| 3815 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3816 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3817 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3818 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3819 | if (INTEL_INFO(dev)->gen >= 9) |
| 3820 | latencies = dev_priv->wm.skl_latency; |
| 3821 | else |
| 3822 | latencies = to_i915(dev)->wm.cur_latency; |
| 3823 | |
| 3824 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3825 | |
| 3826 | return 0; |
| 3827 | } |
| 3828 | |
| 3829 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3830 | { |
| 3831 | struct drm_device *dev = inode->i_private; |
| 3832 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3833 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3834 | return -ENODEV; |
| 3835 | |
| 3836 | return single_open(file, pri_wm_latency_show, dev); |
| 3837 | } |
| 3838 | |
| 3839 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3840 | { |
| 3841 | struct drm_device *dev = inode->i_private; |
| 3842 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3843 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3844 | return -ENODEV; |
| 3845 | |
| 3846 | return single_open(file, spr_wm_latency_show, dev); |
| 3847 | } |
| 3848 | |
| 3849 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3850 | { |
| 3851 | struct drm_device *dev = inode->i_private; |
| 3852 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3853 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3854 | return -ENODEV; |
| 3855 | |
| 3856 | return single_open(file, cur_wm_latency_show, dev); |
| 3857 | } |
| 3858 | |
| 3859 | 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] | 3860 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3861 | { |
| 3862 | struct seq_file *m = file->private_data; |
| 3863 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3864 | uint16_t new[8] = { 0 }; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 3865 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3866 | int level; |
| 3867 | int ret; |
| 3868 | char tmp[32]; |
| 3869 | |
| 3870 | if (len >= sizeof(tmp)) |
| 3871 | return -EINVAL; |
| 3872 | |
| 3873 | if (copy_from_user(tmp, ubuf, len)) |
| 3874 | return -EFAULT; |
| 3875 | |
| 3876 | tmp[len] = '\0'; |
| 3877 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3878 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3879 | &new[0], &new[1], &new[2], &new[3], |
| 3880 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3881 | if (ret != num_levels) |
| 3882 | return -EINVAL; |
| 3883 | |
| 3884 | drm_modeset_lock_all(dev); |
| 3885 | |
| 3886 | for (level = 0; level < num_levels; level++) |
| 3887 | wm[level] = new[level]; |
| 3888 | |
| 3889 | drm_modeset_unlock_all(dev); |
| 3890 | |
| 3891 | return len; |
| 3892 | } |
| 3893 | |
| 3894 | |
| 3895 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3896 | size_t len, loff_t *offp) |
| 3897 | { |
| 3898 | struct seq_file *m = file->private_data; |
| 3899 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3900 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3901 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3902 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3903 | if (INTEL_INFO(dev)->gen >= 9) |
| 3904 | latencies = dev_priv->wm.skl_latency; |
| 3905 | else |
| 3906 | latencies = to_i915(dev)->wm.pri_latency; |
| 3907 | |
| 3908 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3909 | } |
| 3910 | |
| 3911 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3912 | size_t len, loff_t *offp) |
| 3913 | { |
| 3914 | struct seq_file *m = file->private_data; |
| 3915 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3916 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3917 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3918 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3919 | if (INTEL_INFO(dev)->gen >= 9) |
| 3920 | latencies = dev_priv->wm.skl_latency; |
| 3921 | else |
| 3922 | latencies = to_i915(dev)->wm.spr_latency; |
| 3923 | |
| 3924 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3925 | } |
| 3926 | |
| 3927 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3928 | size_t len, loff_t *offp) |
| 3929 | { |
| 3930 | struct seq_file *m = file->private_data; |
| 3931 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3932 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3933 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3934 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3935 | if (INTEL_INFO(dev)->gen >= 9) |
| 3936 | latencies = dev_priv->wm.skl_latency; |
| 3937 | else |
| 3938 | latencies = to_i915(dev)->wm.cur_latency; |
| 3939 | |
| 3940 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3941 | } |
| 3942 | |
| 3943 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3944 | .owner = THIS_MODULE, |
| 3945 | .open = pri_wm_latency_open, |
| 3946 | .read = seq_read, |
| 3947 | .llseek = seq_lseek, |
| 3948 | .release = single_release, |
| 3949 | .write = pri_wm_latency_write |
| 3950 | }; |
| 3951 | |
| 3952 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3953 | .owner = THIS_MODULE, |
| 3954 | .open = spr_wm_latency_open, |
| 3955 | .read = seq_read, |
| 3956 | .llseek = seq_lseek, |
| 3957 | .release = single_release, |
| 3958 | .write = spr_wm_latency_write |
| 3959 | }; |
| 3960 | |
| 3961 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3962 | .owner = THIS_MODULE, |
| 3963 | .open = cur_wm_latency_open, |
| 3964 | .read = seq_read, |
| 3965 | .llseek = seq_lseek, |
| 3966 | .release = single_release, |
| 3967 | .write = cur_wm_latency_write |
| 3968 | }; |
| 3969 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3970 | static int |
| 3971 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3972 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3973 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3974 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3975 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3976 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3977 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3978 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3979 | } |
| 3980 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3981 | static int |
| 3982 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3983 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3984 | struct drm_device *dev = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3985 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3986 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3987 | /* |
| 3988 | * There is no safeguard against this debugfs entry colliding |
| 3989 | * with the hangcheck calling same i915_handle_error() in |
| 3990 | * parallel, causing an explosion. For now we assume that the |
| 3991 | * test harness is responsible enough not to inject gpu hangs |
| 3992 | * while it is writing to 'i915_wedged' |
| 3993 | */ |
| 3994 | |
| 3995 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
| 3996 | return -EAGAIN; |
| 3997 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3998 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3999 | |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4000 | i915_handle_error(dev, val, |
| 4001 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4002 | |
| 4003 | intel_runtime_pm_put(dev_priv); |
| 4004 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4005 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4006 | } |
| 4007 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4008 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4009 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4010 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4011 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4012 | static int |
| 4013 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4014 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4015 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4016 | struct drm_i915_private *dev_priv = dev->dev_private; |
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 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4019 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4020 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4021 | } |
| 4022 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4023 | static int |
| 4024 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4025 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4026 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4027 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4028 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4029 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4030 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4031 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4032 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4033 | if (ret) |
| 4034 | return ret; |
| 4035 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 4036 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4037 | mutex_unlock(&dev->struct_mutex); |
| 4038 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4039 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4040 | } |
| 4041 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4042 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 4043 | i915_ring_stop_get, i915_ring_stop_set, |
| 4044 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 4045 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4046 | static int |
| 4047 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4048 | { |
| 4049 | struct drm_device *dev = data; |
| 4050 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4051 | |
| 4052 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4053 | return 0; |
| 4054 | } |
| 4055 | |
| 4056 | static int |
| 4057 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4058 | { |
| 4059 | struct drm_device *dev = data; |
| 4060 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4061 | int ret; |
| 4062 | |
| 4063 | /* Lock against concurrent debugfs callers */ |
| 4064 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4065 | if (ret) |
| 4066 | return ret; |
| 4067 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4068 | mutex_unlock(&dev->struct_mutex); |
| 4069 | |
| 4070 | return 0; |
| 4071 | } |
| 4072 | |
| 4073 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4074 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4075 | "0x%08llx\n"); |
| 4076 | |
| 4077 | static int |
| 4078 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4079 | { |
| 4080 | struct drm_device *dev = data; |
| 4081 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4082 | |
| 4083 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4084 | |
| 4085 | return 0; |
| 4086 | } |
| 4087 | |
| 4088 | static int |
| 4089 | i915_ring_test_irq_set(void *data, u64 val) |
| 4090 | { |
| 4091 | struct drm_device *dev = data; |
| 4092 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4093 | int ret; |
| 4094 | |
| 4095 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 4096 | |
| 4097 | /* Lock against concurrent debugfs callers */ |
| 4098 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4099 | if (ret) |
| 4100 | return ret; |
| 4101 | |
| 4102 | dev_priv->gpu_error.test_irq_rings = val; |
| 4103 | mutex_unlock(&dev->struct_mutex); |
| 4104 | |
| 4105 | return 0; |
| 4106 | } |
| 4107 | |
| 4108 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4109 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4110 | "0x%08llx\n"); |
| 4111 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4112 | #define DROP_UNBOUND 0x1 |
| 4113 | #define DROP_BOUND 0x2 |
| 4114 | #define DROP_RETIRE 0x4 |
| 4115 | #define DROP_ACTIVE 0x8 |
| 4116 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4117 | DROP_BOUND | \ |
| 4118 | DROP_RETIRE | \ |
| 4119 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4120 | static int |
| 4121 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4122 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4123 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4124 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4125 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4126 | } |
| 4127 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4128 | static int |
| 4129 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4130 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4131 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4132 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4133 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4134 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4135 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4136 | |
| 4137 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4138 | * on ioctls on -EAGAIN. */ |
| 4139 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4140 | if (ret) |
| 4141 | return ret; |
| 4142 | |
| 4143 | if (val & DROP_ACTIVE) { |
| 4144 | ret = i915_gpu_idle(dev); |
| 4145 | if (ret) |
| 4146 | goto unlock; |
| 4147 | } |
| 4148 | |
| 4149 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 4150 | i915_gem_retire_requests(dev); |
| 4151 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4152 | if (val & DROP_BOUND) |
| 4153 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4154 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4155 | if (val & DROP_UNBOUND) |
| 4156 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4157 | |
| 4158 | unlock: |
| 4159 | mutex_unlock(&dev->struct_mutex); |
| 4160 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4161 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4162 | } |
| 4163 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4164 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4165 | i915_drop_caches_get, i915_drop_caches_set, |
| 4166 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4167 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4168 | static int |
| 4169 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4170 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4171 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4172 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4173 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4174 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4175 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4176 | return -ENODEV; |
| 4177 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4178 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4179 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4180 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4181 | if (ret) |
| 4182 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4183 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4184 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4185 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4186 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4187 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4188 | } |
| 4189 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4190 | static int |
| 4191 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4192 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4193 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4194 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4195 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4196 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4197 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4198 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4199 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4200 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4201 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4202 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4203 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4204 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4205 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4206 | if (ret) |
| 4207 | return ret; |
| 4208 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4209 | /* |
| 4210 | * Turbo will still be enabled, but won't go above the set value. |
| 4211 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4212 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4213 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4214 | hw_max = dev_priv->rps.max_freq; |
| 4215 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4216 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4217 | 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] | 4218 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4219 | return -EINVAL; |
| 4220 | } |
| 4221 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4222 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4223 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4224 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4225 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4226 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4227 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4228 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4229 | } |
| 4230 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4231 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4232 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4233 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4234 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4235 | static int |
| 4236 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4237 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4238 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4239 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4240 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4241 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4242 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4243 | return -ENODEV; |
| 4244 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4245 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4246 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4247 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4248 | if (ret) |
| 4249 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4250 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4251 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4252 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4253 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4254 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4255 | } |
| 4256 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4257 | static int |
| 4258 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4259 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4260 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4261 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4262 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4263 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4264 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4265 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4266 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4267 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4268 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4269 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4270 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4271 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4272 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4273 | if (ret) |
| 4274 | return ret; |
| 4275 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4276 | /* |
| 4277 | * Turbo will still be enabled, but won't go below the set value. |
| 4278 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4279 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4280 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4281 | hw_max = dev_priv->rps.max_freq; |
| 4282 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4283 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4284 | 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] | 4285 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4286 | return -EINVAL; |
| 4287 | } |
| 4288 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4289 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4290 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4291 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4292 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4293 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4294 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4295 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4296 | } |
| 4297 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4298 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4299 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4300 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4301 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4302 | static int |
| 4303 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4304 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4305 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4306 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4307 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4308 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4309 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4310 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4311 | return -ENODEV; |
| 4312 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4313 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4314 | if (ret) |
| 4315 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4316 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4317 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4318 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4319 | |
| 4320 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4321 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 4322 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4323 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4324 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4325 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4326 | } |
| 4327 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4328 | static int |
| 4329 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4330 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4331 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4332 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4333 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4334 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4335 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4336 | return -ENODEV; |
| 4337 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4338 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4339 | return -EINVAL; |
| 4340 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4341 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4342 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4343 | |
| 4344 | /* Update the cache sharing policy here as well */ |
| 4345 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4346 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4347 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4348 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4349 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4350 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4351 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4352 | } |
| 4353 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4354 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4355 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4356 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4357 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4358 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4359 | { |
| 4360 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 4361 | struct drm_device *dev = node->minor->dev; |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4362 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4363 | 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] | 4364 | |
| 4365 | if (INTEL_INFO(dev)->gen < 9) |
| 4366 | return -ENODEV; |
| 4367 | |
| 4368 | seq_puts(m, "SSEU Device Info\n"); |
| 4369 | seq_printf(m, " Available Slice Total: %u\n", |
| 4370 | INTEL_INFO(dev)->slice_total); |
| 4371 | seq_printf(m, " Available Subslice Total: %u\n", |
| 4372 | INTEL_INFO(dev)->subslice_total); |
| 4373 | seq_printf(m, " Available Subslice Per Slice: %u\n", |
| 4374 | INTEL_INFO(dev)->subslice_per_slice); |
| 4375 | seq_printf(m, " Available EU Total: %u\n", |
| 4376 | INTEL_INFO(dev)->eu_total); |
| 4377 | seq_printf(m, " Available EU Per Subslice: %u\n", |
| 4378 | INTEL_INFO(dev)->eu_per_subslice); |
| 4379 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4380 | yesno(INTEL_INFO(dev)->has_slice_pg)); |
| 4381 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4382 | yesno(INTEL_INFO(dev)->has_subslice_pg)); |
| 4383 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4384 | yesno(INTEL_INFO(dev)->has_eu_pg)); |
| 4385 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4386 | seq_puts(m, "SSEU Device Status\n"); |
| 4387 | if (IS_SKYLAKE(dev)) { |
| 4388 | const int s_max = 3, ss_max = 4; |
| 4389 | int s, ss; |
| 4390 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4391 | |
| 4392 | s_reg[0] = I915_READ(GEN9_SLICE0_PGCTL_ACK); |
| 4393 | s_reg[1] = I915_READ(GEN9_SLICE1_PGCTL_ACK); |
| 4394 | s_reg[2] = I915_READ(GEN9_SLICE2_PGCTL_ACK); |
| 4395 | eu_reg[0] = I915_READ(GEN9_SLICE0_SS01_EU_PGCTL_ACK); |
| 4396 | eu_reg[1] = I915_READ(GEN9_SLICE0_SS23_EU_PGCTL_ACK); |
| 4397 | eu_reg[2] = I915_READ(GEN9_SLICE1_SS01_EU_PGCTL_ACK); |
| 4398 | eu_reg[3] = I915_READ(GEN9_SLICE1_SS23_EU_PGCTL_ACK); |
| 4399 | eu_reg[4] = I915_READ(GEN9_SLICE2_SS01_EU_PGCTL_ACK); |
| 4400 | eu_reg[5] = I915_READ(GEN9_SLICE2_SS23_EU_PGCTL_ACK); |
| 4401 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4402 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4403 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4404 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4405 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4406 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4407 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4408 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4409 | |
| 4410 | for (s = 0; s < s_max; s++) { |
| 4411 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4412 | /* skip disabled slice */ |
| 4413 | continue; |
| 4414 | |
| 4415 | s_tot++; |
| 4416 | ss_per = INTEL_INFO(dev)->subslice_per_slice; |
| 4417 | ss_tot += ss_per; |
| 4418 | for (ss = 0; ss < ss_max; ss++) { |
| 4419 | unsigned int eu_cnt; |
| 4420 | |
| 4421 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4422 | eu_mask[ss%2]); |
| 4423 | eu_tot += eu_cnt; |
| 4424 | eu_per = max(eu_per, eu_cnt); |
| 4425 | } |
| 4426 | } |
| 4427 | } |
| 4428 | seq_printf(m, " Enabled Slice Total: %u\n", s_tot); |
| 4429 | seq_printf(m, " Enabled Subslice Total: %u\n", ss_tot); |
| 4430 | seq_printf(m, " Enabled Subslice Per Slice: %u\n", ss_per); |
| 4431 | seq_printf(m, " Enabled EU Total: %u\n", eu_tot); |
| 4432 | seq_printf(m, " Enabled EU Per Subslice: %u\n", eu_per); |
| 4433 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4434 | return 0; |
| 4435 | } |
| 4436 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4437 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4438 | { |
| 4439 | struct drm_device *dev = inode->i_private; |
| 4440 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4441 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4442 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4443 | return 0; |
| 4444 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4445 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4446 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4447 | |
| 4448 | return 0; |
| 4449 | } |
| 4450 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4451 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4452 | { |
| 4453 | struct drm_device *dev = inode->i_private; |
| 4454 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4455 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4456 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4457 | return 0; |
| 4458 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4459 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4460 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4461 | |
| 4462 | return 0; |
| 4463 | } |
| 4464 | |
| 4465 | static const struct file_operations i915_forcewake_fops = { |
| 4466 | .owner = THIS_MODULE, |
| 4467 | .open = i915_forcewake_open, |
| 4468 | .release = i915_forcewake_release, |
| 4469 | }; |
| 4470 | |
| 4471 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 4472 | { |
| 4473 | struct drm_device *dev = minor->dev; |
| 4474 | struct dentry *ent; |
| 4475 | |
| 4476 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4477 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4478 | root, dev, |
| 4479 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4480 | if (!ent) |
| 4481 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4482 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4483 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4484 | } |
| 4485 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4486 | static int i915_debugfs_create(struct dentry *root, |
| 4487 | struct drm_minor *minor, |
| 4488 | const char *name, |
| 4489 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4490 | { |
| 4491 | struct drm_device *dev = minor->dev; |
| 4492 | struct dentry *ent; |
| 4493 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4494 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4495 | S_IRUGO | S_IWUSR, |
| 4496 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4497 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4498 | if (!ent) |
| 4499 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4500 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4501 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4502 | } |
| 4503 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4504 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4505 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4506 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4507 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 4508 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 4509 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 4510 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4511 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4512 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4513 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4514 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4515 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4516 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 4517 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 4518 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 4519 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 4520 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4521 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4522 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4523 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4524 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4525 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4526 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4527 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4528 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4529 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4530 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4531 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4532 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4533 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 4534 | {"i915_execlists", i915_execlists, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4535 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4536 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4537 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4538 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4539 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4540 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4541 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 4542 | {"i915_pc8_status", i915_pc8_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4543 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4544 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4545 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4546 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4547 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4548 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4549 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4550 | {"i915_sseu_status", i915_sseu_status, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4551 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4552 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4553 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4554 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4555 | const char *name; |
| 4556 | const struct file_operations *fops; |
| 4557 | } i915_debugfs_files[] = { |
| 4558 | {"i915_wedged", &i915_wedged_fops}, |
| 4559 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4560 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4561 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 4562 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4563 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4564 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4565 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 4566 | {"i915_error_state", &i915_error_state_fops}, |
| 4567 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4568 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4569 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4570 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4571 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 4572 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4573 | }; |
| 4574 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4575 | void intel_display_crc_init(struct drm_device *dev) |
| 4576 | { |
| 4577 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 4578 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4579 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 4580 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 4581 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4582 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4583 | pipe_crc->opened = false; |
| 4584 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4585 | init_waitqueue_head(&pipe_crc->wq); |
| 4586 | } |
| 4587 | } |
| 4588 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4589 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4590 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4591 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4592 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4593 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 4594 | if (ret) |
| 4595 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4596 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4597 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 4598 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 4599 | if (ret) |
| 4600 | return ret; |
| 4601 | } |
| 4602 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4603 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4604 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 4605 | i915_debugfs_files[i].name, |
| 4606 | i915_debugfs_files[i].fops); |
| 4607 | if (ret) |
| 4608 | return ret; |
| 4609 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4610 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4611 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4612 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4613 | minor->debugfs_root, minor); |
| 4614 | } |
| 4615 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4616 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4617 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4618 | int i; |
| 4619 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4620 | drm_debugfs_remove_files(i915_debugfs_list, |
| 4621 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4622 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4623 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 4624 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4625 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 4626 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4627 | struct drm_info_list *info_list = |
| 4628 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 4629 | |
| 4630 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4631 | } |
| 4632 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4633 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4634 | struct drm_info_list *info_list = |
| 4635 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 4636 | |
| 4637 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4638 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4639 | } |