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 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 29 | #include <linux/debugfs.h> |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 30 | #include <linux/list_sort.h> |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 31 | #include "intel_drv.h" |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 32 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 33 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 34 | { |
| 35 | return to_i915(node->minor->dev); |
| 36 | } |
| 37 | |
Damien Lespiau | 497666d | 2013-10-15 18:55:39 +0100 | [diff] [blame] | 38 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 39 | * allocated we need to hook into the minor for release. */ |
| 40 | static int |
| 41 | drm_add_fake_info_node(struct drm_minor *minor, |
| 42 | struct dentry *ent, |
| 43 | const void *key) |
| 44 | { |
| 45 | struct drm_info_node *node; |
| 46 | |
| 47 | node = kmalloc(sizeof(*node), GFP_KERNEL); |
| 48 | if (node == NULL) { |
| 49 | debugfs_remove(ent); |
| 50 | return -ENOMEM; |
| 51 | } |
| 52 | |
| 53 | node->minor = minor; |
| 54 | node->dent = ent; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 55 | node->info_ent = (void *)key; |
Damien Lespiau | 497666d | 2013-10-15 18:55:39 +0100 | [diff] [blame] | 56 | |
| 57 | mutex_lock(&minor->debugfs_lock); |
| 58 | list_add(&node->list, &minor->debugfs_list); |
| 59 | mutex_unlock(&minor->debugfs_lock); |
| 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 64 | static int i915_capabilities(struct seq_file *m, void *data) |
| 65 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 66 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 67 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 68 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 69 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 70 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 71 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 72 | #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
Joonas Lahtinen | 604db65 | 2016-10-05 13:50:16 +0300 | [diff] [blame] | 73 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 74 | #undef PRINT_FLAG |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 75 | |
| 76 | return 0; |
| 77 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 78 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 79 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 80 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 81 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 84 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 85 | { |
| 86 | return obj->pin_display ? 'p' : ' '; |
| 87 | } |
| 88 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 89 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 90 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 91 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 92 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 93 | case I915_TILING_NONE: return ' '; |
| 94 | case I915_TILING_X: return 'X'; |
| 95 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 96 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 99 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 100 | { |
Chris Wilson | 275f039 | 2016-10-24 13:42:14 +0100 | [diff] [blame] | 101 | return !list_empty(&obj->userfault_link) ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 102 | } |
| 103 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 104 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 105 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 106 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 109 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 110 | { |
| 111 | u64 size = 0; |
| 112 | struct i915_vma *vma; |
| 113 | |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 114 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 115 | if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 116 | size += vma->node.size; |
| 117 | } |
| 118 | |
| 119 | return size; |
| 120 | } |
| 121 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 122 | static void |
| 123 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 124 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 125 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 126 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 127 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 128 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 129 | int pin_count = 0; |
| 130 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 131 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 132 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 133 | seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x %s%s%s", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 134 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 135 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 136 | get_pin_flag(obj), |
| 137 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 138 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 139 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 140 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 141 | obj->base.read_domains, |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 142 | obj->base.write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 143 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 144 | obj->mm.dirty ? " dirty" : "", |
| 145 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 146 | if (obj->base.name) |
| 147 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 148 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 149 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 150 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 151 | } |
| 152 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 153 | if (obj->pin_display) |
| 154 | seq_printf(m, " (display)"); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 155 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 156 | if (!drm_mm_node_allocated(&vma->node)) |
| 157 | continue; |
| 158 | |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 159 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 160 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 161 | vma->node.start, vma->node.size); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 162 | if (i915_vma_is_ggtt(vma)) { |
| 163 | switch (vma->ggtt_view.type) { |
| 164 | case I915_GGTT_VIEW_NORMAL: |
| 165 | seq_puts(m, ", normal"); |
| 166 | break; |
| 167 | |
| 168 | case I915_GGTT_VIEW_PARTIAL: |
| 169 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 170 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 171 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 172 | break; |
| 173 | |
| 174 | case I915_GGTT_VIEW_ROTATED: |
| 175 | seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 176 | vma->ggtt_view.rotated.plane[0].width, |
| 177 | vma->ggtt_view.rotated.plane[0].height, |
| 178 | vma->ggtt_view.rotated.plane[0].stride, |
| 179 | vma->ggtt_view.rotated.plane[0].offset, |
| 180 | vma->ggtt_view.rotated.plane[1].width, |
| 181 | vma->ggtt_view.rotated.plane[1].height, |
| 182 | vma->ggtt_view.rotated.plane[1].stride, |
| 183 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 184 | break; |
| 185 | |
| 186 | default: |
| 187 | MISSING_CASE(vma->ggtt_view.type); |
| 188 | break; |
| 189 | } |
| 190 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 191 | if (vma->fence) |
| 192 | seq_printf(m, " , fence: %d%s", |
| 193 | vma->fence->id, |
| 194 | i915_gem_active_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 195 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 196 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 197 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 198 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 199 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 200 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 201 | if (engine) |
| 202 | seq_printf(m, " (%s)", engine->name); |
| 203 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 204 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 205 | if (frontbuffer_bits) |
| 206 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 207 | } |
| 208 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 209 | static int obj_rank_by_stolen(void *priv, |
| 210 | struct list_head *A, struct list_head *B) |
| 211 | { |
| 212 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 213 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 214 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 215 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 216 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 217 | if (a->stolen->start < b->stolen->start) |
| 218 | return -1; |
| 219 | if (a->stolen->start > b->stolen->start) |
| 220 | return 1; |
| 221 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 225 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 226 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 227 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 228 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 229 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 230 | LIST_HEAD(stolen); |
| 231 | int count, ret; |
| 232 | |
| 233 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 234 | if (ret) |
| 235 | return ret; |
| 236 | |
| 237 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 238 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 239 | if (obj->stolen == NULL) |
| 240 | continue; |
| 241 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 242 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 243 | |
| 244 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 245 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 246 | count++; |
| 247 | } |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 248 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 249 | if (obj->stolen == NULL) |
| 250 | continue; |
| 251 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 252 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 253 | |
| 254 | total_obj_size += obj->base.size; |
| 255 | count++; |
| 256 | } |
| 257 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 258 | seq_puts(m, "Stolen:\n"); |
| 259 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 260 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 261 | seq_puts(m, " "); |
| 262 | describe_obj(m, obj); |
| 263 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 264 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 265 | } |
| 266 | mutex_unlock(&dev->struct_mutex); |
| 267 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 268 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 269 | count, total_obj_size, total_gtt_size); |
| 270 | return 0; |
| 271 | } |
| 272 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 273 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 274 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 275 | unsigned long count; |
| 276 | u64 total, unbound; |
| 277 | u64 global, shared; |
| 278 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 279 | }; |
| 280 | |
| 281 | static int per_file_stats(int id, void *ptr, void *data) |
| 282 | { |
| 283 | struct drm_i915_gem_object *obj = ptr; |
| 284 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 285 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 286 | |
| 287 | stats->count++; |
| 288 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 289 | if (!obj->bind_count) |
| 290 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 291 | if (obj->base.name || obj->base.dma_buf) |
| 292 | stats->shared += obj->base.size; |
| 293 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 294 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 295 | if (!drm_mm_node_allocated(&vma->node)) |
| 296 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 297 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 298 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 299 | stats->global += vma->node.size; |
| 300 | } else { |
| 301 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 302 | |
Chris Wilson | 2bfa996 | 2016-08-04 07:52:25 +0100 | [diff] [blame] | 303 | if (ppgtt->base.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 304 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 305 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 306 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 307 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 308 | stats->active += vma->node.size; |
| 309 | else |
| 310 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 316 | #define print_file_stats(m, name, stats) do { \ |
| 317 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 318 | seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 319 | name, \ |
| 320 | stats.count, \ |
| 321 | stats.total, \ |
| 322 | stats.active, \ |
| 323 | stats.inactive, \ |
| 324 | stats.global, \ |
| 325 | stats.shared, \ |
| 326 | stats.unbound); \ |
| 327 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 328 | |
| 329 | static void print_batch_pool_stats(struct seq_file *m, |
| 330 | struct drm_i915_private *dev_priv) |
| 331 | { |
| 332 | struct drm_i915_gem_object *obj; |
| 333 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 334 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 335 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 336 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 337 | |
| 338 | memset(&stats, 0, sizeof(stats)); |
| 339 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 340 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 341 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 342 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 343 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 344 | batch_pool_link) |
| 345 | per_file_stats(0, obj, &stats); |
| 346 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 347 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 348 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 349 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 352 | static int per_file_ctx_stats(int id, void *ptr, void *data) |
| 353 | { |
| 354 | struct i915_gem_context *ctx = ptr; |
| 355 | int n; |
| 356 | |
| 357 | for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) { |
| 358 | if (ctx->engine[n].state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 359 | per_file_stats(0, ctx->engine[n].state->obj, data); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 360 | if (ctx->engine[n].ring) |
Chris Wilson | 57e8853 | 2016-08-15 10:48:57 +0100 | [diff] [blame] | 361 | per_file_stats(0, ctx->engine[n].ring->vma->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | static void print_context_stats(struct seq_file *m, |
| 368 | struct drm_i915_private *dev_priv) |
| 369 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 370 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 371 | struct file_stats stats; |
| 372 | struct drm_file *file; |
| 373 | |
| 374 | memset(&stats, 0, sizeof(stats)); |
| 375 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 376 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 377 | if (dev_priv->kernel_context) |
| 378 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 379 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 380 | list_for_each_entry(file, &dev->filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 381 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 382 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 383 | } |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 384 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 385 | |
| 386 | print_file_stats(m, "[k]contexts", stats); |
| 387 | } |
| 388 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 389 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 390 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 391 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 392 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 393 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 394 | u32 count, mapped_count, purgeable_count, dpy_count; |
| 395 | u64 size, mapped_size, purgeable_size, dpy_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 396 | struct drm_i915_gem_object *obj; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 397 | struct drm_file *file; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 398 | int ret; |
| 399 | |
| 400 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 401 | if (ret) |
| 402 | return ret; |
| 403 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 404 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 405 | dev_priv->mm.object_count, |
| 406 | dev_priv->mm.object_memory); |
| 407 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 408 | size = count = 0; |
| 409 | mapped_size = mapped_count = 0; |
| 410 | purgeable_size = purgeable_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 411 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 412 | size += obj->base.size; |
| 413 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 414 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 415 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 416 | purgeable_size += obj->base.size; |
| 417 | ++purgeable_count; |
| 418 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 419 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 420 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 421 | mapped_count++; |
| 422 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 423 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 424 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 425 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 426 | |
| 427 | size = count = dpy_size = dpy_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 428 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 429 | size += obj->base.size; |
| 430 | ++count; |
| 431 | |
| 432 | if (obj->pin_display) { |
| 433 | dpy_size += obj->base.size; |
| 434 | ++dpy_count; |
| 435 | } |
| 436 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 437 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 438 | purgeable_size += obj->base.size; |
| 439 | ++purgeable_count; |
| 440 | } |
| 441 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 442 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 443 | mapped_count++; |
| 444 | mapped_size += obj->base.size; |
| 445 | } |
| 446 | } |
| 447 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 448 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 449 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 450 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 451 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 452 | mapped_count, mapped_size); |
| 453 | seq_printf(m, "%u display objects (pinned), %llu bytes\n", |
| 454 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 455 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 456 | seq_printf(m, "%llu [%llu] gtt total\n", |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 457 | ggtt->base.total, ggtt->mappable_end - ggtt->base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 458 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 459 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 460 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 461 | mutex_unlock(&dev->struct_mutex); |
| 462 | |
| 463 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 464 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 465 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 466 | struct file_stats stats; |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 467 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 468 | struct drm_i915_gem_request *request; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 469 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 470 | |
| 471 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 472 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 473 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 474 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 475 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 476 | /* |
| 477 | * Although we have a valid reference on file->pid, that does |
| 478 | * not guarantee that the task_struct who called get_pid() is |
| 479 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 480 | * Therefore, we need to protect this ->comm access using RCU. |
| 481 | */ |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 482 | mutex_lock(&dev->struct_mutex); |
| 483 | request = list_first_entry_or_null(&file_priv->mm.request_list, |
| 484 | struct drm_i915_gem_request, |
| 485 | client_list); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 486 | rcu_read_lock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 487 | task = pid_task(request && request->ctx->pid ? |
| 488 | request->ctx->pid : file->pid, |
| 489 | PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 490 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 491 | rcu_read_unlock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 492 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 493 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 494 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 495 | |
| 496 | return 0; |
| 497 | } |
| 498 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 499 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 500 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 501 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 502 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 503 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 5f4b091 | 2016-08-19 12:56:25 +0100 | [diff] [blame] | 504 | bool show_pin_display_only = !!node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 505 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 506 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 507 | int count, ret; |
| 508 | |
| 509 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 510 | if (ret) |
| 511 | return ret; |
| 512 | |
| 513 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 514 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 515 | if (show_pin_display_only && !obj->pin_display) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 516 | continue; |
| 517 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 518 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 519 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 520 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 521 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 522 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 523 | count++; |
| 524 | } |
| 525 | |
| 526 | mutex_unlock(&dev->struct_mutex); |
| 527 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 528 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 529 | count, total_obj_size, total_gtt_size); |
| 530 | |
| 531 | return 0; |
| 532 | } |
| 533 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 534 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 535 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 536 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 537 | struct drm_device *dev = &dev_priv->drm; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 538 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 539 | int ret; |
| 540 | |
| 541 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 542 | if (ret) |
| 543 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 544 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 545 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 546 | const char pipe = pipe_name(crtc->pipe); |
| 547 | const char plane = plane_name(crtc->plane); |
Maarten Lankhorst | 51cbaf0 | 2016-05-17 15:07:49 +0200 | [diff] [blame] | 548 | struct intel_flip_work *work; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 549 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 550 | spin_lock_irq(&dev->event_lock); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 551 | work = crtc->flip_work; |
| 552 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 553 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 554 | pipe, plane); |
| 555 | } else { |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 556 | u32 pending; |
| 557 | u32 addr; |
| 558 | |
| 559 | pending = atomic_read(&work->pending); |
| 560 | if (pending) { |
| 561 | seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n", |
| 562 | pipe, plane); |
| 563 | } else { |
| 564 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
| 565 | pipe, plane); |
| 566 | } |
| 567 | if (work->flip_queued_req) { |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 568 | struct intel_engine_cs *engine = work->flip_queued_req->engine; |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 569 | |
Chris Wilson | 312c3c4 | 2016-11-24 14:47:50 +0000 | [diff] [blame] | 570 | seq_printf(m, "Flip queued on %s at seqno %x, last submitted seqno %x [current breadcrumb %x], completed? %d\n", |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 571 | engine->name, |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 572 | work->flip_queued_req->global_seqno, |
Chris Wilson | 312c3c4 | 2016-11-24 14:47:50 +0000 | [diff] [blame] | 573 | intel_engine_last_submit(engine), |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 574 | intel_engine_get_seqno(engine), |
Chris Wilson | f69a02c | 2016-07-01 17:23:16 +0100 | [diff] [blame] | 575 | i915_gem_request_completed(work->flip_queued_req)); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 576 | } else |
| 577 | seq_printf(m, "Flip not associated with any ring\n"); |
| 578 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 579 | work->flip_queued_vblank, |
| 580 | work->flip_ready_vblank, |
| 581 | intel_crtc_get_vblank_counter(crtc)); |
| 582 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
| 583 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 584 | if (INTEL_GEN(dev_priv) >= 4) |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 585 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 586 | else |
| 587 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 588 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 589 | |
| 590 | if (work->pending_flip_obj) { |
| 591 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 592 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 593 | } |
| 594 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 595 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 596 | } |
| 597 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 598 | mutex_unlock(&dev->struct_mutex); |
| 599 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 600 | return 0; |
| 601 | } |
| 602 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 603 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 604 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 605 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 606 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 607 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 608 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 609 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 610 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 611 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 612 | |
| 613 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 614 | if (ret) |
| 615 | return ret; |
| 616 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 617 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 618 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 619 | int count; |
| 620 | |
| 621 | count = 0; |
| 622 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 623 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 624 | batch_pool_link) |
| 625 | count++; |
| 626 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 627 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 628 | |
| 629 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 630 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 631 | batch_pool_link) { |
| 632 | seq_puts(m, " "); |
| 633 | describe_obj(m, obj); |
| 634 | seq_putc(m, '\n'); |
| 635 | } |
| 636 | |
| 637 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 638 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 639 | } |
| 640 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 641 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 642 | |
| 643 | mutex_unlock(&dev->struct_mutex); |
| 644 | |
| 645 | return 0; |
| 646 | } |
| 647 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 648 | static void print_request(struct seq_file *m, |
| 649 | struct drm_i915_gem_request *rq, |
| 650 | const char *prefix) |
| 651 | { |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 652 | seq_printf(m, "%s%x [%x:%x] prio=%d @ %dms: %s\n", prefix, |
Chris Wilson | 65e4760 | 2016-10-28 13:58:49 +0100 | [diff] [blame] | 653 | rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno, |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 654 | rq->priotree.priority, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 655 | jiffies_to_msecs(jiffies - rq->emitted_jiffies), |
Chris Wilson | 562f5d4 | 2016-10-28 13:58:54 +0100 | [diff] [blame] | 656 | rq->timeline->common->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 657 | } |
| 658 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 659 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 660 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 661 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 662 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 663 | struct drm_i915_gem_request *req; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 664 | struct intel_engine_cs *engine; |
| 665 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 666 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 667 | |
| 668 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 669 | if (ret) |
| 670 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 671 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 672 | any = 0; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 673 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 674 | int count; |
| 675 | |
| 676 | count = 0; |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 677 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 678 | count++; |
| 679 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 680 | continue; |
| 681 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 682 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 683 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 684 | print_request(m, req, " "); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 685 | |
| 686 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 687 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 688 | mutex_unlock(&dev->struct_mutex); |
| 689 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 690 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 691 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 692 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 693 | return 0; |
| 694 | } |
| 695 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 696 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 697 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 698 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 699 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 700 | struct rb_node *rb; |
| 701 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 702 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 703 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 704 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 705 | spin_lock_irq(&b->lock); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 706 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 707 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 708 | |
| 709 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 710 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 711 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 712 | spin_unlock_irq(&b->lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 713 | } |
| 714 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 715 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 716 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 717 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 718 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 719 | enum intel_engine_id id; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 720 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 721 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 722 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 723 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 724 | return 0; |
| 725 | } |
| 726 | |
| 727 | |
| 728 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 729 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 730 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 731 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 732 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 733 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 734 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 735 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 736 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 737 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 738 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 739 | I915_READ(GEN8_MASTER_IRQ)); |
| 740 | |
| 741 | seq_printf(m, "Display IER:\t%08x\n", |
| 742 | I915_READ(VLV_IER)); |
| 743 | seq_printf(m, "Display IIR:\t%08x\n", |
| 744 | I915_READ(VLV_IIR)); |
| 745 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 746 | I915_READ(VLV_IIR_RW)); |
| 747 | seq_printf(m, "Display IMR:\t%08x\n", |
| 748 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 749 | for_each_pipe(dev_priv, pipe) { |
| 750 | enum intel_display_power_domain power_domain; |
| 751 | |
| 752 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 753 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 754 | power_domain)) { |
| 755 | seq_printf(m, "Pipe %c power disabled\n", |
| 756 | pipe_name(pipe)); |
| 757 | continue; |
| 758 | } |
| 759 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 760 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 761 | pipe_name(pipe), |
| 762 | I915_READ(PIPESTAT(pipe))); |
| 763 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 764 | intel_display_power_put(dev_priv, power_domain); |
| 765 | } |
| 766 | |
| 767 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 768 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 769 | I915_READ(PORT_HOTPLUG_EN)); |
| 770 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 771 | I915_READ(VLV_DPFLIPSTAT)); |
| 772 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 773 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 774 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 775 | |
| 776 | for (i = 0; i < 4; i++) { |
| 777 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 778 | i, I915_READ(GEN8_GT_IMR(i))); |
| 779 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 780 | i, I915_READ(GEN8_GT_IIR(i))); |
| 781 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 782 | i, I915_READ(GEN8_GT_IER(i))); |
| 783 | } |
| 784 | |
| 785 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 786 | I915_READ(GEN8_PCU_IMR)); |
| 787 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 788 | I915_READ(GEN8_PCU_IIR)); |
| 789 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 790 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 791 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 792 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 793 | I915_READ(GEN8_MASTER_IRQ)); |
| 794 | |
| 795 | for (i = 0; i < 4; i++) { |
| 796 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 797 | i, I915_READ(GEN8_GT_IMR(i))); |
| 798 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 799 | i, I915_READ(GEN8_GT_IIR(i))); |
| 800 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 801 | i, I915_READ(GEN8_GT_IER(i))); |
| 802 | } |
| 803 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 804 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 805 | enum intel_display_power_domain power_domain; |
| 806 | |
| 807 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 808 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 809 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 810 | seq_printf(m, "Pipe %c power disabled\n", |
| 811 | pipe_name(pipe)); |
| 812 | continue; |
| 813 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 814 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 815 | pipe_name(pipe), |
| 816 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 817 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 818 | pipe_name(pipe), |
| 819 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 820 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 821 | pipe_name(pipe), |
| 822 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 823 | |
| 824 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 828 | I915_READ(GEN8_DE_PORT_IMR)); |
| 829 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 830 | I915_READ(GEN8_DE_PORT_IIR)); |
| 831 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 832 | I915_READ(GEN8_DE_PORT_IER)); |
| 833 | |
| 834 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 835 | I915_READ(GEN8_DE_MISC_IMR)); |
| 836 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 837 | I915_READ(GEN8_DE_MISC_IIR)); |
| 838 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 839 | I915_READ(GEN8_DE_MISC_IER)); |
| 840 | |
| 841 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 842 | I915_READ(GEN8_PCU_IMR)); |
| 843 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 844 | I915_READ(GEN8_PCU_IIR)); |
| 845 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 846 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 847 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 848 | seq_printf(m, "Display IER:\t%08x\n", |
| 849 | I915_READ(VLV_IER)); |
| 850 | seq_printf(m, "Display IIR:\t%08x\n", |
| 851 | I915_READ(VLV_IIR)); |
| 852 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 853 | I915_READ(VLV_IIR_RW)); |
| 854 | seq_printf(m, "Display IMR:\t%08x\n", |
| 855 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 856 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 857 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 858 | pipe_name(pipe), |
| 859 | I915_READ(PIPESTAT(pipe))); |
| 860 | |
| 861 | seq_printf(m, "Master IER:\t%08x\n", |
| 862 | I915_READ(VLV_MASTER_IER)); |
| 863 | |
| 864 | seq_printf(m, "Render IER:\t%08x\n", |
| 865 | I915_READ(GTIER)); |
| 866 | seq_printf(m, "Render IIR:\t%08x\n", |
| 867 | I915_READ(GTIIR)); |
| 868 | seq_printf(m, "Render IMR:\t%08x\n", |
| 869 | I915_READ(GTIMR)); |
| 870 | |
| 871 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 872 | I915_READ(GEN6_PMIER)); |
| 873 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 874 | I915_READ(GEN6_PMIIR)); |
| 875 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 876 | I915_READ(GEN6_PMIMR)); |
| 877 | |
| 878 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 879 | I915_READ(PORT_HOTPLUG_EN)); |
| 880 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 881 | I915_READ(VLV_DPFLIPSTAT)); |
| 882 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 883 | I915_READ(DPINVGTT)); |
| 884 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 885 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 886 | seq_printf(m, "Interrupt enable: %08x\n", |
| 887 | I915_READ(IER)); |
| 888 | seq_printf(m, "Interrupt identity: %08x\n", |
| 889 | I915_READ(IIR)); |
| 890 | seq_printf(m, "Interrupt mask: %08x\n", |
| 891 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 892 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 893 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 894 | pipe_name(pipe), |
| 895 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 896 | } else { |
| 897 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 898 | I915_READ(DEIER)); |
| 899 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 900 | I915_READ(DEIIR)); |
| 901 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 902 | I915_READ(DEIMR)); |
| 903 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 904 | I915_READ(SDEIER)); |
| 905 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 906 | I915_READ(SDEIIR)); |
| 907 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 908 | I915_READ(SDEIMR)); |
| 909 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 910 | I915_READ(GTIER)); |
| 911 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 912 | I915_READ(GTIIR)); |
| 913 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 914 | I915_READ(GTIMR)); |
| 915 | } |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 916 | for_each_engine(engine, dev_priv, id) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 917 | if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 918 | seq_printf(m, |
| 919 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 920 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 921 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 922 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 923 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 924 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 925 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 926 | return 0; |
| 927 | } |
| 928 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 929 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 930 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 931 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 932 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 933 | int i, ret; |
| 934 | |
| 935 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 936 | if (ret) |
| 937 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 938 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 939 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 940 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 941 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 942 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 943 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 944 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 945 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 946 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 947 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 948 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 949 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 950 | } |
| 951 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 952 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 953 | return 0; |
| 954 | } |
| 955 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 956 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
| 957 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 958 | static ssize_t |
| 959 | i915_error_state_write(struct file *filp, |
| 960 | const char __user *ubuf, |
| 961 | size_t cnt, |
| 962 | loff_t *ppos) |
| 963 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 964 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 965 | |
| 966 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Tvrtko Ursulin | 12ff05e | 2016-12-01 14:16:43 +0000 | [diff] [blame] | 967 | i915_destroy_error_state(error_priv->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 968 | |
| 969 | return cnt; |
| 970 | } |
| 971 | |
| 972 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 973 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 974 | struct drm_i915_private *dev_priv = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 975 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 976 | |
| 977 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 978 | if (!error_priv) |
| 979 | return -ENOMEM; |
| 980 | |
Tvrtko Ursulin | 12ff05e | 2016-12-01 14:16:43 +0000 | [diff] [blame] | 981 | error_priv->i915 = dev_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 982 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 983 | i915_error_state_get(&dev_priv->drm, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 984 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 985 | file->private_data = error_priv; |
| 986 | |
| 987 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 991 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 992 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 993 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 994 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 995 | kfree(error_priv); |
| 996 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 997 | return 0; |
| 998 | } |
| 999 | |
| 1000 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1001 | size_t count, loff_t *pos) |
| 1002 | { |
| 1003 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1004 | struct drm_i915_error_state_buf error_str; |
| 1005 | loff_t tmp_pos = 0; |
| 1006 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1007 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1008 | |
Tvrtko Ursulin | 12ff05e | 2016-12-01 14:16:43 +0000 | [diff] [blame] | 1009 | ret = i915_error_state_buf_init(&error_str, error_priv->i915, |
| 1010 | count, *pos); |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1011 | if (ret) |
| 1012 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1013 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1014 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1015 | if (ret) |
| 1016 | goto out; |
| 1017 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1018 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1019 | error_str.buf, |
| 1020 | error_str.bytes); |
| 1021 | |
| 1022 | if (ret_count < 0) |
| 1023 | ret = ret_count; |
| 1024 | else |
| 1025 | *pos = error_str.start + ret_count; |
| 1026 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1027 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1028 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | static const struct file_operations i915_error_state_fops = { |
| 1032 | .owner = THIS_MODULE, |
| 1033 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1034 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1035 | .write = i915_error_state_write, |
| 1036 | .llseek = default_llseek, |
| 1037 | .release = i915_error_state_release, |
| 1038 | }; |
| 1039 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1040 | #endif |
| 1041 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1042 | static int |
| 1043 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1044 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1045 | struct drm_i915_private *dev_priv = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1046 | |
Joonas Lahtinen | 4c266ed | 2016-11-24 14:47:49 +0000 | [diff] [blame] | 1047 | *val = 1 + atomic_read(&dev_priv->gt.global_timeline.seqno); |
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 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1054 | struct drm_i915_private *dev_priv = data; |
| 1055 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1056 | int ret; |
| 1057 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1058 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1059 | if (ret) |
| 1060 | return ret; |
| 1061 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1062 | ret = i915_gem_set_global_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1063 | mutex_unlock(&dev->struct_mutex); |
| 1064 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1065 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1066 | } |
| 1067 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1068 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1069 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1070 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1071 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1072 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1073 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1074 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1075 | struct drm_device *dev = &dev_priv->drm; |
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 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1080 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1081 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1082 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1083 | |
| 1084 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1085 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1086 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1087 | MEMSTAT_VID_SHIFT); |
| 1088 | seq_printf(m, "Current P-state: %d\n", |
| 1089 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1090 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1091 | u32 freq_sts; |
| 1092 | |
| 1093 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1094 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1095 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1096 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1097 | |
| 1098 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1099 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1100 | |
| 1101 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1102 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1103 | |
| 1104 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1105 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1106 | |
| 1107 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1108 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1109 | |
| 1110 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1111 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1112 | |
| 1113 | seq_printf(m, |
| 1114 | "efficient (RPe) frequency: %d MHz\n", |
| 1115 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1116 | mutex_unlock(&dev_priv->rps.hw_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1117 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1118 | u32 rp_state_limits; |
| 1119 | u32 gt_perf_status; |
| 1120 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1121 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1122 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1123 | u32 rpupei, rpcurup, rpprevup; |
| 1124 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1125 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1126 | int max_freq; |
| 1127 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1128 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1129 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1130 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1131 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1132 | } else { |
| 1133 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1134 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1135 | } |
| 1136 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1137 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1138 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1139 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1140 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1141 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1142 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1143 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1144 | reqf = I915_READ(GEN6_RPNSWREQ); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1145 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1146 | reqf >>= 23; |
| 1147 | else { |
| 1148 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1149 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1150 | reqf >>= 24; |
| 1151 | else |
| 1152 | reqf >>= 25; |
| 1153 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1154 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1155 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1156 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1157 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1158 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1159 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1160 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1161 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1162 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1163 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1164 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1165 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1166 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1167 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1168 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1169 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1170 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1171 | else |
| 1172 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1173 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1174 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1175 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1176 | mutex_unlock(&dev->struct_mutex); |
| 1177 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1178 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1179 | pm_ier = I915_READ(GEN6_PMIER); |
| 1180 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1181 | pm_isr = I915_READ(GEN6_PMISR); |
| 1182 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1183 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1184 | } else { |
| 1185 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1186 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1187 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1188 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1189 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1190 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1191 | 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] | 1192 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 1193 | seq_printf(m, "pm_intr_keep: 0x%08x\n", dev_priv->rps.pm_intr_keep); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1194 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1195 | seq_printf(m, "Render p-state ratio: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1196 | (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1197 | seq_printf(m, "Render p-state VID: %d\n", |
| 1198 | gt_perf_status & 0xff); |
| 1199 | seq_printf(m, "Render p-state limit: %d\n", |
| 1200 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1201 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1202 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1203 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1204 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1205 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1206 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1207 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1208 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1209 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1210 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1211 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1212 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1213 | seq_printf(m, "Up threshold: %d%%\n", |
| 1214 | dev_priv->rps.up_threshold); |
| 1215 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1216 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1217 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1218 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1219 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1220 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1221 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1222 | seq_printf(m, "Down threshold: %d%%\n", |
| 1223 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1224 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1225 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1226 | rp_state_cap >> 16) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1227 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1228 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1229 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1230 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1231 | |
| 1232 | max_freq = (rp_state_cap & 0xff00) >> 8; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1233 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1234 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1235 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1236 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1237 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1238 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1239 | rp_state_cap >> 0) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1240 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1241 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1242 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1243 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1244 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1245 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1246 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1247 | seq_printf(m, "Current freq: %d MHz\n", |
| 1248 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1249 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1250 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1251 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1252 | seq_printf(m, "Min freq: %d MHz\n", |
| 1253 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1254 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1255 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1256 | seq_printf(m, "Max freq: %d MHz\n", |
| 1257 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1258 | seq_printf(m, |
| 1259 | "efficient (RPe) frequency: %d MHz\n", |
| 1260 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1261 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1262 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1263 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1264 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1265 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1266 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1267 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1268 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1269 | out: |
| 1270 | intel_runtime_pm_put(dev_priv); |
| 1271 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1272 | } |
| 1273 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1274 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1275 | struct seq_file *m, |
| 1276 | struct intel_instdone *instdone) |
| 1277 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1278 | int slice; |
| 1279 | int subslice; |
| 1280 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1281 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1282 | instdone->instdone); |
| 1283 | |
| 1284 | if (INTEL_GEN(dev_priv) <= 3) |
| 1285 | return; |
| 1286 | |
| 1287 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1288 | instdone->slice_common); |
| 1289 | |
| 1290 | if (INTEL_GEN(dev_priv) <= 6) |
| 1291 | return; |
| 1292 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1293 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1294 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1295 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1296 | |
| 1297 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1298 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1299 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1300 | } |
| 1301 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1302 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1303 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1304 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1305 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1306 | u64 acthd[I915_NUM_ENGINES]; |
| 1307 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1308 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1309 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1310 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1311 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
| 1312 | seq_printf(m, "Wedged\n"); |
| 1313 | if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags)) |
| 1314 | seq_printf(m, "Reset in progress\n"); |
| 1315 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
| 1316 | seq_printf(m, "Waiter holding struct mutex\n"); |
| 1317 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
| 1318 | seq_printf(m, "struct_mutex blocked for reset\n"); |
| 1319 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1320 | if (!i915.enable_hangcheck) { |
| 1321 | seq_printf(m, "Hangcheck disabled\n"); |
| 1322 | return 0; |
| 1323 | } |
| 1324 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1325 | intel_runtime_pm_get(dev_priv); |
| 1326 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1327 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1328 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1329 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1330 | } |
| 1331 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1332 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1333 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1334 | intel_runtime_pm_put(dev_priv); |
| 1335 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1336 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1337 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1338 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1339 | jiffies)); |
| 1340 | } else |
| 1341 | seq_printf(m, "Hangcheck inactive\n"); |
| 1342 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1343 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1344 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1345 | struct rb_node *rb; |
| 1346 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1347 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 14fd0d6 | 2016-04-07 07:29:10 +0100 | [diff] [blame] | 1348 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1349 | engine->hangcheck.seqno, seqno[id], |
| 1350 | intel_engine_last_submit(engine)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1351 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1352 | yesno(intel_engine_has_waiter(engine)), |
| 1353 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1354 | &dev_priv->gpu_error.missed_irq_rings)), |
| 1355 | yesno(engine->hangcheck.stalled)); |
| 1356 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 1357 | spin_lock_irq(&b->lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1358 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 1359 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1360 | |
| 1361 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1362 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1363 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 1364 | spin_unlock_irq(&b->lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1365 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1366 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1367 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1368 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1369 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1370 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1371 | engine->hangcheck.action, |
| 1372 | jiffies_to_msecs(jiffies - |
| 1373 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1374 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1375 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1376 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1377 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1378 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1379 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1380 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1381 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1382 | i915_instdone_info(dev_priv, m, |
| 1383 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1384 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1385 | } |
| 1386 | |
| 1387 | return 0; |
| 1388 | } |
| 1389 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1390 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1391 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1392 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1393 | u32 rgvmodectl, rstdbyctl; |
| 1394 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1395 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1396 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1397 | |
| 1398 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1399 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1400 | crstandvid = I915_READ16(CRSTANDVID); |
| 1401 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1402 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1403 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1404 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1405 | seq_printf(m, "Boost freq: %d\n", |
| 1406 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1407 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1408 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1409 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1410 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1411 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1412 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1413 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1414 | seq_printf(m, "Starting frequency: P%d\n", |
| 1415 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1416 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1417 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1418 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1419 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1420 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1421 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1422 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1423 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1424 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1425 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1426 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1427 | break; |
| 1428 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1429 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1430 | break; |
| 1431 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1432 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1433 | break; |
| 1434 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1435 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1436 | break; |
| 1437 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1438 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1439 | break; |
| 1440 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1441 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1442 | break; |
| 1443 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1444 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1445 | break; |
| 1446 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1447 | |
| 1448 | return 0; |
| 1449 | } |
| 1450 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1451 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1452 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1453 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1454 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1455 | |
| 1456 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1457 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1458 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1459 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1460 | fw_domain->wake_count); |
| 1461 | } |
| 1462 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1463 | |
| 1464 | return 0; |
| 1465 | } |
| 1466 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1467 | static int vlv_drpc_info(struct seq_file *m) |
| 1468 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1469 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1470 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1471 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1472 | intel_runtime_pm_get(dev_priv); |
| 1473 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1474 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1475 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1476 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1477 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1478 | intel_runtime_pm_put(dev_priv); |
| 1479 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1480 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1481 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1482 | seq_printf(m, "Turbo enabled: %s\n", |
| 1483 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1484 | seq_printf(m, "HW control enabled: %s\n", |
| 1485 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1486 | seq_printf(m, "SW control enabled: %s\n", |
| 1487 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1488 | GEN6_RP_MEDIA_SW_MODE)); |
| 1489 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1490 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1491 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1492 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1493 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1494 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1495 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1496 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1497 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1498 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1499 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1500 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1501 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1502 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1503 | } |
| 1504 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1505 | static int gen6_drpc_info(struct seq_file *m) |
| 1506 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1507 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1508 | struct drm_device *dev = &dev_priv->drm; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1509 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1510 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1511 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1512 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1513 | |
| 1514 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1515 | if (ret) |
| 1516 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1517 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1518 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1519 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1520 | 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] | 1521 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1522 | |
| 1523 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1524 | seq_puts(m, "RC information inaccurate because somebody " |
| 1525 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1526 | } else { |
| 1527 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1528 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1529 | udelay(10); |
| 1530 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1531 | } |
| 1532 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1533 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1534 | 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] | 1535 | |
| 1536 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1537 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1538 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1539 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1540 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1541 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1542 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1543 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1544 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1545 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1546 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1547 | intel_runtime_pm_put(dev_priv); |
| 1548 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1549 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1550 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1551 | seq_printf(m, "HW control enabled: %s\n", |
| 1552 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1553 | seq_printf(m, "SW control enabled: %s\n", |
| 1554 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1555 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1556 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1557 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1558 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1559 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1560 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1561 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1562 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1563 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1564 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1565 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1566 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1567 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1568 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1569 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1570 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1571 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1572 | case GEN6_RC0: |
| 1573 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1574 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1575 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1576 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1577 | break; |
| 1578 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1579 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1580 | break; |
| 1581 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1582 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1583 | break; |
| 1584 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1585 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1586 | break; |
| 1587 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1588 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1589 | break; |
| 1590 | } |
| 1591 | |
| 1592 | seq_printf(m, "Core Power Down: %s\n", |
| 1593 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1594 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1595 | seq_printf(m, "Render Power Well: %s\n", |
| 1596 | (gen9_powergate_status & |
| 1597 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1598 | seq_printf(m, "Media Power Well: %s\n", |
| 1599 | (gen9_powergate_status & |
| 1600 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1601 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1602 | |
| 1603 | /* Not exactly sure what this is */ |
| 1604 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1605 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1606 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1607 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1608 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1609 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1610 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1611 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1612 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1613 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1614 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1615 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1616 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1617 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1618 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1619 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1620 | } |
| 1621 | |
| 1622 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1623 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1624 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1625 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1626 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1627 | return vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1628 | else if (INTEL_GEN(dev_priv) >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1629 | return gen6_drpc_info(m); |
| 1630 | else |
| 1631 | return ironlake_drpc_info(m); |
| 1632 | } |
| 1633 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1634 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1635 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1636 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1637 | |
| 1638 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1639 | dev_priv->fb_tracking.busy_bits); |
| 1640 | |
| 1641 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1642 | dev_priv->fb_tracking.flip_bits); |
| 1643 | |
| 1644 | return 0; |
| 1645 | } |
| 1646 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1647 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1648 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1649 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1650 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1651 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1652 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1653 | return 0; |
| 1654 | } |
| 1655 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1656 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1657 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1658 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1659 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1660 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1661 | else |
| 1662 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1663 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1664 | |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1665 | if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) { |
| 1666 | uint32_t mask = INTEL_GEN(dev_priv) >= 8 ? |
| 1667 | BDW_FBC_COMPRESSION_MASK : |
| 1668 | IVB_FBC_COMPRESSION_MASK; |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1669 | seq_printf(m, "Compressing: %s\n", |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1670 | yesno(I915_READ(FBC_STATUS2) & mask)); |
| 1671 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1672 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1673 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1674 | intel_runtime_pm_put(dev_priv); |
| 1675 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1676 | return 0; |
| 1677 | } |
| 1678 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1679 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1680 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1681 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1682 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1683 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1684 | return -ENODEV; |
| 1685 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1686 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1687 | |
| 1688 | return 0; |
| 1689 | } |
| 1690 | |
| 1691 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1692 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1693 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1694 | u32 reg; |
| 1695 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1696 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1697 | return -ENODEV; |
| 1698 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1699 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1700 | |
| 1701 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1702 | dev_priv->fbc.false_color = val; |
| 1703 | |
| 1704 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1705 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1706 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1707 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1708 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1709 | return 0; |
| 1710 | } |
| 1711 | |
| 1712 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1713 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1714 | "%llu\n"); |
| 1715 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1716 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1717 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1718 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1719 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1720 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1721 | seq_puts(m, "not supported\n"); |
| 1722 | return 0; |
| 1723 | } |
| 1724 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1725 | intel_runtime_pm_get(dev_priv); |
| 1726 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1727 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1728 | yesno(i915.enable_ips)); |
| 1729 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1730 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1731 | seq_puts(m, "Currently: unknown\n"); |
| 1732 | } else { |
| 1733 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1734 | seq_puts(m, "Currently: enabled\n"); |
| 1735 | else |
| 1736 | seq_puts(m, "Currently: disabled\n"); |
| 1737 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1738 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1739 | intel_runtime_pm_put(dev_priv); |
| 1740 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1741 | return 0; |
| 1742 | } |
| 1743 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1744 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1745 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1746 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1747 | bool sr_enabled = false; |
| 1748 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1749 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1750 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1751 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1752 | if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1753 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1754 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1755 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1756 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1757 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1758 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1759 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1760 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1761 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1762 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1763 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1764 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1765 | intel_runtime_pm_put(dev_priv); |
| 1766 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1767 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1768 | |
| 1769 | return 0; |
| 1770 | } |
| 1771 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1772 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1773 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1774 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1775 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1776 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1777 | int ret; |
| 1778 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1779 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1780 | return -ENODEV; |
| 1781 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1782 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1783 | if (ret) |
| 1784 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1785 | |
| 1786 | temp = i915_mch_val(dev_priv); |
| 1787 | chipset = i915_chipset_val(dev_priv); |
| 1788 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1789 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1790 | |
| 1791 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1792 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1793 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1794 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1795 | |
| 1796 | return 0; |
| 1797 | } |
| 1798 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1799 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1800 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1801 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1802 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1803 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1804 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1805 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1806 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1807 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1808 | return 0; |
| 1809 | } |
| 1810 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1811 | intel_runtime_pm_get(dev_priv); |
| 1812 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1813 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1814 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1815 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1816 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1817 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1818 | /* Convert GT frequency to 50 HZ units */ |
| 1819 | min_gpu_freq = |
| 1820 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1821 | max_gpu_freq = |
| 1822 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1823 | } else { |
| 1824 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1825 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1826 | } |
| 1827 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1828 | 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] | 1829 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1830 | for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) { |
Ben Widawsky | 42c0526 | 2012-09-26 10:34:00 -0700 | [diff] [blame] | 1831 | ia_freq = gpu_freq; |
| 1832 | sandybridge_pcode_read(dev_priv, |
| 1833 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1834 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1835 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1836 | intel_gpu_freq(dev_priv, (gpu_freq * |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1837 | (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1838 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1839 | ((ia_freq >> 0) & 0xff) * 100, |
| 1840 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1841 | } |
| 1842 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1843 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1844 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1845 | out: |
| 1846 | intel_runtime_pm_put(dev_priv); |
| 1847 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1848 | } |
| 1849 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1850 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1851 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1852 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1853 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1854 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1855 | int ret; |
| 1856 | |
| 1857 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1858 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1859 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1860 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1861 | if (opregion->header) |
| 1862 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1863 | |
| 1864 | mutex_unlock(&dev->struct_mutex); |
| 1865 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1866 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1867 | return 0; |
| 1868 | } |
| 1869 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1870 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1871 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1872 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1873 | |
| 1874 | if (opregion->vbt) |
| 1875 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1876 | |
| 1877 | return 0; |
| 1878 | } |
| 1879 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1880 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1881 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1882 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1883 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1884 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1885 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1886 | int ret; |
| 1887 | |
| 1888 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1889 | if (ret) |
| 1890 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1891 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1892 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1893 | if (dev_priv->fbdev) { |
| 1894 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1895 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1896 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1897 | fbdev_fb->base.width, |
| 1898 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1899 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1900 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1901 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1902 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1903 | describe_obj(m, fbdev_fb->obj); |
| 1904 | seq_putc(m, '\n'); |
| 1905 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1906 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1907 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1908 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1909 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1910 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1911 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1912 | continue; |
| 1913 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1914 | 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] | 1915 | fb->base.width, |
| 1916 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1917 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1918 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1919 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1920 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1921 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1922 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1923 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1924 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1925 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1926 | |
| 1927 | return 0; |
| 1928 | } |
| 1929 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1930 | static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring) |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1931 | { |
| 1932 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1933 | ring->space, ring->head, ring->tail, |
| 1934 | ring->last_retired_head); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1935 | } |
| 1936 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1937 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1938 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1939 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1940 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1941 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1942 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1943 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1944 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1945 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1946 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1947 | if (ret) |
| 1948 | return ret; |
| 1949 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1950 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1951 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1952 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1953 | struct task_struct *task; |
| 1954 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1955 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1956 | if (task) { |
| 1957 | seq_printf(m, "(%s [%d]) ", |
| 1958 | task->comm, task->pid); |
| 1959 | put_task_struct(task); |
| 1960 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1961 | } else if (IS_ERR(ctx->file_priv)) { |
| 1962 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1963 | } else { |
| 1964 | seq_puts(m, "(kernel) "); |
| 1965 | } |
| 1966 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1967 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1968 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1969 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1970 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1971 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 1972 | |
| 1973 | seq_printf(m, "%s: ", engine->name); |
| 1974 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 1975 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1976 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1977 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1978 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1979 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1980 | } |
| 1981 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1982 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1983 | } |
| 1984 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1985 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1986 | |
| 1987 | return 0; |
| 1988 | } |
| 1989 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1990 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1991 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1992 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1993 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1994 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1995 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1996 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1997 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 1998 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 1999 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2000 | if (!vma) { |
| 2001 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2002 | return; |
| 2003 | } |
| 2004 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2005 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 2006 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 2007 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2008 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2009 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2010 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2011 | return; |
| 2012 | } |
| 2013 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2014 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 2015 | if (page) { |
| 2016 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2017 | |
| 2018 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2019 | seq_printf(m, |
| 2020 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2021 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2022 | reg_state[j], reg_state[j + 1], |
| 2023 | reg_state[j + 2], reg_state[j + 3]); |
| 2024 | } |
| 2025 | kunmap_atomic(reg_state); |
| 2026 | } |
| 2027 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2028 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2029 | seq_putc(m, '\n'); |
| 2030 | } |
| 2031 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2032 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2033 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2034 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2035 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2036 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2037 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2038 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2039 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2040 | |
| 2041 | if (!i915.enable_execlists) { |
| 2042 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2043 | return 0; |
| 2044 | } |
| 2045 | |
| 2046 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2047 | if (ret) |
| 2048 | return ret; |
| 2049 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2050 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2051 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2052 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2053 | |
| 2054 | mutex_unlock(&dev->struct_mutex); |
| 2055 | |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2059 | static const char *swizzle_string(unsigned swizzle) |
| 2060 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2061 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2062 | case I915_BIT_6_SWIZZLE_NONE: |
| 2063 | return "none"; |
| 2064 | case I915_BIT_6_SWIZZLE_9: |
| 2065 | return "bit9"; |
| 2066 | case I915_BIT_6_SWIZZLE_9_10: |
| 2067 | return "bit9/bit10"; |
| 2068 | case I915_BIT_6_SWIZZLE_9_11: |
| 2069 | return "bit9/bit11"; |
| 2070 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2071 | return "bit9/bit10/bit11"; |
| 2072 | case I915_BIT_6_SWIZZLE_9_17: |
| 2073 | return "bit9/bit17"; |
| 2074 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2075 | return "bit9/bit10/bit17"; |
| 2076 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2077 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2078 | } |
| 2079 | |
| 2080 | return "bug"; |
| 2081 | } |
| 2082 | |
| 2083 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2084 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2085 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2086 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2087 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2088 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2089 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2090 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2091 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2092 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2093 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2094 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2095 | seq_printf(m, "DDC = 0x%08x\n", |
| 2096 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2097 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2098 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2099 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2100 | I915_READ16(C0DRB3)); |
| 2101 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2102 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2103 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2104 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2105 | I915_READ(MAD_DIMM_C0)); |
| 2106 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2107 | I915_READ(MAD_DIMM_C1)); |
| 2108 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2109 | I915_READ(MAD_DIMM_C2)); |
| 2110 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2111 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2112 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2113 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2114 | I915_READ(GAMTARBMODE)); |
| 2115 | else |
| 2116 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2117 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2118 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2119 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2120 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2121 | |
| 2122 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2123 | seq_puts(m, "L-shaped memory detected\n"); |
| 2124 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2125 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2126 | |
| 2127 | return 0; |
| 2128 | } |
| 2129 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2130 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2131 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2132 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2133 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2134 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2135 | |
| 2136 | if (!ppgtt) { |
| 2137 | seq_printf(m, " no ppgtt for context %d\n", |
| 2138 | ctx->user_handle); |
| 2139 | return 0; |
| 2140 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2141 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2142 | if (i915_gem_context_is_default(ctx)) |
| 2143 | seq_puts(m, " default context:\n"); |
| 2144 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2145 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2146 | ppgtt->debug_dump(ppgtt, m); |
| 2147 | |
| 2148 | return 0; |
| 2149 | } |
| 2150 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2151 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2152 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2153 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2154 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2155 | struct intel_engine_cs *engine; |
| 2156 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2157 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2158 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2159 | if (!ppgtt) |
| 2160 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2161 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2162 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2163 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2164 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2165 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2166 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2167 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2168 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2169 | } |
| 2170 | } |
| 2171 | } |
| 2172 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2173 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2174 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2175 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2176 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2177 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2178 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2179 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2180 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2181 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2182 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2183 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2184 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2185 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2186 | I915_READ(RING_MODE_GEN7(engine))); |
| 2187 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2188 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2189 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2190 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2191 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2192 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2193 | } |
| 2194 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2195 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2196 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2197 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2198 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2199 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2200 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2201 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2202 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2203 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2204 | } |
| 2205 | |
| 2206 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2207 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2208 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2209 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2210 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2211 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2212 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2213 | mutex_lock(&dev->filelist_mutex); |
| 2214 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2215 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2216 | goto out_unlock; |
| 2217 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2218 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2219 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2220 | if (INTEL_GEN(dev_priv) >= 8) |
| 2221 | gen8_ppgtt_info(m, dev_priv); |
| 2222 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2223 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2224 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2225 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2226 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2227 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2228 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2229 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2230 | if (!task) { |
| 2231 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2232 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2233 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2234 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2235 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2236 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2237 | (void *)(unsigned long)m); |
| 2238 | } |
| 2239 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2240 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2241 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2242 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2243 | out_unlock: |
| 2244 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2245 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2246 | } |
| 2247 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2248 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2249 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2250 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2251 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2252 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2253 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2254 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2255 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2256 | |
| 2257 | return count; |
| 2258 | } |
| 2259 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2260 | static const char *rps_power_to_str(unsigned int power) |
| 2261 | { |
| 2262 | static const char * const strings[] = { |
| 2263 | [LOW_POWER] = "low power", |
| 2264 | [BETWEEN] = "mixed", |
| 2265 | [HIGH_POWER] = "high power", |
| 2266 | }; |
| 2267 | |
| 2268 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2269 | return "unknown"; |
| 2270 | |
| 2271 | return strings[power]; |
| 2272 | } |
| 2273 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2274 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2275 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2276 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2277 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2278 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2279 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2280 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2281 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2282 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2283 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2284 | seq_printf(m, "Frequency requested %d\n", |
| 2285 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 2286 | seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2287 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2288 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2289 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2290 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2291 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
| 2292 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq), |
| 2293 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
| 2294 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2295 | |
| 2296 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2297 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2298 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2299 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2300 | struct task_struct *task; |
| 2301 | |
| 2302 | rcu_read_lock(); |
| 2303 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2304 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2305 | task ? task->comm : "<unknown>", |
| 2306 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2307 | file_priv->rps.boosts, |
| 2308 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2309 | rcu_read_unlock(); |
| 2310 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2311 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2312 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2313 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2314 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2315 | if (INTEL_GEN(dev_priv) >= 6 && |
| 2316 | dev_priv->rps.enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2317 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2318 | u32 rpup, rpupei; |
| 2319 | u32 rpdown, rpdownei; |
| 2320 | |
| 2321 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2322 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2323 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2324 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2325 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2326 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2327 | |
| 2328 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
| 2329 | rps_power_to_str(dev_priv->rps.power)); |
| 2330 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
| 2331 | 100 * rpup / rpupei, |
| 2332 | dev_priv->rps.up_threshold); |
| 2333 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
| 2334 | 100 * rpdown / rpdownei, |
| 2335 | dev_priv->rps.down_threshold); |
| 2336 | } else { |
| 2337 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2338 | } |
| 2339 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2340 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2341 | } |
| 2342 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2343 | static int i915_llc(struct seq_file *m, void *data) |
| 2344 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2345 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2346 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2347 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2348 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2349 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2350 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2351 | |
| 2352 | return 0; |
| 2353 | } |
| 2354 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame^] | 2355 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2356 | { |
| 2357 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2358 | struct intel_uc_fw *huc_fw = &dev_priv->huc.fw; |
| 2359 | |
| 2360 | if (!HAS_HUC_UCODE(dev_priv)) |
| 2361 | return 0; |
| 2362 | |
| 2363 | seq_puts(m, "HuC firmware status:\n"); |
| 2364 | seq_printf(m, "\tpath: %s\n", huc_fw->path); |
| 2365 | seq_printf(m, "\tfetch: %s\n", |
| 2366 | intel_uc_fw_status_repr(huc_fw->fetch_status)); |
| 2367 | seq_printf(m, "\tload: %s\n", |
| 2368 | intel_uc_fw_status_repr(huc_fw->load_status)); |
| 2369 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2370 | huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted); |
| 2371 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2372 | huc_fw->major_ver_found, huc_fw->minor_ver_found); |
| 2373 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2374 | huc_fw->header_offset, huc_fw->header_size); |
| 2375 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2376 | huc_fw->ucode_offset, huc_fw->ucode_size); |
| 2377 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2378 | huc_fw->rsa_offset, huc_fw->rsa_size); |
| 2379 | |
| 2380 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
| 2381 | |
| 2382 | return 0; |
| 2383 | } |
| 2384 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2385 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2386 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2387 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2388 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2389 | u32 tmp, i; |
| 2390 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2391 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2392 | return 0; |
| 2393 | |
| 2394 | seq_printf(m, "GuC firmware status:\n"); |
| 2395 | seq_printf(m, "\tpath: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2396 | guc_fw->path); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2397 | seq_printf(m, "\tfetch: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2398 | intel_uc_fw_status_repr(guc_fw->fetch_status)); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2399 | seq_printf(m, "\tload: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2400 | intel_uc_fw_status_repr(guc_fw->load_status)); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2401 | seq_printf(m, "\tversion wanted: %d.%d\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2402 | guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2403 | seq_printf(m, "\tversion found: %d.%d\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2404 | guc_fw->major_ver_found, guc_fw->minor_ver_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2405 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2406 | guc_fw->header_offset, guc_fw->header_size); |
| 2407 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2408 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2409 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2410 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2411 | |
| 2412 | tmp = I915_READ(GUC_STATUS); |
| 2413 | |
| 2414 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2415 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2416 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2417 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2418 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2419 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2420 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2421 | seq_puts(m, "\nScratch registers:\n"); |
| 2422 | for (i = 0; i < 16; i++) |
| 2423 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2424 | |
| 2425 | return 0; |
| 2426 | } |
| 2427 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2428 | static void i915_guc_log_info(struct seq_file *m, |
| 2429 | struct drm_i915_private *dev_priv) |
| 2430 | { |
| 2431 | struct intel_guc *guc = &dev_priv->guc; |
| 2432 | |
| 2433 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2434 | |
| 2435 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2436 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2437 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2438 | |
| 2439 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2440 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2441 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2442 | |
| 2443 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2444 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2445 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2446 | |
| 2447 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2448 | guc->log.flush_interrupt_count); |
| 2449 | |
| 2450 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2451 | guc->log.capture_miss_count); |
| 2452 | } |
| 2453 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2454 | static void i915_guc_client_info(struct seq_file *m, |
| 2455 | struct drm_i915_private *dev_priv, |
| 2456 | struct i915_guc_client *client) |
| 2457 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2458 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2459 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2460 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2461 | |
| 2462 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2463 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2464 | seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", |
Chris Wilson | 357248b | 2016-11-29 12:10:21 +0000 | [diff] [blame] | 2465 | client->doorbell_id, client->doorbell_offset, client->doorbell_cookie); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2466 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2467 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2468 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2469 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2470 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2471 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2472 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2473 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2474 | u64 submissions = client->submissions[id]; |
| 2475 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2476 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2477 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2478 | } |
| 2479 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2480 | } |
| 2481 | |
| 2482 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2483 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2484 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2485 | const struct intel_guc *guc = &dev_priv->guc; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2486 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2487 | enum intel_engine_id id; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2488 | u64 total; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2489 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2490 | if (!guc->execbuf_client) { |
| 2491 | seq_printf(m, "GuC submission %s\n", |
| 2492 | HAS_GUC_SCHED(dev_priv) ? |
| 2493 | "disabled" : |
| 2494 | "not supported"); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2495 | return 0; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2496 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2497 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2498 | seq_printf(m, "Doorbell map:\n"); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2499 | seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap); |
| 2500 | seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2501 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2502 | seq_printf(m, "GuC total action count: %llu\n", guc->action_count); |
| 2503 | seq_printf(m, "GuC action failure count: %u\n", guc->action_fail); |
| 2504 | seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd); |
| 2505 | seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status); |
| 2506 | seq_printf(m, "GuC last action error code: %d\n", guc->action_err); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2507 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2508 | total = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2509 | seq_printf(m, "\nGuC submissions:\n"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2510 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2511 | u64 submissions = guc->submissions[id]; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2512 | total += submissions; |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2513 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2514 | engine->name, submissions, guc->last_seqno[id]); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2515 | } |
| 2516 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2517 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2518 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2519 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2520 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2521 | i915_guc_log_info(m, dev_priv); |
| 2522 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2523 | /* Add more as required ... */ |
| 2524 | |
| 2525 | return 0; |
| 2526 | } |
| 2527 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2528 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2529 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2530 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2531 | struct drm_i915_gem_object *obj; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2532 | int i = 0, pg; |
| 2533 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2534 | if (!dev_priv->guc.log.vma) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2535 | return 0; |
| 2536 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2537 | obj = dev_priv->guc.log.vma->obj; |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2538 | for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) { |
| 2539 | u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg)); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2540 | |
| 2541 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2542 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2543 | *(log + i), *(log + i + 1), |
| 2544 | *(log + i + 2), *(log + i + 3)); |
| 2545 | |
| 2546 | kunmap_atomic(log); |
| 2547 | } |
| 2548 | |
| 2549 | seq_putc(m, '\n'); |
| 2550 | |
| 2551 | return 0; |
| 2552 | } |
| 2553 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2554 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2555 | { |
| 2556 | struct drm_device *dev = data; |
| 2557 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2558 | |
| 2559 | if (!dev_priv->guc.log.vma) |
| 2560 | return -EINVAL; |
| 2561 | |
| 2562 | *val = i915.guc_log_level; |
| 2563 | |
| 2564 | return 0; |
| 2565 | } |
| 2566 | |
| 2567 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2568 | { |
| 2569 | struct drm_device *dev = data; |
| 2570 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2571 | int ret; |
| 2572 | |
| 2573 | if (!dev_priv->guc.log.vma) |
| 2574 | return -EINVAL; |
| 2575 | |
| 2576 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2577 | if (ret) |
| 2578 | return ret; |
| 2579 | |
| 2580 | intel_runtime_pm_get(dev_priv); |
| 2581 | ret = i915_guc_log_control(dev_priv, val); |
| 2582 | intel_runtime_pm_put(dev_priv); |
| 2583 | |
| 2584 | mutex_unlock(&dev->struct_mutex); |
| 2585 | return ret; |
| 2586 | } |
| 2587 | |
| 2588 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2589 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2590 | "%lld\n"); |
| 2591 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2592 | static const char *psr2_live_status(u32 val) |
| 2593 | { |
| 2594 | static const char * const live_status[] = { |
| 2595 | "IDLE", |
| 2596 | "CAPTURE", |
| 2597 | "CAPTURE_FS", |
| 2598 | "SLEEP", |
| 2599 | "BUFON_FW", |
| 2600 | "ML_UP", |
| 2601 | "SU_STANDBY", |
| 2602 | "FAST_SLEEP", |
| 2603 | "DEEP_SLEEP", |
| 2604 | "BUF_ON", |
| 2605 | "TG_ON" |
| 2606 | }; |
| 2607 | |
| 2608 | val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT; |
| 2609 | if (val < ARRAY_SIZE(live_status)) |
| 2610 | return live_status[val]; |
| 2611 | |
| 2612 | return "unknown"; |
| 2613 | } |
| 2614 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2615 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2616 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2617 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2618 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2619 | u32 stat[3]; |
| 2620 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2621 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2622 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2623 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2624 | seq_puts(m, "PSR not supported\n"); |
| 2625 | return 0; |
| 2626 | } |
| 2627 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2628 | intel_runtime_pm_get(dev_priv); |
| 2629 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2630 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2631 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2632 | 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] | 2633 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2634 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2635 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2636 | dev_priv->psr.busy_frontbuffer_bits); |
| 2637 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2638 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2639 | |
Nagaraju, Vathsala | 7e3eb59 | 2016-12-09 23:42:09 +0530 | [diff] [blame] | 2640 | if (HAS_DDI(dev_priv)) { |
| 2641 | if (dev_priv->psr.psr2_support) |
| 2642 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2643 | else |
| 2644 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
| 2645 | } else { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2646 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2647 | enum transcoder cpu_transcoder = |
| 2648 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2649 | enum intel_display_power_domain power_domain; |
| 2650 | |
| 2651 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2652 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2653 | power_domain)) |
| 2654 | continue; |
| 2655 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2656 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2657 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2658 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2659 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2660 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2661 | |
| 2662 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2663 | } |
| 2664 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2665 | |
| 2666 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2667 | yesno(dev_priv->psr.link_standby)); |
| 2668 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2669 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2670 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2671 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2672 | for_each_pipe(dev_priv, pipe) { |
| 2673 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2674 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2675 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2676 | } |
| 2677 | seq_puts(m, "\n"); |
| 2678 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2679 | /* |
| 2680 | * VLV/CHV PSR has no kind of performance counter |
| 2681 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2682 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2683 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2684 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2685 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2686 | |
| 2687 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2688 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2689 | if (dev_priv->psr.psr2_support) { |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2690 | u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2691 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2692 | seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n", |
| 2693 | psr2, psr2_live_status(psr2)); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2694 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2695 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2696 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2697 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2698 | return 0; |
| 2699 | } |
| 2700 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2701 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2702 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2703 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2704 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2705 | struct intel_connector *connector; |
| 2706 | struct intel_dp *intel_dp = NULL; |
| 2707 | int ret; |
| 2708 | u8 crc[6]; |
| 2709 | |
| 2710 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2711 | for_each_intel_connector(dev, connector) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2712 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2713 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2714 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2715 | continue; |
| 2716 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2717 | crtc = connector->base.state->crtc; |
| 2718 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2719 | continue; |
| 2720 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2721 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2722 | continue; |
| 2723 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2724 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2725 | |
| 2726 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2727 | if (ret) |
| 2728 | goto out; |
| 2729 | |
| 2730 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2731 | crc[0], crc[1], crc[2], |
| 2732 | crc[3], crc[4], crc[5]); |
| 2733 | goto out; |
| 2734 | } |
| 2735 | ret = -ENODEV; |
| 2736 | out: |
| 2737 | drm_modeset_unlock_all(dev); |
| 2738 | return ret; |
| 2739 | } |
| 2740 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2741 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2742 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2743 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2744 | u64 power; |
| 2745 | u32 units; |
| 2746 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2747 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2748 | return -ENODEV; |
| 2749 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2750 | intel_runtime_pm_get(dev_priv); |
| 2751 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2752 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2753 | power = (power & 0x1f00) >> 8; |
| 2754 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2755 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2756 | power *= units; |
| 2757 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2758 | intel_runtime_pm_put(dev_priv); |
| 2759 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2760 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2761 | |
| 2762 | return 0; |
| 2763 | } |
| 2764 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2765 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2766 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2767 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2768 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2769 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2770 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2771 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2772 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2773 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2774 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2775 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2776 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2777 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2778 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2779 | #else |
| 2780 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2781 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2782 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2783 | pci_power_name(pdev->current_state), |
| 2784 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2785 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2786 | return 0; |
| 2787 | } |
| 2788 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2789 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2790 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2791 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2792 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2793 | int i; |
| 2794 | |
| 2795 | mutex_lock(&power_domains->lock); |
| 2796 | |
| 2797 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2798 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2799 | struct i915_power_well *power_well; |
| 2800 | enum intel_display_power_domain power_domain; |
| 2801 | |
| 2802 | power_well = &power_domains->power_wells[i]; |
| 2803 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2804 | power_well->count); |
| 2805 | |
| 2806 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2807 | power_domain++) { |
| 2808 | if (!(BIT(power_domain) & power_well->domains)) |
| 2809 | continue; |
| 2810 | |
| 2811 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2812 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2813 | power_domains->domain_use_count[power_domain]); |
| 2814 | } |
| 2815 | } |
| 2816 | |
| 2817 | mutex_unlock(&power_domains->lock); |
| 2818 | |
| 2819 | return 0; |
| 2820 | } |
| 2821 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2822 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2823 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2824 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2825 | struct intel_csr *csr; |
| 2826 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2827 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2828 | seq_puts(m, "not supported\n"); |
| 2829 | return 0; |
| 2830 | } |
| 2831 | |
| 2832 | csr = &dev_priv->csr; |
| 2833 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2834 | intel_runtime_pm_get(dev_priv); |
| 2835 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2836 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2837 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2838 | |
| 2839 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2840 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2841 | |
| 2842 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2843 | CSR_VERSION_MINOR(csr->version)); |
| 2844 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2845 | if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2846 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2847 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2848 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2849 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2850 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2851 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2852 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2853 | } |
| 2854 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2855 | out: |
| 2856 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2857 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2858 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2859 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2860 | intel_runtime_pm_put(dev_priv); |
| 2861 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2862 | return 0; |
| 2863 | } |
| 2864 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2865 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2866 | struct drm_display_mode *mode) |
| 2867 | { |
| 2868 | int i; |
| 2869 | |
| 2870 | for (i = 0; i < tabs; i++) |
| 2871 | seq_putc(m, '\t'); |
| 2872 | |
| 2873 | 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", |
| 2874 | mode->base.id, mode->name, |
| 2875 | mode->vrefresh, mode->clock, |
| 2876 | mode->hdisplay, mode->hsync_start, |
| 2877 | mode->hsync_end, mode->htotal, |
| 2878 | mode->vdisplay, mode->vsync_start, |
| 2879 | mode->vsync_end, mode->vtotal, |
| 2880 | mode->type, mode->flags); |
| 2881 | } |
| 2882 | |
| 2883 | static void intel_encoder_info(struct seq_file *m, |
| 2884 | struct intel_crtc *intel_crtc, |
| 2885 | struct intel_encoder *intel_encoder) |
| 2886 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2887 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2888 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2889 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2890 | struct intel_connector *intel_connector; |
| 2891 | struct drm_encoder *encoder; |
| 2892 | |
| 2893 | encoder = &intel_encoder->base; |
| 2894 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2895 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2896 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2897 | struct drm_connector *connector = &intel_connector->base; |
| 2898 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2899 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2900 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2901 | drm_get_connector_status_name(connector->status)); |
| 2902 | if (connector->status == connector_status_connected) { |
| 2903 | struct drm_display_mode *mode = &crtc->mode; |
| 2904 | seq_printf(m, ", mode:\n"); |
| 2905 | intel_seq_print_mode(m, 2, mode); |
| 2906 | } else { |
| 2907 | seq_putc(m, '\n'); |
| 2908 | } |
| 2909 | } |
| 2910 | } |
| 2911 | |
| 2912 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2913 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2914 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2915 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2916 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2917 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2918 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2919 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2920 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2921 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2922 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2923 | fb->base.id, plane_state->src_x >> 16, |
| 2924 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2925 | else |
| 2926 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2927 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2928 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2929 | } |
| 2930 | |
| 2931 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2932 | { |
| 2933 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2934 | |
| 2935 | seq_printf(m, "\tfixed mode:\n"); |
| 2936 | intel_seq_print_mode(m, 2, mode); |
| 2937 | } |
| 2938 | |
| 2939 | static void intel_dp_info(struct seq_file *m, |
| 2940 | struct intel_connector *intel_connector) |
| 2941 | { |
| 2942 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2943 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2944 | |
| 2945 | seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2946 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2947 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2948 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2949 | |
| 2950 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2951 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2952 | } |
| 2953 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2954 | static void intel_dp_mst_info(struct seq_file *m, |
| 2955 | struct intel_connector *intel_connector) |
| 2956 | { |
| 2957 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2958 | struct intel_dp_mst_encoder *intel_mst = |
| 2959 | enc_to_mst(&intel_encoder->base); |
| 2960 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2961 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2962 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2963 | intel_connector->port); |
| 2964 | |
| 2965 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2966 | } |
| 2967 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2968 | static void intel_hdmi_info(struct seq_file *m, |
| 2969 | struct intel_connector *intel_connector) |
| 2970 | { |
| 2971 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2972 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2973 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2974 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2975 | } |
| 2976 | |
| 2977 | static void intel_lvds_info(struct seq_file *m, |
| 2978 | struct intel_connector *intel_connector) |
| 2979 | { |
| 2980 | intel_panel_info(m, &intel_connector->panel); |
| 2981 | } |
| 2982 | |
| 2983 | static void intel_connector_info(struct seq_file *m, |
| 2984 | struct drm_connector *connector) |
| 2985 | { |
| 2986 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2987 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2988 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2989 | |
| 2990 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2991 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2992 | drm_get_connector_status_name(connector->status)); |
| 2993 | if (connector->status == connector_status_connected) { |
| 2994 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2995 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2996 | connector->display_info.width_mm, |
| 2997 | connector->display_info.height_mm); |
| 2998 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2999 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 3000 | seq_printf(m, "\tCEA rev: %d\n", |
| 3001 | connector->display_info.cea_rev); |
| 3002 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3003 | |
| 3004 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3005 | return; |
| 3006 | |
| 3007 | switch (connector->connector_type) { |
| 3008 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 3009 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3010 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3011 | intel_dp_mst_info(m, intel_connector); |
| 3012 | else |
| 3013 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3014 | break; |
| 3015 | case DRM_MODE_CONNECTOR_LVDS: |
| 3016 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3017 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3018 | break; |
| 3019 | case DRM_MODE_CONNECTOR_HDMIA: |
| 3020 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 3021 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 3022 | intel_hdmi_info(m, intel_connector); |
| 3023 | break; |
| 3024 | default: |
| 3025 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3026 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3027 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3028 | seq_printf(m, "\tmodes:\n"); |
| 3029 | list_for_each_entry(mode, &connector->modes, head) |
| 3030 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3031 | } |
| 3032 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3033 | static bool cursor_active(struct drm_i915_private *dev_priv, int pipe) |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3034 | { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3035 | u32 state; |
| 3036 | |
Jani Nikula | 2a307c2 | 2016-11-30 17:43:04 +0200 | [diff] [blame] | 3037 | if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 3038 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3039 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 3040 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3041 | |
| 3042 | return state; |
| 3043 | } |
| 3044 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3045 | static bool cursor_position(struct drm_i915_private *dev_priv, |
| 3046 | int pipe, int *x, int *y) |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3047 | { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3048 | u32 pos; |
| 3049 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 3050 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3051 | |
| 3052 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 3053 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 3054 | *x = -*x; |
| 3055 | |
| 3056 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 3057 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 3058 | *y = -*y; |
| 3059 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3060 | return cursor_active(dev_priv, pipe); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3061 | } |
| 3062 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3063 | static const char *plane_type(enum drm_plane_type type) |
| 3064 | { |
| 3065 | switch (type) { |
| 3066 | case DRM_PLANE_TYPE_OVERLAY: |
| 3067 | return "OVL"; |
| 3068 | case DRM_PLANE_TYPE_PRIMARY: |
| 3069 | return "PRI"; |
| 3070 | case DRM_PLANE_TYPE_CURSOR: |
| 3071 | return "CUR"; |
| 3072 | /* |
| 3073 | * Deliberately omitting default: to generate compiler warnings |
| 3074 | * when a new drm_plane_type gets added. |
| 3075 | */ |
| 3076 | } |
| 3077 | |
| 3078 | return "unknown"; |
| 3079 | } |
| 3080 | |
| 3081 | static const char *plane_rotation(unsigned int rotation) |
| 3082 | { |
| 3083 | static char buf[48]; |
| 3084 | /* |
| 3085 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3086 | * will print them all to visualize if the values are misused |
| 3087 | */ |
| 3088 | snprintf(buf, sizeof(buf), |
| 3089 | "%s%s%s%s%s%s(0x%08x)", |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 3090 | (rotation & DRM_ROTATE_0) ? "0 " : "", |
| 3091 | (rotation & DRM_ROTATE_90) ? "90 " : "", |
| 3092 | (rotation & DRM_ROTATE_180) ? "180 " : "", |
| 3093 | (rotation & DRM_ROTATE_270) ? "270 " : "", |
| 3094 | (rotation & DRM_REFLECT_X) ? "FLIPX " : "", |
| 3095 | (rotation & DRM_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3096 | rotation); |
| 3097 | |
| 3098 | return buf; |
| 3099 | } |
| 3100 | |
| 3101 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3102 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3103 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3104 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3105 | struct intel_plane *intel_plane; |
| 3106 | |
| 3107 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3108 | struct drm_plane_state *state; |
| 3109 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3110 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3111 | |
| 3112 | if (!plane->state) { |
| 3113 | seq_puts(m, "plane->state is NULL!\n"); |
| 3114 | continue; |
| 3115 | } |
| 3116 | |
| 3117 | state = plane->state; |
| 3118 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3119 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3120 | drm_get_format_name(state->fb->format->format, |
| 3121 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3122 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3123 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3124 | } |
| 3125 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3126 | seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n", |
| 3127 | plane->base.id, |
| 3128 | plane_type(intel_plane->base.type), |
| 3129 | state->crtc_x, state->crtc_y, |
| 3130 | state->crtc_w, state->crtc_h, |
| 3131 | (state->src_x >> 16), |
| 3132 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3133 | (state->src_y >> 16), |
| 3134 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3135 | (state->src_w >> 16), |
| 3136 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3137 | (state->src_h >> 16), |
| 3138 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3139 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3140 | plane_rotation(state->rotation)); |
| 3141 | } |
| 3142 | } |
| 3143 | |
| 3144 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3145 | { |
| 3146 | struct intel_crtc_state *pipe_config; |
| 3147 | int num_scalers = intel_crtc->num_scalers; |
| 3148 | int i; |
| 3149 | |
| 3150 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3151 | |
| 3152 | /* Not all platformas have a scaler */ |
| 3153 | if (num_scalers) { |
| 3154 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3155 | num_scalers, |
| 3156 | pipe_config->scaler_state.scaler_users, |
| 3157 | pipe_config->scaler_state.scaler_id); |
| 3158 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3159 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3160 | struct intel_scaler *sc = |
| 3161 | &pipe_config->scaler_state.scalers[i]; |
| 3162 | |
| 3163 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3164 | i, yesno(sc->in_use), sc->mode); |
| 3165 | } |
| 3166 | seq_puts(m, "\n"); |
| 3167 | } else { |
| 3168 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3169 | } |
| 3170 | } |
| 3171 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3172 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3173 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3174 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3175 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3176 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3177 | struct drm_connector *connector; |
| 3178 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3179 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3180 | drm_modeset_lock_all(dev); |
| 3181 | seq_printf(m, "CRTC info\n"); |
| 3182 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3183 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3184 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3185 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3186 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3187 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3188 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3189 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3190 | seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n", |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3191 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3192 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3193 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3194 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3195 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3196 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3197 | intel_crtc_info(m, crtc); |
| 3198 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3199 | active = cursor_position(dev_priv, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3200 | 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] | 3201 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3202 | x, y, crtc->base.cursor->state->crtc_w, |
| 3203 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3204 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3205 | intel_scaler_info(m, crtc); |
| 3206 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3207 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3208 | |
| 3209 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3210 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3211 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3212 | } |
| 3213 | |
| 3214 | seq_printf(m, "\n"); |
| 3215 | seq_printf(m, "Connector info\n"); |
| 3216 | seq_printf(m, "--------------\n"); |
| 3217 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3218 | intel_connector_info(m, connector); |
| 3219 | } |
| 3220 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3221 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3222 | |
| 3223 | return 0; |
| 3224 | } |
| 3225 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3226 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3227 | { |
| 3228 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3229 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3230 | enum intel_engine_id id; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3231 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3232 | intel_runtime_pm_get(dev_priv); |
| 3233 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3234 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3235 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 3236 | struct drm_i915_gem_request *rq; |
| 3237 | struct rb_node *rb; |
| 3238 | u64 addr; |
| 3239 | |
| 3240 | seq_printf(m, "%s\n", engine->name); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 3241 | seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms]\n", |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3242 | intel_engine_get_seqno(engine), |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 3243 | intel_engine_last_submit(engine), |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3244 | engine->hangcheck.seqno, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 3245 | jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp)); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3246 | |
| 3247 | rcu_read_lock(); |
| 3248 | |
| 3249 | seq_printf(m, "\tRequests:\n"); |
| 3250 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3251 | rq = list_first_entry(&engine->timeline->requests, |
| 3252 | struct drm_i915_gem_request, link); |
| 3253 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3254 | print_request(m, rq, "\t\tfirst "); |
| 3255 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3256 | rq = list_last_entry(&engine->timeline->requests, |
| 3257 | struct drm_i915_gem_request, link); |
| 3258 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3259 | print_request(m, rq, "\t\tlast "); |
| 3260 | |
| 3261 | rq = i915_gem_find_active_request(engine); |
| 3262 | if (rq) { |
| 3263 | print_request(m, rq, "\t\tactive "); |
| 3264 | seq_printf(m, |
| 3265 | "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n", |
| 3266 | rq->head, rq->postfix, rq->tail, |
| 3267 | rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, |
| 3268 | rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); |
| 3269 | } |
| 3270 | |
| 3271 | seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n", |
| 3272 | I915_READ(RING_START(engine->mmio_base)), |
| 3273 | rq ? i915_ggtt_offset(rq->ring->vma) : 0); |
| 3274 | seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n", |
| 3275 | I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR, |
| 3276 | rq ? rq->ring->head : 0); |
| 3277 | seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n", |
| 3278 | I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR, |
| 3279 | rq ? rq->ring->tail : 0); |
| 3280 | seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n", |
| 3281 | I915_READ(RING_CTL(engine->mmio_base)), |
| 3282 | I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : ""); |
| 3283 | |
| 3284 | rcu_read_unlock(); |
| 3285 | |
| 3286 | addr = intel_engine_get_active_head(engine); |
| 3287 | seq_printf(m, "\tACTHD: 0x%08x_%08x\n", |
| 3288 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3289 | addr = intel_engine_get_last_batch_head(engine); |
| 3290 | seq_printf(m, "\tBBADDR: 0x%08x_%08x\n", |
| 3291 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3292 | |
| 3293 | if (i915.enable_execlists) { |
| 3294 | u32 ptr, read, write; |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3295 | struct rb_node *rb; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3296 | |
| 3297 | seq_printf(m, "\tExeclist status: 0x%08x %08x\n", |
| 3298 | I915_READ(RING_EXECLIST_STATUS_LO(engine)), |
| 3299 | I915_READ(RING_EXECLIST_STATUS_HI(engine))); |
| 3300 | |
| 3301 | ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
| 3302 | read = GEN8_CSB_READ_PTR(ptr); |
| 3303 | write = GEN8_CSB_WRITE_PTR(ptr); |
| 3304 | seq_printf(m, "\tExeclist CSB read %d, write %d\n", |
| 3305 | read, write); |
| 3306 | if (read >= GEN8_CSB_ENTRIES) |
| 3307 | read = 0; |
| 3308 | if (write >= GEN8_CSB_ENTRIES) |
| 3309 | write = 0; |
| 3310 | if (read > write) |
| 3311 | write += GEN8_CSB_ENTRIES; |
| 3312 | while (read < write) { |
| 3313 | unsigned int idx = ++read % GEN8_CSB_ENTRIES; |
| 3314 | |
| 3315 | seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n", |
| 3316 | idx, |
| 3317 | I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)), |
| 3318 | I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx))); |
| 3319 | } |
| 3320 | |
| 3321 | rcu_read_lock(); |
| 3322 | rq = READ_ONCE(engine->execlist_port[0].request); |
| 3323 | if (rq) |
| 3324 | print_request(m, rq, "\t\tELSP[0] "); |
| 3325 | else |
| 3326 | seq_printf(m, "\t\tELSP[0] idle\n"); |
| 3327 | rq = READ_ONCE(engine->execlist_port[1].request); |
| 3328 | if (rq) |
| 3329 | print_request(m, rq, "\t\tELSP[1] "); |
| 3330 | else |
| 3331 | seq_printf(m, "\t\tELSP[1] idle\n"); |
| 3332 | rcu_read_unlock(); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3333 | |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3334 | spin_lock_irq(&engine->timeline->lock); |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3335 | for (rb = engine->execlist_first; rb; rb = rb_next(rb)) { |
| 3336 | rq = rb_entry(rb, typeof(*rq), priotree.node); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3337 | print_request(m, rq, "\t\tQ "); |
| 3338 | } |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3339 | spin_unlock_irq(&engine->timeline->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3340 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 3341 | seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n", |
| 3342 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 3343 | seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n", |
| 3344 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 3345 | seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n", |
| 3346 | I915_READ(RING_PP_DIR_DCLV(engine))); |
| 3347 | } |
| 3348 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 3349 | spin_lock_irq(&b->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3350 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 3351 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3352 | |
| 3353 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 3354 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 3355 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 3356 | spin_unlock_irq(&b->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3357 | |
| 3358 | seq_puts(m, "\n"); |
| 3359 | } |
| 3360 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3361 | intel_runtime_pm_put(dev_priv); |
| 3362 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3363 | return 0; |
| 3364 | } |
| 3365 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3366 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3367 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3368 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3369 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3370 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3371 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3372 | enum intel_engine_id id; |
| 3373 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3374 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3375 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3376 | seq_puts(m, "Semaphores are disabled\n"); |
| 3377 | return 0; |
| 3378 | } |
| 3379 | |
| 3380 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3381 | if (ret) |
| 3382 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3383 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3384 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3385 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3386 | struct page *page; |
| 3387 | uint64_t *seqno; |
| 3388 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3389 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3390 | |
| 3391 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3392 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3393 | uint64_t offset; |
| 3394 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3395 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3396 | |
| 3397 | seq_puts(m, " Last signal:"); |
| 3398 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3399 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3400 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3401 | seqno[offset], offset * 8); |
| 3402 | } |
| 3403 | seq_putc(m, '\n'); |
| 3404 | |
| 3405 | seq_puts(m, " Last wait: "); |
| 3406 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3407 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3408 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3409 | seqno[offset], offset * 8); |
| 3410 | } |
| 3411 | seq_putc(m, '\n'); |
| 3412 | |
| 3413 | } |
| 3414 | kunmap_atomic(seqno); |
| 3415 | } else { |
| 3416 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3417 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3418 | for (j = 0; j < num_rings; j++) |
| 3419 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3420 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3421 | seq_putc(m, '\n'); |
| 3422 | } |
| 3423 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3424 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3425 | mutex_unlock(&dev->struct_mutex); |
| 3426 | return 0; |
| 3427 | } |
| 3428 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3429 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3430 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3431 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3432 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3433 | int i; |
| 3434 | |
| 3435 | drm_modeset_lock_all(dev); |
| 3436 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3437 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3438 | |
| 3439 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3440 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3441 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3442 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3443 | seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3444 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3445 | pll->state.hw_state.dpll_md); |
| 3446 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3447 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3448 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3449 | } |
| 3450 | drm_modeset_unlock_all(dev); |
| 3451 | |
| 3452 | return 0; |
| 3453 | } |
| 3454 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3455 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3456 | { |
| 3457 | int i; |
| 3458 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3459 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3460 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3461 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3462 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3463 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3464 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3465 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3466 | if (ret) |
| 3467 | return ret; |
| 3468 | |
| 3469 | intel_runtime_pm_get(dev_priv); |
| 3470 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3471 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3472 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3473 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3474 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3475 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3476 | i915_reg_t addr; |
| 3477 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3478 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3479 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3480 | addr = workarounds->reg[i].addr; |
| 3481 | mask = workarounds->reg[i].mask; |
| 3482 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3483 | read = I915_READ(addr); |
| 3484 | ok = (value & mask) == (read & mask); |
| 3485 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n", |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3486 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3487 | } |
| 3488 | |
| 3489 | intel_runtime_pm_put(dev_priv); |
| 3490 | mutex_unlock(&dev->struct_mutex); |
| 3491 | |
| 3492 | return 0; |
| 3493 | } |
| 3494 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3495 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3496 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3497 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3498 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3499 | struct skl_ddb_allocation *ddb; |
| 3500 | struct skl_ddb_entry *entry; |
| 3501 | enum pipe pipe; |
| 3502 | int plane; |
| 3503 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3504 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3505 | return 0; |
| 3506 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3507 | drm_modeset_lock_all(dev); |
| 3508 | |
| 3509 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3510 | |
| 3511 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3512 | |
| 3513 | for_each_pipe(dev_priv, pipe) { |
| 3514 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3515 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3516 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3517 | entry = &ddb->plane[pipe][plane]; |
| 3518 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3519 | entry->start, entry->end, |
| 3520 | skl_ddb_entry_size(entry)); |
| 3521 | } |
| 3522 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3523 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3524 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3525 | entry->end, skl_ddb_entry_size(entry)); |
| 3526 | } |
| 3527 | |
| 3528 | drm_modeset_unlock_all(dev); |
| 3529 | |
| 3530 | return 0; |
| 3531 | } |
| 3532 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3533 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3534 | struct drm_device *dev, |
| 3535 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3536 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3537 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3538 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3539 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3540 | struct drm_connector *connector; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3541 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3542 | drm_for_each_connector(connector, dev) { |
| 3543 | if (connector->state->crtc != &intel_crtc->base) |
| 3544 | continue; |
| 3545 | |
| 3546 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3547 | } |
| 3548 | |
| 3549 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3550 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3551 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3552 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3553 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3554 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3555 | else |
| 3556 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3557 | |
| 3558 | seq_puts(m, "\n\n"); |
| 3559 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3560 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3561 | struct intel_panel *panel; |
| 3562 | |
| 3563 | mutex_lock(&drrs->mutex); |
| 3564 | /* DRRS Supported */ |
| 3565 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3566 | |
| 3567 | /* disable_drrs() will make drrs->dp NULL */ |
| 3568 | if (!drrs->dp) { |
| 3569 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3570 | mutex_unlock(&drrs->mutex); |
| 3571 | return; |
| 3572 | } |
| 3573 | |
| 3574 | panel = &drrs->dp->attached_connector->panel; |
| 3575 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3576 | drrs->busy_frontbuffer_bits); |
| 3577 | |
| 3578 | seq_puts(m, "\n\t\t"); |
| 3579 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3580 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3581 | vrefresh = panel->fixed_mode->vrefresh; |
| 3582 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3583 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3584 | vrefresh = panel->downclock_mode->vrefresh; |
| 3585 | } else { |
| 3586 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3587 | drrs->refresh_rate_type); |
| 3588 | mutex_unlock(&drrs->mutex); |
| 3589 | return; |
| 3590 | } |
| 3591 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3592 | |
| 3593 | seq_puts(m, "\n\t\t"); |
| 3594 | mutex_unlock(&drrs->mutex); |
| 3595 | } else { |
| 3596 | /* DRRS not supported. Print the VBT parameter*/ |
| 3597 | seq_puts(m, "\tDRRS Supported : No"); |
| 3598 | } |
| 3599 | seq_puts(m, "\n"); |
| 3600 | } |
| 3601 | |
| 3602 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3603 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3604 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3605 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3606 | struct intel_crtc *intel_crtc; |
| 3607 | int active_crtc_cnt = 0; |
| 3608 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3609 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3610 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3611 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3612 | active_crtc_cnt++; |
| 3613 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3614 | |
| 3615 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3616 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3617 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3618 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3619 | |
| 3620 | if (!active_crtc_cnt) |
| 3621 | seq_puts(m, "No active crtc found\n"); |
| 3622 | |
| 3623 | return 0; |
| 3624 | } |
| 3625 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3626 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3627 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3628 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3629 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3630 | struct intel_encoder *intel_encoder; |
| 3631 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3632 | struct drm_connector *connector; |
| 3633 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3634 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3635 | drm_for_each_connector(connector, dev) { |
| 3636 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3637 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3638 | |
| 3639 | intel_encoder = intel_attached_encoder(connector); |
| 3640 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3641 | continue; |
| 3642 | |
| 3643 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3644 | if (!intel_dig_port->dp.can_mst) |
| 3645 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3646 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3647 | seq_printf(m, "MST Source Port %c\n", |
| 3648 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3649 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3650 | } |
| 3651 | drm_modeset_unlock_all(dev); |
| 3652 | return 0; |
| 3653 | } |
| 3654 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3655 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3656 | const char __user *ubuf, |
| 3657 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3658 | { |
| 3659 | char *input_buffer; |
| 3660 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3661 | struct drm_device *dev; |
| 3662 | struct drm_connector *connector; |
| 3663 | struct list_head *connector_list; |
| 3664 | struct intel_dp *intel_dp; |
| 3665 | int val = 0; |
| 3666 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3667 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3668 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3669 | connector_list = &dev->mode_config.connector_list; |
| 3670 | |
| 3671 | if (len == 0) |
| 3672 | return 0; |
| 3673 | |
| 3674 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 3675 | if (!input_buffer) |
| 3676 | return -ENOMEM; |
| 3677 | |
| 3678 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 3679 | status = -EFAULT; |
| 3680 | goto out; |
| 3681 | } |
| 3682 | |
| 3683 | input_buffer[len] = '\0'; |
| 3684 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3685 | |
| 3686 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3687 | if (connector->connector_type != |
| 3688 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3689 | continue; |
| 3690 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 3691 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3692 | connector->encoder != NULL) { |
| 3693 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3694 | status = kstrtoint(input_buffer, 10, &val); |
| 3695 | if (status < 0) |
| 3696 | goto out; |
| 3697 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3698 | /* To prevent erroneous activation of the compliance |
| 3699 | * testing code, only accept an actual value of 1 here |
| 3700 | */ |
| 3701 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3702 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3703 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3704 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3705 | } |
| 3706 | } |
| 3707 | out: |
| 3708 | kfree(input_buffer); |
| 3709 | if (status < 0) |
| 3710 | return status; |
| 3711 | |
| 3712 | *offp += len; |
| 3713 | return len; |
| 3714 | } |
| 3715 | |
| 3716 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3717 | { |
| 3718 | struct drm_device *dev = m->private; |
| 3719 | struct drm_connector *connector; |
| 3720 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 3721 | struct intel_dp *intel_dp; |
| 3722 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3723 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3724 | if (connector->connector_type != |
| 3725 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3726 | continue; |
| 3727 | |
| 3728 | if (connector->status == connector_status_connected && |
| 3729 | connector->encoder != NULL) { |
| 3730 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3731 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3732 | seq_puts(m, "1"); |
| 3733 | else |
| 3734 | seq_puts(m, "0"); |
| 3735 | } else |
| 3736 | seq_puts(m, "0"); |
| 3737 | } |
| 3738 | |
| 3739 | return 0; |
| 3740 | } |
| 3741 | |
| 3742 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3743 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3744 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3745 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3746 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3747 | return single_open(file, i915_displayport_test_active_show, |
| 3748 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3749 | } |
| 3750 | |
| 3751 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3752 | .owner = THIS_MODULE, |
| 3753 | .open = i915_displayport_test_active_open, |
| 3754 | .read = seq_read, |
| 3755 | .llseek = seq_lseek, |
| 3756 | .release = single_release, |
| 3757 | .write = i915_displayport_test_active_write |
| 3758 | }; |
| 3759 | |
| 3760 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3761 | { |
| 3762 | struct drm_device *dev = m->private; |
| 3763 | struct drm_connector *connector; |
| 3764 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 3765 | struct intel_dp *intel_dp; |
| 3766 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3767 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3768 | if (connector->connector_type != |
| 3769 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3770 | continue; |
| 3771 | |
| 3772 | if (connector->status == connector_status_connected && |
| 3773 | connector->encoder != NULL) { |
| 3774 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3775 | seq_printf(m, "%lx", intel_dp->compliance.test_data.edid); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3776 | } else |
| 3777 | seq_puts(m, "0"); |
| 3778 | } |
| 3779 | |
| 3780 | return 0; |
| 3781 | } |
| 3782 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3783 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3784 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3785 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3786 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3787 | return single_open(file, i915_displayport_test_data_show, |
| 3788 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3789 | } |
| 3790 | |
| 3791 | static const struct file_operations i915_displayport_test_data_fops = { |
| 3792 | .owner = THIS_MODULE, |
| 3793 | .open = i915_displayport_test_data_open, |
| 3794 | .read = seq_read, |
| 3795 | .llseek = seq_lseek, |
| 3796 | .release = single_release |
| 3797 | }; |
| 3798 | |
| 3799 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3800 | { |
| 3801 | struct drm_device *dev = m->private; |
| 3802 | struct drm_connector *connector; |
| 3803 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 3804 | struct intel_dp *intel_dp; |
| 3805 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3806 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3807 | if (connector->connector_type != |
| 3808 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3809 | continue; |
| 3810 | |
| 3811 | if (connector->status == connector_status_connected && |
| 3812 | connector->encoder != NULL) { |
| 3813 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3814 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3815 | } else |
| 3816 | seq_puts(m, "0"); |
| 3817 | } |
| 3818 | |
| 3819 | return 0; |
| 3820 | } |
| 3821 | |
| 3822 | static int i915_displayport_test_type_open(struct inode *inode, |
| 3823 | struct file *file) |
| 3824 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3825 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3826 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3827 | return single_open(file, i915_displayport_test_type_show, |
| 3828 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3829 | } |
| 3830 | |
| 3831 | static const struct file_operations i915_displayport_test_type_fops = { |
| 3832 | .owner = THIS_MODULE, |
| 3833 | .open = i915_displayport_test_type_open, |
| 3834 | .read = seq_read, |
| 3835 | .llseek = seq_lseek, |
| 3836 | .release = single_release |
| 3837 | }; |
| 3838 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3839 | 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] | 3840 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3841 | struct drm_i915_private *dev_priv = m->private; |
| 3842 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3843 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3844 | int num_levels; |
| 3845 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3846 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3847 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3848 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3849 | num_levels = 1; |
| 3850 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3851 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3852 | |
| 3853 | drm_modeset_lock_all(dev); |
| 3854 | |
| 3855 | for (level = 0; level < num_levels; level++) { |
| 3856 | unsigned int latency = wm[level]; |
| 3857 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3858 | /* |
| 3859 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3860 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3861 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3862 | if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) || |
| 3863 | IS_CHERRYVIEW(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3864 | latency *= 10; |
| 3865 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3866 | latency *= 5; |
| 3867 | |
| 3868 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3869 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3870 | } |
| 3871 | |
| 3872 | drm_modeset_unlock_all(dev); |
| 3873 | } |
| 3874 | |
| 3875 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3876 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3877 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3878 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3879 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3880 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3881 | latencies = dev_priv->wm.skl_latency; |
| 3882 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3883 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3884 | |
| 3885 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3886 | |
| 3887 | return 0; |
| 3888 | } |
| 3889 | |
| 3890 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3891 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3892 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3893 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3894 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3895 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3896 | latencies = dev_priv->wm.skl_latency; |
| 3897 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3898 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3899 | |
| 3900 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3901 | |
| 3902 | return 0; |
| 3903 | } |
| 3904 | |
| 3905 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3906 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3907 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3908 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3909 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3910 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3911 | latencies = dev_priv->wm.skl_latency; |
| 3912 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3913 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3914 | |
| 3915 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3916 | |
| 3917 | return 0; |
| 3918 | } |
| 3919 | |
| 3920 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3921 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3922 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3923 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3924 | if (INTEL_GEN(dev_priv) < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3925 | return -ENODEV; |
| 3926 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3927 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3928 | } |
| 3929 | |
| 3930 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3931 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3932 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3933 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3934 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3935 | return -ENODEV; |
| 3936 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3937 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3938 | } |
| 3939 | |
| 3940 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3941 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3942 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3943 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3944 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3945 | return -ENODEV; |
| 3946 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3947 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3948 | } |
| 3949 | |
| 3950 | 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] | 3951 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3952 | { |
| 3953 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3954 | struct drm_i915_private *dev_priv = m->private; |
| 3955 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3956 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3957 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3958 | int level; |
| 3959 | int ret; |
| 3960 | char tmp[32]; |
| 3961 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3962 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3963 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3964 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3965 | num_levels = 1; |
| 3966 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3967 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3968 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3969 | if (len >= sizeof(tmp)) |
| 3970 | return -EINVAL; |
| 3971 | |
| 3972 | if (copy_from_user(tmp, ubuf, len)) |
| 3973 | return -EFAULT; |
| 3974 | |
| 3975 | tmp[len] = '\0'; |
| 3976 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3977 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3978 | &new[0], &new[1], &new[2], &new[3], |
| 3979 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3980 | if (ret != num_levels) |
| 3981 | return -EINVAL; |
| 3982 | |
| 3983 | drm_modeset_lock_all(dev); |
| 3984 | |
| 3985 | for (level = 0; level < num_levels; level++) |
| 3986 | wm[level] = new[level]; |
| 3987 | |
| 3988 | drm_modeset_unlock_all(dev); |
| 3989 | |
| 3990 | return len; |
| 3991 | } |
| 3992 | |
| 3993 | |
| 3994 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3995 | size_t len, loff_t *offp) |
| 3996 | { |
| 3997 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3998 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3999 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4000 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4001 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4002 | latencies = dev_priv->wm.skl_latency; |
| 4003 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4004 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4005 | |
| 4006 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4007 | } |
| 4008 | |
| 4009 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4010 | size_t len, loff_t *offp) |
| 4011 | { |
| 4012 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4013 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4014 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4015 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4016 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4017 | latencies = dev_priv->wm.skl_latency; |
| 4018 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4019 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4020 | |
| 4021 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4022 | } |
| 4023 | |
| 4024 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4025 | size_t len, loff_t *offp) |
| 4026 | { |
| 4027 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4028 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4029 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4030 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4031 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4032 | latencies = dev_priv->wm.skl_latency; |
| 4033 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4034 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4035 | |
| 4036 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4037 | } |
| 4038 | |
| 4039 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4040 | .owner = THIS_MODULE, |
| 4041 | .open = pri_wm_latency_open, |
| 4042 | .read = seq_read, |
| 4043 | .llseek = seq_lseek, |
| 4044 | .release = single_release, |
| 4045 | .write = pri_wm_latency_write |
| 4046 | }; |
| 4047 | |
| 4048 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4049 | .owner = THIS_MODULE, |
| 4050 | .open = spr_wm_latency_open, |
| 4051 | .read = seq_read, |
| 4052 | .llseek = seq_lseek, |
| 4053 | .release = single_release, |
| 4054 | .write = spr_wm_latency_write |
| 4055 | }; |
| 4056 | |
| 4057 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4058 | .owner = THIS_MODULE, |
| 4059 | .open = cur_wm_latency_open, |
| 4060 | .read = seq_read, |
| 4061 | .llseek = seq_lseek, |
| 4062 | .release = single_release, |
| 4063 | .write = cur_wm_latency_write |
| 4064 | }; |
| 4065 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4066 | static int |
| 4067 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4068 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4069 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4070 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4071 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4072 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4073 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4074 | } |
| 4075 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4076 | static int |
| 4077 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4078 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4079 | struct drm_i915_private *dev_priv = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4080 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4081 | /* |
| 4082 | * There is no safeguard against this debugfs entry colliding |
| 4083 | * with the hangcheck calling same i915_handle_error() in |
| 4084 | * parallel, causing an explosion. For now we assume that the |
| 4085 | * test harness is responsible enough not to inject gpu hangs |
| 4086 | * while it is writing to 'i915_wedged' |
| 4087 | */ |
| 4088 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4089 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4090 | return -EAGAIN; |
| 4091 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4092 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4093 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4094 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4095 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4096 | } |
| 4097 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4098 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4099 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4100 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4101 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4102 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4103 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4104 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4105 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4106 | |
| 4107 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4108 | return 0; |
| 4109 | } |
| 4110 | |
| 4111 | static int |
| 4112 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4113 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4114 | struct drm_i915_private *dev_priv = data; |
| 4115 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4116 | int ret; |
| 4117 | |
| 4118 | /* Lock against concurrent debugfs callers */ |
| 4119 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4120 | if (ret) |
| 4121 | return ret; |
| 4122 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4123 | mutex_unlock(&dev->struct_mutex); |
| 4124 | |
| 4125 | return 0; |
| 4126 | } |
| 4127 | |
| 4128 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4129 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4130 | "0x%08llx\n"); |
| 4131 | |
| 4132 | static int |
| 4133 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4134 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4135 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4136 | |
| 4137 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4138 | |
| 4139 | return 0; |
| 4140 | } |
| 4141 | |
| 4142 | static int |
| 4143 | i915_ring_test_irq_set(void *data, u64 val) |
| 4144 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4145 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4146 | |
Chris Wilson | 3a122c2 | 2016-06-17 14:35:05 +0100 | [diff] [blame] | 4147 | val &= INTEL_INFO(dev_priv)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4148 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4149 | dev_priv->gpu_error.test_irq_rings = val; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4150 | |
| 4151 | return 0; |
| 4152 | } |
| 4153 | |
| 4154 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4155 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4156 | "0x%08llx\n"); |
| 4157 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4158 | #define DROP_UNBOUND 0x1 |
| 4159 | #define DROP_BOUND 0x2 |
| 4160 | #define DROP_RETIRE 0x4 |
| 4161 | #define DROP_ACTIVE 0x8 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4162 | #define DROP_FREED 0x10 |
| 4163 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4164 | DROP_BOUND | \ |
| 4165 | DROP_RETIRE | \ |
| 4166 | DROP_ACTIVE | \ |
| 4167 | DROP_FREED) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4168 | static int |
| 4169 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4170 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4171 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4172 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4173 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4174 | } |
| 4175 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4176 | static int |
| 4177 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4178 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4179 | struct drm_i915_private *dev_priv = data; |
| 4180 | struct drm_device *dev = &dev_priv->drm; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4181 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4182 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4183 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4184 | |
| 4185 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4186 | * on ioctls on -EAGAIN. */ |
| 4187 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4188 | if (ret) |
| 4189 | return ret; |
| 4190 | |
| 4191 | if (val & DROP_ACTIVE) { |
Chris Wilson | 22dd3bb | 2016-09-09 14:11:50 +0100 | [diff] [blame] | 4192 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4193 | I915_WAIT_INTERRUPTIBLE | |
| 4194 | I915_WAIT_LOCKED); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4195 | if (ret) |
| 4196 | goto unlock; |
| 4197 | } |
| 4198 | |
| 4199 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4200 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4201 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4202 | if (val & DROP_BOUND) |
| 4203 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4204 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4205 | if (val & DROP_UNBOUND) |
| 4206 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4207 | |
| 4208 | unlock: |
| 4209 | mutex_unlock(&dev->struct_mutex); |
| 4210 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4211 | if (val & DROP_FREED) { |
| 4212 | synchronize_rcu(); |
Chris Wilson | bdeb978 | 2016-12-23 14:57:56 +0000 | [diff] [blame] | 4213 | i915_gem_drain_freed_objects(dev_priv); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4214 | } |
| 4215 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4216 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4217 | } |
| 4218 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4219 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4220 | i915_drop_caches_get, i915_drop_caches_set, |
| 4221 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4222 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4223 | static int |
| 4224 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4225 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4226 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4227 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4228 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4229 | return -ENODEV; |
| 4230 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4231 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4232 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4233 | } |
| 4234 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4235 | static int |
| 4236 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4237 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4238 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4239 | u32 hw_max, hw_min; |
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 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4242 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4243 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4244 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4245 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 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; |
| 4250 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4251 | /* |
| 4252 | * Turbo will still be enabled, but won't go above the set value. |
| 4253 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4254 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4255 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4256 | hw_max = dev_priv->rps.max_freq; |
| 4257 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4258 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4259 | 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] | 4260 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4261 | return -EINVAL; |
| 4262 | } |
| 4263 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4264 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4265 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 4266 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4267 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4268 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4269 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4270 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4271 | } |
| 4272 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4273 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4274 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4275 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4276 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4277 | static int |
| 4278 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4279 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4280 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4281 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4282 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4283 | return -ENODEV; |
| 4284 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4285 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4286 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4287 | } |
| 4288 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4289 | static int |
| 4290 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4291 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4292 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4293 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4294 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4295 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4296 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4297 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4298 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4299 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4300 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4301 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4302 | if (ret) |
| 4303 | return ret; |
| 4304 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4305 | /* |
| 4306 | * Turbo will still be enabled, but won't go below the set value. |
| 4307 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4308 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4309 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4310 | hw_max = dev_priv->rps.max_freq; |
| 4311 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4312 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4313 | if (val < hw_min || |
| 4314 | val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4315 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4316 | return -EINVAL; |
| 4317 | } |
| 4318 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4319 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4320 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 4321 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4322 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4323 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4324 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4325 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4326 | } |
| 4327 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4328 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4329 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4330 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4331 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4332 | static int |
| 4333 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4334 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4335 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4336 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4337 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4338 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4339 | return -ENODEV; |
| 4340 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4341 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4342 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4343 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4344 | |
| 4345 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4346 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4347 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4348 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4349 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4350 | } |
| 4351 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4352 | static int |
| 4353 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4354 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4355 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4356 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4357 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4358 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4359 | return -ENODEV; |
| 4360 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4361 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4362 | return -EINVAL; |
| 4363 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4364 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4365 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4366 | |
| 4367 | /* Update the cache sharing policy here as well */ |
| 4368 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4369 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4370 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4371 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4372 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4373 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4374 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4375 | } |
| 4376 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4377 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4378 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4379 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4380 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4381 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4382 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4383 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 4384 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4385 | int ss; |
| 4386 | u32 sig1[ss_max], sig2[ss_max]; |
| 4387 | |
| 4388 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4389 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4390 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4391 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4392 | |
| 4393 | for (ss = 0; ss < ss_max; ss++) { |
| 4394 | unsigned int eu_cnt; |
| 4395 | |
| 4396 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4397 | /* skip disabled subslice */ |
| 4398 | continue; |
| 4399 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4400 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4401 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4402 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4403 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4404 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4405 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4406 | sseu->eu_total += eu_cnt; |
| 4407 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4408 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4409 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4410 | } |
| 4411 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4412 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4413 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4414 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4415 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4416 | int s, ss; |
| 4417 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4418 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4419 | /* BXT has a single slice and at most 3 subslices. */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4420 | if (IS_GEN9_LP(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4421 | s_max = 1; |
| 4422 | ss_max = 3; |
| 4423 | } |
| 4424 | |
| 4425 | for (s = 0; s < s_max; s++) { |
| 4426 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4427 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4428 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4429 | } |
| 4430 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4431 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4432 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4433 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4434 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4435 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4436 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4437 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4438 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4439 | |
| 4440 | for (s = 0; s < s_max; s++) { |
| 4441 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4442 | /* skip disabled slice */ |
| 4443 | continue; |
| 4444 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4445 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4446 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4447 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4448 | sseu->subslice_mask = |
| 4449 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4450 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4451 | for (ss = 0; ss < ss_max; ss++) { |
| 4452 | unsigned int eu_cnt; |
| 4453 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4454 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4455 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4456 | /* skip disabled subslice */ |
| 4457 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4458 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4459 | sseu->subslice_mask |= BIT(ss); |
| 4460 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4461 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4462 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4463 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4464 | sseu->eu_total += eu_cnt; |
| 4465 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4466 | sseu->eu_per_subslice, |
| 4467 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4468 | } |
| 4469 | } |
| 4470 | } |
| 4471 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4472 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4473 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4474 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4475 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4476 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4477 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4478 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4479 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4480 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4481 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4482 | sseu->eu_per_subslice = |
| 4483 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4484 | sseu->eu_total = sseu->eu_per_subslice * |
| 4485 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4486 | |
| 4487 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4488 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4489 | u8 subslice_7eu = |
| 4490 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4491 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4492 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4493 | } |
| 4494 | } |
| 4495 | } |
| 4496 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4497 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4498 | const struct sseu_dev_info *sseu) |
| 4499 | { |
| 4500 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4501 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 4502 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4503 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4504 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4505 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4506 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4507 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4508 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4509 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 4510 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4511 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4512 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4513 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4514 | sseu->eu_total); |
| 4515 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4516 | sseu->eu_per_subslice); |
| 4517 | |
| 4518 | if (!is_available_info) |
| 4519 | return; |
| 4520 | |
| 4521 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4522 | if (HAS_POOLED_EU(dev_priv)) |
| 4523 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4524 | |
| 4525 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4526 | yesno(sseu->has_slice_pg)); |
| 4527 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4528 | yesno(sseu->has_subslice_pg)); |
| 4529 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4530 | yesno(sseu->has_eu_pg)); |
| 4531 | } |
| 4532 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4533 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4534 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4535 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4536 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4537 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4538 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4539 | return -ENODEV; |
| 4540 | |
| 4541 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4542 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4543 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4544 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4545 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4546 | |
| 4547 | intel_runtime_pm_get(dev_priv); |
| 4548 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4549 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4550 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4551 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4552 | broadwell_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4553 | } else if (INTEL_GEN(dev_priv) >= 9) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4554 | gen9_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4555 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4556 | |
| 4557 | intel_runtime_pm_put(dev_priv); |
| 4558 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4559 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4560 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4561 | return 0; |
| 4562 | } |
| 4563 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4564 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4565 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4566 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4567 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4568 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4569 | return 0; |
| 4570 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4571 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4572 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4573 | |
| 4574 | return 0; |
| 4575 | } |
| 4576 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4577 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4578 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4579 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4580 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4581 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4582 | return 0; |
| 4583 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4584 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4585 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4586 | |
| 4587 | return 0; |
| 4588 | } |
| 4589 | |
| 4590 | static const struct file_operations i915_forcewake_fops = { |
| 4591 | .owner = THIS_MODULE, |
| 4592 | .open = i915_forcewake_open, |
| 4593 | .release = i915_forcewake_release, |
| 4594 | }; |
| 4595 | |
| 4596 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 4597 | { |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4598 | struct dentry *ent; |
| 4599 | |
| 4600 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4601 | S_IRUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4602 | root, to_i915(minor->dev), |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4603 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4604 | if (!ent) |
| 4605 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4606 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4607 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4608 | } |
| 4609 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4610 | static int i915_debugfs_create(struct dentry *root, |
| 4611 | struct drm_minor *minor, |
| 4612 | const char *name, |
| 4613 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4614 | { |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4615 | struct dentry *ent; |
| 4616 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4617 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4618 | S_IRUGO | S_IWUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4619 | root, to_i915(minor->dev), |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4620 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4621 | if (!ent) |
| 4622 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4623 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4624 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4625 | } |
| 4626 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4627 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4628 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4629 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4630 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 4631 | {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4632 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4633 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4634 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4635 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4636 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4637 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4638 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4639 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4640 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4641 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame^] | 4642 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4643 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4644 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4645 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4646 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4647 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4648 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4649 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4650 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4651 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4652 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4653 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4654 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4655 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4656 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4657 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4658 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4659 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4660 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4661 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4662 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4663 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4664 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4665 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4666 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4667 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4668 | {"i915_engine_info", i915_engine_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4669 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4670 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4671 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4672 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4673 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4674 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4675 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4676 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4677 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4678 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4679 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4680 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4681 | const char *name; |
| 4682 | const struct file_operations *fops; |
| 4683 | } i915_debugfs_files[] = { |
| 4684 | {"i915_wedged", &i915_wedged_fops}, |
| 4685 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4686 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4687 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4688 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4689 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4690 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4691 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4692 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4693 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4694 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4695 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4696 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4697 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4698 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 4699 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4700 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4701 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4702 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
| 4703 | {"i915_guc_log_control", &i915_guc_log_control_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4704 | }; |
| 4705 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4706 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4707 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4708 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4709 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4710 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4711 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 4712 | if (ret) |
| 4713 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4714 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame] | 4715 | ret = intel_pipe_crc_create(minor); |
| 4716 | if (ret) |
| 4717 | return ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4718 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4719 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4720 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 4721 | i915_debugfs_files[i].name, |
| 4722 | i915_debugfs_files[i].fops); |
| 4723 | if (ret) |
| 4724 | return ret; |
| 4725 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4726 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4727 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4728 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4729 | minor->debugfs_root, minor); |
| 4730 | } |
| 4731 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4732 | void i915_debugfs_unregister(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4733 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4734 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4735 | int i; |
| 4736 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4737 | drm_debugfs_remove_files(i915_debugfs_list, |
| 4738 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4739 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4740 | drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4741 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4742 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame] | 4743 | intel_pipe_crc_cleanup(minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4744 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4745 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4746 | struct drm_info_list *info_list = |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4747 | (struct drm_info_list *)i915_debugfs_files[i].fops; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4748 | |
| 4749 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4750 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4751 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4752 | |
| 4753 | struct dpcd_block { |
| 4754 | /* DPCD dump start address. */ |
| 4755 | unsigned int offset; |
| 4756 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4757 | unsigned int end; |
| 4758 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4759 | size_t size; |
| 4760 | /* Only valid for eDP. */ |
| 4761 | bool edp; |
| 4762 | }; |
| 4763 | |
| 4764 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4765 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4766 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4767 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4768 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4769 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4770 | { .offset = DP_SET_POWER }, |
| 4771 | { .offset = DP_EDP_DPCD_REV }, |
| 4772 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4773 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4774 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4775 | }; |
| 4776 | |
| 4777 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4778 | { |
| 4779 | struct drm_connector *connector = m->private; |
| 4780 | struct intel_dp *intel_dp = |
| 4781 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4782 | uint8_t buf[16]; |
| 4783 | ssize_t err; |
| 4784 | int i; |
| 4785 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4786 | if (connector->status != connector_status_connected) |
| 4787 | return -ENODEV; |
| 4788 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4789 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4790 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4791 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4792 | |
| 4793 | if (b->edp && |
| 4794 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4795 | continue; |
| 4796 | |
| 4797 | /* low tech for now */ |
| 4798 | if (WARN_ON(size > sizeof(buf))) |
| 4799 | continue; |
| 4800 | |
| 4801 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 4802 | if (err <= 0) { |
| 4803 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 4804 | size, b->offset, err); |
| 4805 | continue; |
| 4806 | } |
| 4807 | |
| 4808 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4809 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4810 | |
| 4811 | return 0; |
| 4812 | } |
| 4813 | |
| 4814 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 4815 | { |
| 4816 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 4817 | } |
| 4818 | |
| 4819 | static const struct file_operations i915_dpcd_fops = { |
| 4820 | .owner = THIS_MODULE, |
| 4821 | .open = i915_dpcd_open, |
| 4822 | .read = seq_read, |
| 4823 | .llseek = seq_lseek, |
| 4824 | .release = single_release, |
| 4825 | }; |
| 4826 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4827 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4828 | { |
| 4829 | struct drm_connector *connector = m->private; |
| 4830 | struct intel_dp *intel_dp = |
| 4831 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4832 | |
| 4833 | if (connector->status != connector_status_connected) |
| 4834 | return -ENODEV; |
| 4835 | |
| 4836 | seq_printf(m, "Panel power up delay: %d\n", |
| 4837 | intel_dp->panel_power_up_delay); |
| 4838 | seq_printf(m, "Panel power down delay: %d\n", |
| 4839 | intel_dp->panel_power_down_delay); |
| 4840 | seq_printf(m, "Backlight on delay: %d\n", |
| 4841 | intel_dp->backlight_on_delay); |
| 4842 | seq_printf(m, "Backlight off delay: %d\n", |
| 4843 | intel_dp->backlight_off_delay); |
| 4844 | |
| 4845 | return 0; |
| 4846 | } |
| 4847 | |
| 4848 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 4849 | { |
| 4850 | return single_open(file, i915_panel_show, inode->i_private); |
| 4851 | } |
| 4852 | |
| 4853 | static const struct file_operations i915_panel_fops = { |
| 4854 | .owner = THIS_MODULE, |
| 4855 | .open = i915_panel_open, |
| 4856 | .read = seq_read, |
| 4857 | .llseek = seq_lseek, |
| 4858 | .release = single_release, |
| 4859 | }; |
| 4860 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4861 | /** |
| 4862 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4863 | * @connector: pointer to a registered drm_connector |
| 4864 | * |
| 4865 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4866 | * drm_debugfs_connector_remove(). |
| 4867 | * |
| 4868 | * Returns 0 on success, negative error codes on error. |
| 4869 | */ |
| 4870 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 4871 | { |
| 4872 | struct dentry *root = connector->debugfs_entry; |
| 4873 | |
| 4874 | /* The connector must have been registered beforehands. */ |
| 4875 | if (!root) |
| 4876 | return -ENODEV; |
| 4877 | |
| 4878 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4879 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4880 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 4881 | connector, &i915_dpcd_fops); |
| 4882 | |
| 4883 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 4884 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 4885 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4886 | |
| 4887 | return 0; |
| 4888 | } |