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 | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 162 | if (i915_vma_is_ggtt(vma)) |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 163 | seq_printf(m, ", type: %u", vma->ggtt_view.type); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 164 | if (vma->fence) |
| 165 | seq_printf(m, " , fence: %d%s", |
| 166 | vma->fence->id, |
| 167 | i915_gem_active_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 168 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 169 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 170 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 171 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 172 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 173 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 174 | if (engine) |
| 175 | seq_printf(m, " (%s)", engine->name); |
| 176 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 177 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 178 | if (frontbuffer_bits) |
| 179 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 180 | } |
| 181 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 182 | static int obj_rank_by_stolen(void *priv, |
| 183 | struct list_head *A, struct list_head *B) |
| 184 | { |
| 185 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 186 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 187 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 188 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 189 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 190 | if (a->stolen->start < b->stolen->start) |
| 191 | return -1; |
| 192 | if (a->stolen->start > b->stolen->start) |
| 193 | return 1; |
| 194 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 198 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 199 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 200 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 201 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 202 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 203 | LIST_HEAD(stolen); |
| 204 | int count, ret; |
| 205 | |
| 206 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 207 | if (ret) |
| 208 | return ret; |
| 209 | |
| 210 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 211 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 212 | if (obj->stolen == NULL) |
| 213 | continue; |
| 214 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 215 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 216 | |
| 217 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 218 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 219 | count++; |
| 220 | } |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 221 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 222 | if (obj->stolen == NULL) |
| 223 | continue; |
| 224 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 225 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 226 | |
| 227 | total_obj_size += obj->base.size; |
| 228 | count++; |
| 229 | } |
| 230 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 231 | seq_puts(m, "Stolen:\n"); |
| 232 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 233 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 234 | seq_puts(m, " "); |
| 235 | describe_obj(m, obj); |
| 236 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 237 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 238 | } |
| 239 | mutex_unlock(&dev->struct_mutex); |
| 240 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 241 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 242 | count, total_obj_size, total_gtt_size); |
| 243 | return 0; |
| 244 | } |
| 245 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 246 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 247 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 248 | unsigned long count; |
| 249 | u64 total, unbound; |
| 250 | u64 global, shared; |
| 251 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 252 | }; |
| 253 | |
| 254 | static int per_file_stats(int id, void *ptr, void *data) |
| 255 | { |
| 256 | struct drm_i915_gem_object *obj = ptr; |
| 257 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 258 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 259 | |
| 260 | stats->count++; |
| 261 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 262 | if (!obj->bind_count) |
| 263 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 264 | if (obj->base.name || obj->base.dma_buf) |
| 265 | stats->shared += obj->base.size; |
| 266 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 267 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 268 | if (!drm_mm_node_allocated(&vma->node)) |
| 269 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 270 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 271 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 272 | stats->global += vma->node.size; |
| 273 | } else { |
| 274 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 275 | |
Chris Wilson | 2bfa996 | 2016-08-04 07:52:25 +0100 | [diff] [blame] | 276 | if (ppgtt->base.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 277 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 278 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 279 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 280 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 281 | stats->active += vma->node.size; |
| 282 | else |
| 283 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | return 0; |
| 287 | } |
| 288 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 289 | #define print_file_stats(m, name, stats) do { \ |
| 290 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 291 | 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] | 292 | name, \ |
| 293 | stats.count, \ |
| 294 | stats.total, \ |
| 295 | stats.active, \ |
| 296 | stats.inactive, \ |
| 297 | stats.global, \ |
| 298 | stats.shared, \ |
| 299 | stats.unbound); \ |
| 300 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 301 | |
| 302 | static void print_batch_pool_stats(struct seq_file *m, |
| 303 | struct drm_i915_private *dev_priv) |
| 304 | { |
| 305 | struct drm_i915_gem_object *obj; |
| 306 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 307 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 308 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 309 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 310 | |
| 311 | memset(&stats, 0, sizeof(stats)); |
| 312 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 313 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 314 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 315 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 316 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 317 | batch_pool_link) |
| 318 | per_file_stats(0, obj, &stats); |
| 319 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 320 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 321 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 322 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 325 | static int per_file_ctx_stats(int id, void *ptr, void *data) |
| 326 | { |
| 327 | struct i915_gem_context *ctx = ptr; |
| 328 | int n; |
| 329 | |
| 330 | for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) { |
| 331 | if (ctx->engine[n].state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 332 | per_file_stats(0, ctx->engine[n].state->obj, data); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 333 | if (ctx->engine[n].ring) |
Chris Wilson | 57e8853 | 2016-08-15 10:48:57 +0100 | [diff] [blame] | 334 | per_file_stats(0, ctx->engine[n].ring->vma->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | static void print_context_stats(struct seq_file *m, |
| 341 | struct drm_i915_private *dev_priv) |
| 342 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 343 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 344 | struct file_stats stats; |
| 345 | struct drm_file *file; |
| 346 | |
| 347 | memset(&stats, 0, sizeof(stats)); |
| 348 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 349 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 350 | if (dev_priv->kernel_context) |
| 351 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 352 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 353 | list_for_each_entry(file, &dev->filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 354 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 355 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 356 | } |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 357 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 358 | |
| 359 | print_file_stats(m, "[k]contexts", stats); |
| 360 | } |
| 361 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 362 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 363 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 364 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 365 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 366 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 367 | u32 count, mapped_count, purgeable_count, dpy_count; |
| 368 | u64 size, mapped_size, purgeable_size, dpy_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 369 | struct drm_i915_gem_object *obj; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 370 | struct drm_file *file; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 371 | int ret; |
| 372 | |
| 373 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 374 | if (ret) |
| 375 | return ret; |
| 376 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 377 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 378 | dev_priv->mm.object_count, |
| 379 | dev_priv->mm.object_memory); |
| 380 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 381 | size = count = 0; |
| 382 | mapped_size = mapped_count = 0; |
| 383 | purgeable_size = purgeable_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 384 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 385 | size += obj->base.size; |
| 386 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 387 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 388 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 389 | purgeable_size += obj->base.size; |
| 390 | ++purgeable_count; |
| 391 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 392 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 393 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 394 | mapped_count++; |
| 395 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 396 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 397 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 398 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 399 | |
| 400 | size = count = dpy_size = dpy_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 401 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 402 | size += obj->base.size; |
| 403 | ++count; |
| 404 | |
| 405 | if (obj->pin_display) { |
| 406 | dpy_size += obj->base.size; |
| 407 | ++dpy_count; |
| 408 | } |
| 409 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 410 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 411 | purgeable_size += obj->base.size; |
| 412 | ++purgeable_count; |
| 413 | } |
| 414 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 415 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 416 | mapped_count++; |
| 417 | mapped_size += obj->base.size; |
| 418 | } |
| 419 | } |
| 420 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 421 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 422 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 423 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 424 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 425 | mapped_count, mapped_size); |
| 426 | seq_printf(m, "%u display objects (pinned), %llu bytes\n", |
| 427 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 428 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 429 | seq_printf(m, "%llu [%llu] gtt total\n", |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 430 | ggtt->base.total, ggtt->mappable_end - ggtt->base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 431 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 432 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 433 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 434 | mutex_unlock(&dev->struct_mutex); |
| 435 | |
| 436 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 437 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 438 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 439 | struct file_stats stats; |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 440 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 441 | struct drm_i915_gem_request *request; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 442 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 443 | |
| 444 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 445 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 446 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 447 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 448 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 449 | /* |
| 450 | * Although we have a valid reference on file->pid, that does |
| 451 | * not guarantee that the task_struct who called get_pid() is |
| 452 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 453 | * Therefore, we need to protect this ->comm access using RCU. |
| 454 | */ |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 455 | mutex_lock(&dev->struct_mutex); |
| 456 | request = list_first_entry_or_null(&file_priv->mm.request_list, |
| 457 | struct drm_i915_gem_request, |
| 458 | client_list); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 459 | rcu_read_lock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 460 | task = pid_task(request && request->ctx->pid ? |
| 461 | request->ctx->pid : file->pid, |
| 462 | PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 463 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 464 | rcu_read_unlock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 465 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 466 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 467 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 468 | |
| 469 | return 0; |
| 470 | } |
| 471 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 472 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 473 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 474 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 475 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 476 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 5f4b091 | 2016-08-19 12:56:25 +0100 | [diff] [blame] | 477 | bool show_pin_display_only = !!node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 478 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 479 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 480 | int count, ret; |
| 481 | |
| 482 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 483 | if (ret) |
| 484 | return ret; |
| 485 | |
| 486 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 487 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 488 | if (show_pin_display_only && !obj->pin_display) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 489 | continue; |
| 490 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 491 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 492 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 493 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 494 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 495 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 496 | count++; |
| 497 | } |
| 498 | |
| 499 | mutex_unlock(&dev->struct_mutex); |
| 500 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 501 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 502 | count, total_obj_size, total_gtt_size); |
| 503 | |
| 504 | return 0; |
| 505 | } |
| 506 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 507 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 508 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 509 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 510 | struct drm_device *dev = &dev_priv->drm; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 511 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 512 | int ret; |
| 513 | |
| 514 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 515 | if (ret) |
| 516 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 517 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 518 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 519 | const char pipe = pipe_name(crtc->pipe); |
| 520 | const char plane = plane_name(crtc->plane); |
Maarten Lankhorst | 51cbaf0 | 2016-05-17 15:07:49 +0200 | [diff] [blame] | 521 | struct intel_flip_work *work; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 522 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 523 | spin_lock_irq(&dev->event_lock); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 524 | work = crtc->flip_work; |
| 525 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 526 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 527 | pipe, plane); |
| 528 | } else { |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 529 | u32 pending; |
| 530 | u32 addr; |
| 531 | |
| 532 | pending = atomic_read(&work->pending); |
| 533 | if (pending) { |
| 534 | seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n", |
| 535 | pipe, plane); |
| 536 | } else { |
| 537 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
| 538 | pipe, plane); |
| 539 | } |
| 540 | if (work->flip_queued_req) { |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 541 | struct intel_engine_cs *engine = work->flip_queued_req->engine; |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 542 | |
Chris Wilson | 312c3c4 | 2016-11-24 14:47:50 +0000 | [diff] [blame] | 543 | 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] | 544 | engine->name, |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 545 | work->flip_queued_req->global_seqno, |
Chris Wilson | 312c3c4 | 2016-11-24 14:47:50 +0000 | [diff] [blame] | 546 | intel_engine_last_submit(engine), |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 547 | intel_engine_get_seqno(engine), |
Chris Wilson | f69a02c | 2016-07-01 17:23:16 +0100 | [diff] [blame] | 548 | i915_gem_request_completed(work->flip_queued_req)); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 549 | } else |
| 550 | seq_printf(m, "Flip not associated with any ring\n"); |
| 551 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 552 | work->flip_queued_vblank, |
| 553 | work->flip_ready_vblank, |
| 554 | intel_crtc_get_vblank_counter(crtc)); |
| 555 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
| 556 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 557 | if (INTEL_GEN(dev_priv) >= 4) |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 558 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 559 | else |
| 560 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 561 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 562 | |
| 563 | if (work->pending_flip_obj) { |
| 564 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 565 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 566 | } |
| 567 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 568 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 569 | } |
| 570 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 571 | mutex_unlock(&dev->struct_mutex); |
| 572 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 573 | return 0; |
| 574 | } |
| 575 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 576 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 577 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 578 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 579 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 580 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 581 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 582 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 583 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 584 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 585 | |
| 586 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 587 | if (ret) |
| 588 | return ret; |
| 589 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 590 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 591 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 592 | int count; |
| 593 | |
| 594 | count = 0; |
| 595 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 596 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 597 | batch_pool_link) |
| 598 | count++; |
| 599 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 600 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 601 | |
| 602 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 603 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 604 | batch_pool_link) { |
| 605 | seq_puts(m, " "); |
| 606 | describe_obj(m, obj); |
| 607 | seq_putc(m, '\n'); |
| 608 | } |
| 609 | |
| 610 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 611 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 612 | } |
| 613 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 614 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 615 | |
| 616 | mutex_unlock(&dev->struct_mutex); |
| 617 | |
| 618 | return 0; |
| 619 | } |
| 620 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 621 | static void print_request(struct seq_file *m, |
| 622 | struct drm_i915_gem_request *rq, |
| 623 | const char *prefix) |
| 624 | { |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 625 | 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] | 626 | rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno, |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 627 | rq->priotree.priority, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 628 | jiffies_to_msecs(jiffies - rq->emitted_jiffies), |
Chris Wilson | 562f5d4 | 2016-10-28 13:58:54 +0100 | [diff] [blame] | 629 | rq->timeline->common->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 630 | } |
| 631 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 632 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 633 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 634 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 635 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 636 | struct drm_i915_gem_request *req; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 637 | struct intel_engine_cs *engine; |
| 638 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 639 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 640 | |
| 641 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 642 | if (ret) |
| 643 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 644 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 645 | any = 0; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 646 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 647 | int count; |
| 648 | |
| 649 | count = 0; |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 650 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 651 | count++; |
| 652 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 653 | continue; |
| 654 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 655 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 656 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 657 | print_request(m, req, " "); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 658 | |
| 659 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 660 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 661 | mutex_unlock(&dev->struct_mutex); |
| 662 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 663 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 664 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 665 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 666 | return 0; |
| 667 | } |
| 668 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 669 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 670 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 671 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 672 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 673 | struct rb_node *rb; |
| 674 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 675 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 676 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 677 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 678 | spin_lock_irq(&b->lock); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 679 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 680 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 681 | |
| 682 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 683 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 684 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 685 | spin_unlock_irq(&b->lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 686 | } |
| 687 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 688 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 689 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 690 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 691 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 692 | enum intel_engine_id id; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 693 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 694 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 695 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 696 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 697 | return 0; |
| 698 | } |
| 699 | |
| 700 | |
| 701 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 702 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 703 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 704 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 705 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 706 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 707 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 708 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 709 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 710 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 711 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 712 | I915_READ(GEN8_MASTER_IRQ)); |
| 713 | |
| 714 | seq_printf(m, "Display IER:\t%08x\n", |
| 715 | I915_READ(VLV_IER)); |
| 716 | seq_printf(m, "Display IIR:\t%08x\n", |
| 717 | I915_READ(VLV_IIR)); |
| 718 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 719 | I915_READ(VLV_IIR_RW)); |
| 720 | seq_printf(m, "Display IMR:\t%08x\n", |
| 721 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 722 | for_each_pipe(dev_priv, pipe) { |
| 723 | enum intel_display_power_domain power_domain; |
| 724 | |
| 725 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 726 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 727 | power_domain)) { |
| 728 | seq_printf(m, "Pipe %c power disabled\n", |
| 729 | pipe_name(pipe)); |
| 730 | continue; |
| 731 | } |
| 732 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 733 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 734 | pipe_name(pipe), |
| 735 | I915_READ(PIPESTAT(pipe))); |
| 736 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 737 | intel_display_power_put(dev_priv, power_domain); |
| 738 | } |
| 739 | |
| 740 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 741 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 742 | I915_READ(PORT_HOTPLUG_EN)); |
| 743 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 744 | I915_READ(VLV_DPFLIPSTAT)); |
| 745 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 746 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 747 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 748 | |
| 749 | for (i = 0; i < 4; i++) { |
| 750 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 751 | i, I915_READ(GEN8_GT_IMR(i))); |
| 752 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 753 | i, I915_READ(GEN8_GT_IIR(i))); |
| 754 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 755 | i, I915_READ(GEN8_GT_IER(i))); |
| 756 | } |
| 757 | |
| 758 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 759 | I915_READ(GEN8_PCU_IMR)); |
| 760 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 761 | I915_READ(GEN8_PCU_IIR)); |
| 762 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 763 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 764 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 765 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 766 | I915_READ(GEN8_MASTER_IRQ)); |
| 767 | |
| 768 | for (i = 0; i < 4; i++) { |
| 769 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 770 | i, I915_READ(GEN8_GT_IMR(i))); |
| 771 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 772 | i, I915_READ(GEN8_GT_IIR(i))); |
| 773 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 774 | i, I915_READ(GEN8_GT_IER(i))); |
| 775 | } |
| 776 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 777 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 778 | enum intel_display_power_domain power_domain; |
| 779 | |
| 780 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 781 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 782 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 783 | seq_printf(m, "Pipe %c power disabled\n", |
| 784 | pipe_name(pipe)); |
| 785 | continue; |
| 786 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 787 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 788 | pipe_name(pipe), |
| 789 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 790 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 791 | pipe_name(pipe), |
| 792 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 793 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 794 | pipe_name(pipe), |
| 795 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 796 | |
| 797 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 801 | I915_READ(GEN8_DE_PORT_IMR)); |
| 802 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 803 | I915_READ(GEN8_DE_PORT_IIR)); |
| 804 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 805 | I915_READ(GEN8_DE_PORT_IER)); |
| 806 | |
| 807 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 808 | I915_READ(GEN8_DE_MISC_IMR)); |
| 809 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 810 | I915_READ(GEN8_DE_MISC_IIR)); |
| 811 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 812 | I915_READ(GEN8_DE_MISC_IER)); |
| 813 | |
| 814 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 815 | I915_READ(GEN8_PCU_IMR)); |
| 816 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 817 | I915_READ(GEN8_PCU_IIR)); |
| 818 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 819 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 820 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 821 | seq_printf(m, "Display IER:\t%08x\n", |
| 822 | I915_READ(VLV_IER)); |
| 823 | seq_printf(m, "Display IIR:\t%08x\n", |
| 824 | I915_READ(VLV_IIR)); |
| 825 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 826 | I915_READ(VLV_IIR_RW)); |
| 827 | seq_printf(m, "Display IMR:\t%08x\n", |
| 828 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 829 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 830 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 831 | pipe_name(pipe), |
| 832 | I915_READ(PIPESTAT(pipe))); |
| 833 | |
| 834 | seq_printf(m, "Master IER:\t%08x\n", |
| 835 | I915_READ(VLV_MASTER_IER)); |
| 836 | |
| 837 | seq_printf(m, "Render IER:\t%08x\n", |
| 838 | I915_READ(GTIER)); |
| 839 | seq_printf(m, "Render IIR:\t%08x\n", |
| 840 | I915_READ(GTIIR)); |
| 841 | seq_printf(m, "Render IMR:\t%08x\n", |
| 842 | I915_READ(GTIMR)); |
| 843 | |
| 844 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 845 | I915_READ(GEN6_PMIER)); |
| 846 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 847 | I915_READ(GEN6_PMIIR)); |
| 848 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 849 | I915_READ(GEN6_PMIMR)); |
| 850 | |
| 851 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 852 | I915_READ(PORT_HOTPLUG_EN)); |
| 853 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 854 | I915_READ(VLV_DPFLIPSTAT)); |
| 855 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 856 | I915_READ(DPINVGTT)); |
| 857 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 858 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 859 | seq_printf(m, "Interrupt enable: %08x\n", |
| 860 | I915_READ(IER)); |
| 861 | seq_printf(m, "Interrupt identity: %08x\n", |
| 862 | I915_READ(IIR)); |
| 863 | seq_printf(m, "Interrupt mask: %08x\n", |
| 864 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 865 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 866 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 867 | pipe_name(pipe), |
| 868 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 869 | } else { |
| 870 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 871 | I915_READ(DEIER)); |
| 872 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 873 | I915_READ(DEIIR)); |
| 874 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 875 | I915_READ(DEIMR)); |
| 876 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 877 | I915_READ(SDEIER)); |
| 878 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 879 | I915_READ(SDEIIR)); |
| 880 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 881 | I915_READ(SDEIMR)); |
| 882 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 883 | I915_READ(GTIER)); |
| 884 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 885 | I915_READ(GTIIR)); |
| 886 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 887 | I915_READ(GTIMR)); |
| 888 | } |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 889 | for_each_engine(engine, dev_priv, id) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 890 | if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 891 | seq_printf(m, |
| 892 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 893 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 894 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 895 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 896 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 897 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 898 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 899 | return 0; |
| 900 | } |
| 901 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 902 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 903 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 904 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 905 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 906 | int i, ret; |
| 907 | |
| 908 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 909 | if (ret) |
| 910 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 911 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 912 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 913 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 914 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 915 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 916 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 917 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 918 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 919 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 920 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 921 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 922 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 923 | } |
| 924 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 925 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 926 | return 0; |
| 927 | } |
| 928 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 929 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
| 930 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 931 | static ssize_t |
| 932 | i915_error_state_write(struct file *filp, |
| 933 | const char __user *ubuf, |
| 934 | size_t cnt, |
| 935 | loff_t *ppos) |
| 936 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 937 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 938 | |
| 939 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Tvrtko Ursulin | 12ff05e | 2016-12-01 14:16:43 +0000 | [diff] [blame] | 940 | i915_destroy_error_state(error_priv->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 941 | |
| 942 | return cnt; |
| 943 | } |
| 944 | |
| 945 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 946 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 947 | struct drm_i915_private *dev_priv = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 948 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 949 | |
| 950 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 951 | if (!error_priv) |
| 952 | return -ENOMEM; |
| 953 | |
Tvrtko Ursulin | 12ff05e | 2016-12-01 14:16:43 +0000 | [diff] [blame] | 954 | error_priv->i915 = dev_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 955 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 956 | i915_error_state_get(&dev_priv->drm, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 957 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 958 | file->private_data = error_priv; |
| 959 | |
| 960 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 964 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 965 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 966 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 967 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 968 | kfree(error_priv); |
| 969 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 970 | return 0; |
| 971 | } |
| 972 | |
| 973 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 974 | size_t count, loff_t *pos) |
| 975 | { |
| 976 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 977 | struct drm_i915_error_state_buf error_str; |
| 978 | loff_t tmp_pos = 0; |
| 979 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 980 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 981 | |
Tvrtko Ursulin | 12ff05e | 2016-12-01 14:16:43 +0000 | [diff] [blame] | 982 | ret = i915_error_state_buf_init(&error_str, error_priv->i915, |
| 983 | count, *pos); |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 984 | if (ret) |
| 985 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 986 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 987 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 988 | if (ret) |
| 989 | goto out; |
| 990 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 991 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 992 | error_str.buf, |
| 993 | error_str.bytes); |
| 994 | |
| 995 | if (ret_count < 0) |
| 996 | ret = ret_count; |
| 997 | else |
| 998 | *pos = error_str.start + ret_count; |
| 999 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1000 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1001 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | static const struct file_operations i915_error_state_fops = { |
| 1005 | .owner = THIS_MODULE, |
| 1006 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1007 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1008 | .write = i915_error_state_write, |
| 1009 | .llseek = default_llseek, |
| 1010 | .release = i915_error_state_release, |
| 1011 | }; |
| 1012 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1013 | #endif |
| 1014 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1015 | static int |
| 1016 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1017 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1018 | struct drm_i915_private *dev_priv = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1019 | |
Joonas Lahtinen | 4c266ed | 2016-11-24 14:47:49 +0000 | [diff] [blame] | 1020 | *val = 1 + atomic_read(&dev_priv->gt.global_timeline.seqno); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1021 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1022 | } |
| 1023 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1024 | static int |
| 1025 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1026 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1027 | struct drm_i915_private *dev_priv = data; |
| 1028 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1029 | int ret; |
| 1030 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1031 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1032 | if (ret) |
| 1033 | return ret; |
| 1034 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1035 | ret = i915_gem_set_global_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1036 | mutex_unlock(&dev->struct_mutex); |
| 1037 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1038 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1039 | } |
| 1040 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1041 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1042 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1043 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1044 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1045 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1046 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1047 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1048 | struct drm_device *dev = &dev_priv->drm; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1049 | int ret = 0; |
| 1050 | |
| 1051 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1052 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1053 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1054 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1055 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1056 | |
| 1057 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1058 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1059 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1060 | MEMSTAT_VID_SHIFT); |
| 1061 | seq_printf(m, "Current P-state: %d\n", |
| 1062 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1063 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1064 | u32 freq_sts; |
| 1065 | |
| 1066 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1067 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1068 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1069 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1070 | |
| 1071 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1072 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1073 | |
| 1074 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1075 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1076 | |
| 1077 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1078 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1079 | |
| 1080 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1081 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1082 | |
| 1083 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1084 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1085 | |
| 1086 | seq_printf(m, |
| 1087 | "efficient (RPe) frequency: %d MHz\n", |
| 1088 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1089 | mutex_unlock(&dev_priv->rps.hw_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1090 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1091 | u32 rp_state_limits; |
| 1092 | u32 gt_perf_status; |
| 1093 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1094 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1095 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1096 | u32 rpupei, rpcurup, rpprevup; |
| 1097 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1098 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1099 | int max_freq; |
| 1100 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1101 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1102 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1103 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1104 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1105 | } else { |
| 1106 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1107 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1108 | } |
| 1109 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1110 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1111 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1112 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1113 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1114 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1115 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1116 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1117 | reqf = I915_READ(GEN6_RPNSWREQ); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1118 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1119 | reqf >>= 23; |
| 1120 | else { |
| 1121 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1122 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1123 | reqf >>= 24; |
| 1124 | else |
| 1125 | reqf >>= 25; |
| 1126 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1127 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1128 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1129 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1130 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1131 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1132 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1133 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1134 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1135 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1136 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1137 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1138 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1139 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1140 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1141 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1142 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1143 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1144 | else |
| 1145 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1146 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1147 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1148 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1149 | mutex_unlock(&dev->struct_mutex); |
| 1150 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1151 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1152 | pm_ier = I915_READ(GEN6_PMIER); |
| 1153 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1154 | pm_isr = I915_READ(GEN6_PMISR); |
| 1155 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1156 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1157 | } else { |
| 1158 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1159 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1160 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1161 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1162 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1163 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1164 | 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] | 1165 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 1166 | 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] | 1167 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1168 | seq_printf(m, "Render p-state ratio: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1169 | (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1170 | seq_printf(m, "Render p-state VID: %d\n", |
| 1171 | gt_perf_status & 0xff); |
| 1172 | seq_printf(m, "Render p-state limit: %d\n", |
| 1173 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1174 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1175 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1176 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1177 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1178 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1179 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1180 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1181 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1182 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1183 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1184 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1185 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1186 | seq_printf(m, "Up threshold: %d%%\n", |
| 1187 | dev_priv->rps.up_threshold); |
| 1188 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1189 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1190 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1191 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1192 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1193 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1194 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1195 | seq_printf(m, "Down threshold: %d%%\n", |
| 1196 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1197 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1198 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1199 | rp_state_cap >> 16) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1200 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1201 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1202 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1203 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1204 | |
| 1205 | max_freq = (rp_state_cap & 0xff00) >> 8; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1206 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1207 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1208 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1209 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1210 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1211 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1212 | rp_state_cap >> 0) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1213 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1214 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1215 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1216 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1217 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1218 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1219 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1220 | seq_printf(m, "Current freq: %d MHz\n", |
| 1221 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1222 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1223 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1224 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1225 | seq_printf(m, "Min freq: %d MHz\n", |
| 1226 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1227 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1228 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1229 | seq_printf(m, "Max freq: %d MHz\n", |
| 1230 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1231 | seq_printf(m, |
| 1232 | "efficient (RPe) frequency: %d MHz\n", |
| 1233 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1234 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1235 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1236 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1237 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1238 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1239 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1240 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1241 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1242 | out: |
| 1243 | intel_runtime_pm_put(dev_priv); |
| 1244 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1245 | } |
| 1246 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1247 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1248 | struct seq_file *m, |
| 1249 | struct intel_instdone *instdone) |
| 1250 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1251 | int slice; |
| 1252 | int subslice; |
| 1253 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1254 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1255 | instdone->instdone); |
| 1256 | |
| 1257 | if (INTEL_GEN(dev_priv) <= 3) |
| 1258 | return; |
| 1259 | |
| 1260 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1261 | instdone->slice_common); |
| 1262 | |
| 1263 | if (INTEL_GEN(dev_priv) <= 6) |
| 1264 | return; |
| 1265 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1266 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1267 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1268 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1269 | |
| 1270 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1271 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1272 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1273 | } |
| 1274 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1275 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1276 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1277 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1278 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1279 | u64 acthd[I915_NUM_ENGINES]; |
| 1280 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1281 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1282 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1283 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1284 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
| 1285 | seq_printf(m, "Wedged\n"); |
| 1286 | if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags)) |
| 1287 | seq_printf(m, "Reset in progress\n"); |
| 1288 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
| 1289 | seq_printf(m, "Waiter holding struct mutex\n"); |
| 1290 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
| 1291 | seq_printf(m, "struct_mutex blocked for reset\n"); |
| 1292 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1293 | if (!i915.enable_hangcheck) { |
| 1294 | seq_printf(m, "Hangcheck disabled\n"); |
| 1295 | return 0; |
| 1296 | } |
| 1297 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1298 | intel_runtime_pm_get(dev_priv); |
| 1299 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1300 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1301 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1302 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1303 | } |
| 1304 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1305 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1306 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1307 | intel_runtime_pm_put(dev_priv); |
| 1308 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1309 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1310 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1311 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1312 | jiffies)); |
| 1313 | } else |
| 1314 | seq_printf(m, "Hangcheck inactive\n"); |
| 1315 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1316 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1317 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1318 | struct rb_node *rb; |
| 1319 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1320 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 14fd0d6 | 2016-04-07 07:29:10 +0100 | [diff] [blame] | 1321 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1322 | engine->hangcheck.seqno, seqno[id], |
| 1323 | intel_engine_last_submit(engine)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1324 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1325 | yesno(intel_engine_has_waiter(engine)), |
| 1326 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1327 | &dev_priv->gpu_error.missed_irq_rings)), |
| 1328 | yesno(engine->hangcheck.stalled)); |
| 1329 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 1330 | spin_lock_irq(&b->lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1331 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 1332 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 1333 | |
| 1334 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1335 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1336 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 1337 | spin_unlock_irq(&b->lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1338 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1339 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1340 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1341 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1342 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1343 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1344 | engine->hangcheck.action, |
| 1345 | jiffies_to_msecs(jiffies - |
| 1346 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1347 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1348 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1349 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1350 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1351 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1352 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1353 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1354 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1355 | i915_instdone_info(dev_priv, m, |
| 1356 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1357 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | return 0; |
| 1361 | } |
| 1362 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1363 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1364 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1365 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1366 | u32 rgvmodectl, rstdbyctl; |
| 1367 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1368 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1369 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1370 | |
| 1371 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1372 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1373 | crstandvid = I915_READ16(CRSTANDVID); |
| 1374 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1375 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1376 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1377 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1378 | seq_printf(m, "Boost freq: %d\n", |
| 1379 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1380 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1381 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1382 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1383 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1384 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1385 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1386 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1387 | seq_printf(m, "Starting frequency: P%d\n", |
| 1388 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1389 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1390 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1391 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1392 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1393 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1394 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1395 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1396 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1397 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1398 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1399 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1400 | break; |
| 1401 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1402 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1403 | break; |
| 1404 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1405 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1406 | break; |
| 1407 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1408 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1409 | break; |
| 1410 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1411 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1412 | break; |
| 1413 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1414 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1415 | break; |
| 1416 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1417 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1418 | break; |
| 1419 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1420 | |
| 1421 | return 0; |
| 1422 | } |
| 1423 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1424 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1425 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1426 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1427 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1428 | |
| 1429 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1430 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1431 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1432 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1433 | fw_domain->wake_count); |
| 1434 | } |
| 1435 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1436 | |
| 1437 | return 0; |
| 1438 | } |
| 1439 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1440 | static int vlv_drpc_info(struct seq_file *m) |
| 1441 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1442 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1443 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1444 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1445 | intel_runtime_pm_get(dev_priv); |
| 1446 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1447 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1448 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1449 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1450 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1451 | intel_runtime_pm_put(dev_priv); |
| 1452 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1453 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1454 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1455 | seq_printf(m, "Turbo enabled: %s\n", |
| 1456 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1457 | seq_printf(m, "HW control enabled: %s\n", |
| 1458 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1459 | seq_printf(m, "SW control enabled: %s\n", |
| 1460 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1461 | GEN6_RP_MEDIA_SW_MODE)); |
| 1462 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1463 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1464 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1465 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1466 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1467 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1468 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1469 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1470 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1471 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1472 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1473 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1474 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1475 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1476 | } |
| 1477 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1478 | static int gen6_drpc_info(struct seq_file *m) |
| 1479 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1480 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1481 | struct drm_device *dev = &dev_priv->drm; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1482 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1483 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1484 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1485 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1486 | |
| 1487 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1488 | if (ret) |
| 1489 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1490 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1491 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1492 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1493 | 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] | 1494 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1495 | |
| 1496 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1497 | seq_puts(m, "RC information inaccurate because somebody " |
| 1498 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1499 | } else { |
| 1500 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1501 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1502 | udelay(10); |
| 1503 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1504 | } |
| 1505 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1506 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1507 | 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] | 1508 | |
| 1509 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1510 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1511 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1512 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1513 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1514 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1515 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1516 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1517 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1518 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1519 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1520 | intel_runtime_pm_put(dev_priv); |
| 1521 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1522 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1523 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1524 | seq_printf(m, "HW control enabled: %s\n", |
| 1525 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1526 | seq_printf(m, "SW control enabled: %s\n", |
| 1527 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1528 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1529 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1530 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1531 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1532 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1533 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1534 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1535 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1536 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1537 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1538 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1539 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1540 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1541 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1542 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1543 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1544 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1545 | case GEN6_RC0: |
| 1546 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1547 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1548 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1549 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1550 | break; |
| 1551 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1552 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1553 | break; |
| 1554 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1555 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1556 | break; |
| 1557 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1558 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1559 | break; |
| 1560 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1561 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1562 | break; |
| 1563 | } |
| 1564 | |
| 1565 | seq_printf(m, "Core Power Down: %s\n", |
| 1566 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1567 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1568 | seq_printf(m, "Render Power Well: %s\n", |
| 1569 | (gen9_powergate_status & |
| 1570 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1571 | seq_printf(m, "Media Power Well: %s\n", |
| 1572 | (gen9_powergate_status & |
| 1573 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1574 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1575 | |
| 1576 | /* Not exactly sure what this is */ |
| 1577 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1578 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1579 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1580 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1581 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1582 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1583 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1584 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1585 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1586 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1587 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1588 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1589 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1590 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1591 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1592 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1593 | } |
| 1594 | |
| 1595 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1596 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1597 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1598 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1599 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1600 | return vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1601 | else if (INTEL_GEN(dev_priv) >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1602 | return gen6_drpc_info(m); |
| 1603 | else |
| 1604 | return ironlake_drpc_info(m); |
| 1605 | } |
| 1606 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1607 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1608 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1609 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1610 | |
| 1611 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1612 | dev_priv->fb_tracking.busy_bits); |
| 1613 | |
| 1614 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1615 | dev_priv->fb_tracking.flip_bits); |
| 1616 | |
| 1617 | return 0; |
| 1618 | } |
| 1619 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1620 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1621 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1622 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1623 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1624 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1625 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1626 | return 0; |
| 1627 | } |
| 1628 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1629 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1630 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1631 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1632 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1633 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1634 | else |
| 1635 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1636 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1637 | |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1638 | if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) { |
| 1639 | uint32_t mask = INTEL_GEN(dev_priv) >= 8 ? |
| 1640 | BDW_FBC_COMPRESSION_MASK : |
| 1641 | IVB_FBC_COMPRESSION_MASK; |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1642 | seq_printf(m, "Compressing: %s\n", |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1643 | yesno(I915_READ(FBC_STATUS2) & mask)); |
| 1644 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1645 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1646 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1647 | intel_runtime_pm_put(dev_priv); |
| 1648 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1649 | return 0; |
| 1650 | } |
| 1651 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1652 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1653 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1654 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1655 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1656 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1657 | return -ENODEV; |
| 1658 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1659 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1660 | |
| 1661 | return 0; |
| 1662 | } |
| 1663 | |
| 1664 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1665 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1666 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1667 | u32 reg; |
| 1668 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1669 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1670 | return -ENODEV; |
| 1671 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1672 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1673 | |
| 1674 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1675 | dev_priv->fbc.false_color = val; |
| 1676 | |
| 1677 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1678 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1679 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1680 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1681 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1682 | return 0; |
| 1683 | } |
| 1684 | |
| 1685 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1686 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1687 | "%llu\n"); |
| 1688 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1689 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1690 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1691 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1692 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1693 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1694 | seq_puts(m, "not supported\n"); |
| 1695 | return 0; |
| 1696 | } |
| 1697 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1698 | intel_runtime_pm_get(dev_priv); |
| 1699 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1700 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1701 | yesno(i915.enable_ips)); |
| 1702 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1703 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1704 | seq_puts(m, "Currently: unknown\n"); |
| 1705 | } else { |
| 1706 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1707 | seq_puts(m, "Currently: enabled\n"); |
| 1708 | else |
| 1709 | seq_puts(m, "Currently: disabled\n"); |
| 1710 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1711 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1712 | intel_runtime_pm_put(dev_priv); |
| 1713 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1714 | return 0; |
| 1715 | } |
| 1716 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1717 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1718 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1719 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1720 | bool sr_enabled = false; |
| 1721 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1722 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1723 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1724 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1725 | if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1726 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1727 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1728 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1729 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1730 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1731 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1732 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1733 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1734 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1735 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1736 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1737 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1738 | intel_runtime_pm_put(dev_priv); |
| 1739 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1740 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1741 | |
| 1742 | return 0; |
| 1743 | } |
| 1744 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1745 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1746 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1747 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1748 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1749 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1750 | int ret; |
| 1751 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1752 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1753 | return -ENODEV; |
| 1754 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1755 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1756 | if (ret) |
| 1757 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1758 | |
| 1759 | temp = i915_mch_val(dev_priv); |
| 1760 | chipset = i915_chipset_val(dev_priv); |
| 1761 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1762 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1763 | |
| 1764 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1765 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1766 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1767 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1768 | |
| 1769 | return 0; |
| 1770 | } |
| 1771 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1772 | static int i915_ring_freq_table(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); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1775 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1776 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1777 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1778 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1779 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1780 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1781 | return 0; |
| 1782 | } |
| 1783 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1784 | intel_runtime_pm_get(dev_priv); |
| 1785 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1786 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1787 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1788 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1789 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1790 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1791 | /* Convert GT frequency to 50 HZ units */ |
| 1792 | min_gpu_freq = |
| 1793 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1794 | max_gpu_freq = |
| 1795 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1796 | } else { |
| 1797 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1798 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1799 | } |
| 1800 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1801 | 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] | 1802 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1803 | 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] | 1804 | ia_freq = gpu_freq; |
| 1805 | sandybridge_pcode_read(dev_priv, |
| 1806 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1807 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1808 | 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] | 1809 | intel_gpu_freq(dev_priv, (gpu_freq * |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1810 | (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1811 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1812 | ((ia_freq >> 0) & 0xff) * 100, |
| 1813 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1814 | } |
| 1815 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1816 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1817 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1818 | out: |
| 1819 | intel_runtime_pm_put(dev_priv); |
| 1820 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1821 | } |
| 1822 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1823 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1824 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1825 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1826 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1827 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1828 | int ret; |
| 1829 | |
| 1830 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1831 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1832 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1833 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1834 | if (opregion->header) |
| 1835 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1836 | |
| 1837 | mutex_unlock(&dev->struct_mutex); |
| 1838 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1839 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1840 | return 0; |
| 1841 | } |
| 1842 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1843 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1844 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1845 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1846 | |
| 1847 | if (opregion->vbt) |
| 1848 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1849 | |
| 1850 | return 0; |
| 1851 | } |
| 1852 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1853 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1854 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1855 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1856 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1857 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1858 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1859 | int ret; |
| 1860 | |
| 1861 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1862 | if (ret) |
| 1863 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1864 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1865 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1866 | if (dev_priv->fbdev) { |
| 1867 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1868 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1869 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1870 | fbdev_fb->base.width, |
| 1871 | fbdev_fb->base.height, |
| 1872 | fbdev_fb->base.depth, |
| 1873 | fbdev_fb->base.bits_per_pixel, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1874 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1875 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1876 | describe_obj(m, fbdev_fb->obj); |
| 1877 | seq_putc(m, '\n'); |
| 1878 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1879 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1880 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1881 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1882 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1883 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1884 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1885 | continue; |
| 1886 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1887 | 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] | 1888 | fb->base.width, |
| 1889 | fb->base.height, |
| 1890 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1891 | fb->base.bits_per_pixel, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1892 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1893 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1894 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1895 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1896 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1897 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1898 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1899 | |
| 1900 | return 0; |
| 1901 | } |
| 1902 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1903 | 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] | 1904 | { |
| 1905 | 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] | 1906 | ring->space, ring->head, ring->tail, |
| 1907 | ring->last_retired_head); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1908 | } |
| 1909 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1910 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1911 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1912 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1913 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1914 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1915 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1916 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1917 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1918 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1919 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1920 | if (ret) |
| 1921 | return ret; |
| 1922 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1923 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1924 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1925 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1926 | struct task_struct *task; |
| 1927 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1928 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1929 | if (task) { |
| 1930 | seq_printf(m, "(%s [%d]) ", |
| 1931 | task->comm, task->pid); |
| 1932 | put_task_struct(task); |
| 1933 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1934 | } else if (IS_ERR(ctx->file_priv)) { |
| 1935 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1936 | } else { |
| 1937 | seq_puts(m, "(kernel) "); |
| 1938 | } |
| 1939 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1940 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1941 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1942 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1943 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1944 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 1945 | |
| 1946 | seq_printf(m, "%s: ", engine->name); |
| 1947 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 1948 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1949 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1950 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1951 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1952 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1953 | } |
| 1954 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1955 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1956 | } |
| 1957 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1958 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1959 | |
| 1960 | return 0; |
| 1961 | } |
| 1962 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1963 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1964 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1965 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1966 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1967 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1968 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1969 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1970 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 1971 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 1972 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1973 | if (!vma) { |
| 1974 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1975 | return; |
| 1976 | } |
| 1977 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1978 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 1979 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 1980 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1981 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 1982 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1983 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1984 | return; |
| 1985 | } |
| 1986 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1987 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 1988 | if (page) { |
| 1989 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1990 | |
| 1991 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1992 | seq_printf(m, |
| 1993 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1994 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1995 | reg_state[j], reg_state[j + 1], |
| 1996 | reg_state[j + 2], reg_state[j + 3]); |
| 1997 | } |
| 1998 | kunmap_atomic(reg_state); |
| 1999 | } |
| 2000 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2001 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2002 | seq_putc(m, '\n'); |
| 2003 | } |
| 2004 | |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2005 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2006 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2007 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2008 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2009 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2010 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2011 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2012 | int ret; |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2013 | |
| 2014 | if (!i915.enable_execlists) { |
| 2015 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2016 | return 0; |
| 2017 | } |
| 2018 | |
| 2019 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2020 | if (ret) |
| 2021 | return ret; |
| 2022 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2023 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2024 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2025 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2026 | |
| 2027 | mutex_unlock(&dev->struct_mutex); |
| 2028 | |
| 2029 | return 0; |
| 2030 | } |
| 2031 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2032 | static const char *swizzle_string(unsigned swizzle) |
| 2033 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2034 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2035 | case I915_BIT_6_SWIZZLE_NONE: |
| 2036 | return "none"; |
| 2037 | case I915_BIT_6_SWIZZLE_9: |
| 2038 | return "bit9"; |
| 2039 | case I915_BIT_6_SWIZZLE_9_10: |
| 2040 | return "bit9/bit10"; |
| 2041 | case I915_BIT_6_SWIZZLE_9_11: |
| 2042 | return "bit9/bit11"; |
| 2043 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2044 | return "bit9/bit10/bit11"; |
| 2045 | case I915_BIT_6_SWIZZLE_9_17: |
| 2046 | return "bit9/bit17"; |
| 2047 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2048 | return "bit9/bit10/bit17"; |
| 2049 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2050 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2051 | } |
| 2052 | |
| 2053 | return "bug"; |
| 2054 | } |
| 2055 | |
| 2056 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2057 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2058 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2059 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2060 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2061 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2062 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2063 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2064 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2065 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2066 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2067 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2068 | seq_printf(m, "DDC = 0x%08x\n", |
| 2069 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2070 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2071 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2072 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2073 | I915_READ16(C0DRB3)); |
| 2074 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2075 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2076 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2077 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2078 | I915_READ(MAD_DIMM_C0)); |
| 2079 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2080 | I915_READ(MAD_DIMM_C1)); |
| 2081 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2082 | I915_READ(MAD_DIMM_C2)); |
| 2083 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2084 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2085 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2086 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2087 | I915_READ(GAMTARBMODE)); |
| 2088 | else |
| 2089 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2090 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2091 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2092 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2093 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2094 | |
| 2095 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2096 | seq_puts(m, "L-shaped memory detected\n"); |
| 2097 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2098 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2099 | |
| 2100 | return 0; |
| 2101 | } |
| 2102 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2103 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2104 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2105 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2106 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2107 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2108 | |
| 2109 | if (!ppgtt) { |
| 2110 | seq_printf(m, " no ppgtt for context %d\n", |
| 2111 | ctx->user_handle); |
| 2112 | return 0; |
| 2113 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2114 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2115 | if (i915_gem_context_is_default(ctx)) |
| 2116 | seq_puts(m, " default context:\n"); |
| 2117 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2118 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2119 | ppgtt->debug_dump(ppgtt, m); |
| 2120 | |
| 2121 | return 0; |
| 2122 | } |
| 2123 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2124 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2125 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2126 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2127 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2128 | struct intel_engine_cs *engine; |
| 2129 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2130 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2131 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2132 | if (!ppgtt) |
| 2133 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2134 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2135 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2136 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2137 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2138 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2139 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2140 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2141 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2142 | } |
| 2143 | } |
| 2144 | } |
| 2145 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2146 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2147 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2148 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2149 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2150 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2151 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2152 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2153 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2154 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2155 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2156 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2157 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2158 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2159 | I915_READ(RING_MODE_GEN7(engine))); |
| 2160 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2161 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2162 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2163 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2164 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2165 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2166 | } |
| 2167 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2168 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2169 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2170 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2171 | 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] | 2172 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2173 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2174 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2175 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2176 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2177 | } |
| 2178 | |
| 2179 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2180 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2181 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2182 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2183 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2184 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2185 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2186 | mutex_lock(&dev->filelist_mutex); |
| 2187 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2188 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2189 | goto out_unlock; |
| 2190 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2191 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2192 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2193 | if (INTEL_GEN(dev_priv) >= 8) |
| 2194 | gen8_ppgtt_info(m, dev_priv); |
| 2195 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2196 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2197 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2198 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2199 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2200 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2201 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2202 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2203 | if (!task) { |
| 2204 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2205 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2206 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2207 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2208 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2209 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2210 | (void *)(unsigned long)m); |
| 2211 | } |
| 2212 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2213 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2214 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2215 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2216 | out_unlock: |
| 2217 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2218 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2219 | } |
| 2220 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2221 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2222 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2223 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2224 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2225 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2226 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2227 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2228 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2229 | |
| 2230 | return count; |
| 2231 | } |
| 2232 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2233 | static const char *rps_power_to_str(unsigned int power) |
| 2234 | { |
| 2235 | static const char * const strings[] = { |
| 2236 | [LOW_POWER] = "low power", |
| 2237 | [BETWEEN] = "mixed", |
| 2238 | [HIGH_POWER] = "high power", |
| 2239 | }; |
| 2240 | |
| 2241 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2242 | return "unknown"; |
| 2243 | |
| 2244 | return strings[power]; |
| 2245 | } |
| 2246 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2247 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2248 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2249 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2250 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2251 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2252 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2253 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2254 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2255 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2256 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2257 | seq_printf(m, "Frequency requested %d\n", |
| 2258 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 2259 | 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] | 2260 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2261 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2262 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2263 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2264 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
| 2265 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq), |
| 2266 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
| 2267 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2268 | |
| 2269 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2270 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2271 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2272 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2273 | struct task_struct *task; |
| 2274 | |
| 2275 | rcu_read_lock(); |
| 2276 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2277 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2278 | task ? task->comm : "<unknown>", |
| 2279 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2280 | file_priv->rps.boosts, |
| 2281 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2282 | rcu_read_unlock(); |
| 2283 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2284 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2285 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2286 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2287 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2288 | if (INTEL_GEN(dev_priv) >= 6 && |
| 2289 | dev_priv->rps.enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2290 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2291 | u32 rpup, rpupei; |
| 2292 | u32 rpdown, rpdownei; |
| 2293 | |
| 2294 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2295 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2296 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2297 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2298 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2299 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2300 | |
| 2301 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
| 2302 | rps_power_to_str(dev_priv->rps.power)); |
| 2303 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
| 2304 | 100 * rpup / rpupei, |
| 2305 | dev_priv->rps.up_threshold); |
| 2306 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
| 2307 | 100 * rpdown / rpdownei, |
| 2308 | dev_priv->rps.down_threshold); |
| 2309 | } else { |
| 2310 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2311 | } |
| 2312 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2313 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2314 | } |
| 2315 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2316 | static int i915_llc(struct seq_file *m, void *data) |
| 2317 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2318 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2319 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2320 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2321 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2322 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2323 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2324 | |
| 2325 | return 0; |
| 2326 | } |
| 2327 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2328 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2329 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2330 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2331 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
| 2332 | u32 tmp, i; |
| 2333 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2334 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2335 | return 0; |
| 2336 | |
| 2337 | seq_printf(m, "GuC firmware status:\n"); |
| 2338 | seq_printf(m, "\tpath: %s\n", |
| 2339 | guc_fw->guc_fw_path); |
| 2340 | seq_printf(m, "\tfetch: %s\n", |
| 2341 | intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status)); |
| 2342 | seq_printf(m, "\tload: %s\n", |
| 2343 | intel_guc_fw_status_repr(guc_fw->guc_fw_load_status)); |
| 2344 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2345 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
| 2346 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2347 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2348 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2349 | guc_fw->header_offset, guc_fw->header_size); |
| 2350 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2351 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2352 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2353 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2354 | |
| 2355 | tmp = I915_READ(GUC_STATUS); |
| 2356 | |
| 2357 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2358 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2359 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2360 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2361 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2362 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2363 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2364 | seq_puts(m, "\nScratch registers:\n"); |
| 2365 | for (i = 0; i < 16; i++) |
| 2366 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2367 | |
| 2368 | return 0; |
| 2369 | } |
| 2370 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2371 | static void i915_guc_log_info(struct seq_file *m, |
| 2372 | struct drm_i915_private *dev_priv) |
| 2373 | { |
| 2374 | struct intel_guc *guc = &dev_priv->guc; |
| 2375 | |
| 2376 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2377 | |
| 2378 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2379 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2380 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2381 | |
| 2382 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2383 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2384 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2385 | |
| 2386 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2387 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2388 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2389 | |
| 2390 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2391 | guc->log.flush_interrupt_count); |
| 2392 | |
| 2393 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2394 | guc->log.capture_miss_count); |
| 2395 | } |
| 2396 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2397 | static void i915_guc_client_info(struct seq_file *m, |
| 2398 | struct drm_i915_private *dev_priv, |
| 2399 | struct i915_guc_client *client) |
| 2400 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2401 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2402 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2403 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2404 | |
| 2405 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2406 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2407 | 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] | 2408 | client->doorbell_id, client->doorbell_offset, client->doorbell_cookie); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2409 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2410 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2411 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2412 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2413 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2414 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2415 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2416 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2417 | u64 submissions = client->submissions[id]; |
| 2418 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2419 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2420 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2421 | } |
| 2422 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2423 | } |
| 2424 | |
| 2425 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2426 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2427 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2428 | const struct intel_guc *guc = &dev_priv->guc; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2429 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2430 | enum intel_engine_id id; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2431 | u64 total; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2432 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2433 | if (!guc->execbuf_client) { |
| 2434 | seq_printf(m, "GuC submission %s\n", |
| 2435 | HAS_GUC_SCHED(dev_priv) ? |
| 2436 | "disabled" : |
| 2437 | "not supported"); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2438 | return 0; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2439 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2440 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2441 | seq_printf(m, "Doorbell map:\n"); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2442 | seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap); |
| 2443 | 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] | 2444 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2445 | seq_printf(m, "GuC total action count: %llu\n", guc->action_count); |
| 2446 | seq_printf(m, "GuC action failure count: %u\n", guc->action_fail); |
| 2447 | seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd); |
| 2448 | seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status); |
| 2449 | 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] | 2450 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2451 | total = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2452 | seq_printf(m, "\nGuC submissions:\n"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2453 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2454 | u64 submissions = guc->submissions[id]; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2455 | total += submissions; |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2456 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2457 | engine->name, submissions, guc->last_seqno[id]); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2458 | } |
| 2459 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2460 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2461 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2462 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2463 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2464 | i915_guc_log_info(m, dev_priv); |
| 2465 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2466 | /* Add more as required ... */ |
| 2467 | |
| 2468 | return 0; |
| 2469 | } |
| 2470 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2471 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2472 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2473 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2474 | struct drm_i915_gem_object *obj; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2475 | int i = 0, pg; |
| 2476 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2477 | if (!dev_priv->guc.log.vma) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2478 | return 0; |
| 2479 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2480 | obj = dev_priv->guc.log.vma->obj; |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2481 | for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) { |
| 2482 | u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg)); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2483 | |
| 2484 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2485 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2486 | *(log + i), *(log + i + 1), |
| 2487 | *(log + i + 2), *(log + i + 3)); |
| 2488 | |
| 2489 | kunmap_atomic(log); |
| 2490 | } |
| 2491 | |
| 2492 | seq_putc(m, '\n'); |
| 2493 | |
| 2494 | return 0; |
| 2495 | } |
| 2496 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2497 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2498 | { |
| 2499 | struct drm_device *dev = data; |
| 2500 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2501 | |
| 2502 | if (!dev_priv->guc.log.vma) |
| 2503 | return -EINVAL; |
| 2504 | |
| 2505 | *val = i915.guc_log_level; |
| 2506 | |
| 2507 | return 0; |
| 2508 | } |
| 2509 | |
| 2510 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2511 | { |
| 2512 | struct drm_device *dev = data; |
| 2513 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2514 | int ret; |
| 2515 | |
| 2516 | if (!dev_priv->guc.log.vma) |
| 2517 | return -EINVAL; |
| 2518 | |
| 2519 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2520 | if (ret) |
| 2521 | return ret; |
| 2522 | |
| 2523 | intel_runtime_pm_get(dev_priv); |
| 2524 | ret = i915_guc_log_control(dev_priv, val); |
| 2525 | intel_runtime_pm_put(dev_priv); |
| 2526 | |
| 2527 | mutex_unlock(&dev->struct_mutex); |
| 2528 | return ret; |
| 2529 | } |
| 2530 | |
| 2531 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2532 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2533 | "%lld\n"); |
| 2534 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2535 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2536 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2537 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2538 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2539 | u32 stat[3]; |
| 2540 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2541 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2542 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2543 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2544 | seq_puts(m, "PSR not supported\n"); |
| 2545 | return 0; |
| 2546 | } |
| 2547 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2548 | intel_runtime_pm_get(dev_priv); |
| 2549 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2550 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2551 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2552 | 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] | 2553 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2554 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2555 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2556 | dev_priv->psr.busy_frontbuffer_bits); |
| 2557 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2558 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2559 | |
Nagaraju, Vathsala | 7e3eb59 | 2016-12-09 23:42:09 +0530 | [diff] [blame] | 2560 | if (HAS_DDI(dev_priv)) { |
| 2561 | if (dev_priv->psr.psr2_support) |
| 2562 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2563 | else |
| 2564 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
| 2565 | } else { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2566 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2567 | enum transcoder cpu_transcoder = |
| 2568 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2569 | enum intel_display_power_domain power_domain; |
| 2570 | |
| 2571 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2572 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2573 | power_domain)) |
| 2574 | continue; |
| 2575 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2576 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2577 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2578 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2579 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2580 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2581 | |
| 2582 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2583 | } |
| 2584 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2585 | |
| 2586 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2587 | yesno(dev_priv->psr.link_standby)); |
| 2588 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2589 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2590 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2591 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2592 | for_each_pipe(dev_priv, pipe) { |
| 2593 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2594 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2595 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2596 | } |
| 2597 | seq_puts(m, "\n"); |
| 2598 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2599 | /* |
| 2600 | * VLV/CHV PSR has no kind of performance counter |
| 2601 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2602 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2603 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2604 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2605 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2606 | |
| 2607 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2608 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2609 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2610 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2611 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2612 | return 0; |
| 2613 | } |
| 2614 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2615 | static int i915_sink_crc(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); |
| 2618 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2619 | struct intel_connector *connector; |
| 2620 | struct intel_dp *intel_dp = NULL; |
| 2621 | int ret; |
| 2622 | u8 crc[6]; |
| 2623 | |
| 2624 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2625 | for_each_intel_connector(dev, connector) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2626 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2627 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2628 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2629 | continue; |
| 2630 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2631 | crtc = connector->base.state->crtc; |
| 2632 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2633 | continue; |
| 2634 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2635 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2636 | continue; |
| 2637 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2638 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2639 | |
| 2640 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2641 | if (ret) |
| 2642 | goto out; |
| 2643 | |
| 2644 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2645 | crc[0], crc[1], crc[2], |
| 2646 | crc[3], crc[4], crc[5]); |
| 2647 | goto out; |
| 2648 | } |
| 2649 | ret = -ENODEV; |
| 2650 | out: |
| 2651 | drm_modeset_unlock_all(dev); |
| 2652 | return ret; |
| 2653 | } |
| 2654 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2655 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2656 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2657 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2658 | u64 power; |
| 2659 | u32 units; |
| 2660 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2661 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2662 | return -ENODEV; |
| 2663 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2664 | intel_runtime_pm_get(dev_priv); |
| 2665 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2666 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2667 | power = (power & 0x1f00) >> 8; |
| 2668 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2669 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2670 | power *= units; |
| 2671 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2672 | intel_runtime_pm_put(dev_priv); |
| 2673 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2674 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2675 | |
| 2676 | return 0; |
| 2677 | } |
| 2678 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2679 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2680 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2681 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2682 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2683 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2684 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2685 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2686 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2687 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2688 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2689 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2690 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2691 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2692 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2693 | #else |
| 2694 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2695 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2696 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2697 | pci_power_name(pdev->current_state), |
| 2698 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2699 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2700 | return 0; |
| 2701 | } |
| 2702 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2703 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2704 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2705 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2706 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2707 | int i; |
| 2708 | |
| 2709 | mutex_lock(&power_domains->lock); |
| 2710 | |
| 2711 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2712 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2713 | struct i915_power_well *power_well; |
| 2714 | enum intel_display_power_domain power_domain; |
| 2715 | |
| 2716 | power_well = &power_domains->power_wells[i]; |
| 2717 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2718 | power_well->count); |
| 2719 | |
| 2720 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2721 | power_domain++) { |
| 2722 | if (!(BIT(power_domain) & power_well->domains)) |
| 2723 | continue; |
| 2724 | |
| 2725 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2726 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2727 | power_domains->domain_use_count[power_domain]); |
| 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | mutex_unlock(&power_domains->lock); |
| 2732 | |
| 2733 | return 0; |
| 2734 | } |
| 2735 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2736 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2737 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2738 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2739 | struct intel_csr *csr; |
| 2740 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2741 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2742 | seq_puts(m, "not supported\n"); |
| 2743 | return 0; |
| 2744 | } |
| 2745 | |
| 2746 | csr = &dev_priv->csr; |
| 2747 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2748 | intel_runtime_pm_get(dev_priv); |
| 2749 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2750 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2751 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2752 | |
| 2753 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2754 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2755 | |
| 2756 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2757 | CSR_VERSION_MINOR(csr->version)); |
| 2758 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2759 | if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2760 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2761 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2762 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2763 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2764 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2765 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2766 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2767 | } |
| 2768 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2769 | out: |
| 2770 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2771 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2772 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2773 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2774 | intel_runtime_pm_put(dev_priv); |
| 2775 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2776 | return 0; |
| 2777 | } |
| 2778 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2779 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2780 | struct drm_display_mode *mode) |
| 2781 | { |
| 2782 | int i; |
| 2783 | |
| 2784 | for (i = 0; i < tabs; i++) |
| 2785 | seq_putc(m, '\t'); |
| 2786 | |
| 2787 | 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", |
| 2788 | mode->base.id, mode->name, |
| 2789 | mode->vrefresh, mode->clock, |
| 2790 | mode->hdisplay, mode->hsync_start, |
| 2791 | mode->hsync_end, mode->htotal, |
| 2792 | mode->vdisplay, mode->vsync_start, |
| 2793 | mode->vsync_end, mode->vtotal, |
| 2794 | mode->type, mode->flags); |
| 2795 | } |
| 2796 | |
| 2797 | static void intel_encoder_info(struct seq_file *m, |
| 2798 | struct intel_crtc *intel_crtc, |
| 2799 | struct intel_encoder *intel_encoder) |
| 2800 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2801 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2802 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2803 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2804 | struct intel_connector *intel_connector; |
| 2805 | struct drm_encoder *encoder; |
| 2806 | |
| 2807 | encoder = &intel_encoder->base; |
| 2808 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2809 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2810 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2811 | struct drm_connector *connector = &intel_connector->base; |
| 2812 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2813 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2814 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2815 | drm_get_connector_status_name(connector->status)); |
| 2816 | if (connector->status == connector_status_connected) { |
| 2817 | struct drm_display_mode *mode = &crtc->mode; |
| 2818 | seq_printf(m, ", mode:\n"); |
| 2819 | intel_seq_print_mode(m, 2, mode); |
| 2820 | } else { |
| 2821 | seq_putc(m, '\n'); |
| 2822 | } |
| 2823 | } |
| 2824 | } |
| 2825 | |
| 2826 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2827 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2828 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2829 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2830 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2831 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2832 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2833 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2834 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2835 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2836 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2837 | fb->base.id, plane_state->src_x >> 16, |
| 2838 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2839 | else |
| 2840 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2841 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2842 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2843 | } |
| 2844 | |
| 2845 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2846 | { |
| 2847 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2848 | |
| 2849 | seq_printf(m, "\tfixed mode:\n"); |
| 2850 | intel_seq_print_mode(m, 2, mode); |
| 2851 | } |
| 2852 | |
| 2853 | static void intel_dp_info(struct seq_file *m, |
| 2854 | struct intel_connector *intel_connector) |
| 2855 | { |
| 2856 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2857 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2858 | |
| 2859 | 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] | 2860 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2861 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2862 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2863 | |
| 2864 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2865 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2866 | } |
| 2867 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2868 | static void intel_dp_mst_info(struct seq_file *m, |
| 2869 | struct intel_connector *intel_connector) |
| 2870 | { |
| 2871 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2872 | struct intel_dp_mst_encoder *intel_mst = |
| 2873 | enc_to_mst(&intel_encoder->base); |
| 2874 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2875 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2876 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2877 | intel_connector->port); |
| 2878 | |
| 2879 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2880 | } |
| 2881 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2882 | static void intel_hdmi_info(struct seq_file *m, |
| 2883 | struct intel_connector *intel_connector) |
| 2884 | { |
| 2885 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2886 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2887 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2888 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2889 | } |
| 2890 | |
| 2891 | static void intel_lvds_info(struct seq_file *m, |
| 2892 | struct intel_connector *intel_connector) |
| 2893 | { |
| 2894 | intel_panel_info(m, &intel_connector->panel); |
| 2895 | } |
| 2896 | |
| 2897 | static void intel_connector_info(struct seq_file *m, |
| 2898 | struct drm_connector *connector) |
| 2899 | { |
| 2900 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2901 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2902 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2903 | |
| 2904 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2905 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2906 | drm_get_connector_status_name(connector->status)); |
| 2907 | if (connector->status == connector_status_connected) { |
| 2908 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2909 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2910 | connector->display_info.width_mm, |
| 2911 | connector->display_info.height_mm); |
| 2912 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2913 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2914 | seq_printf(m, "\tCEA rev: %d\n", |
| 2915 | connector->display_info.cea_rev); |
| 2916 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2917 | |
| 2918 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2919 | return; |
| 2920 | |
| 2921 | switch (connector->connector_type) { |
| 2922 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2923 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2924 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2925 | intel_dp_mst_info(m, intel_connector); |
| 2926 | else |
| 2927 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2928 | break; |
| 2929 | case DRM_MODE_CONNECTOR_LVDS: |
| 2930 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2931 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2932 | break; |
| 2933 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2934 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 2935 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 2936 | intel_hdmi_info(m, intel_connector); |
| 2937 | break; |
| 2938 | default: |
| 2939 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2940 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2941 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2942 | seq_printf(m, "\tmodes:\n"); |
| 2943 | list_for_each_entry(mode, &connector->modes, head) |
| 2944 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2945 | } |
| 2946 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2947 | static bool cursor_active(struct drm_i915_private *dev_priv, int pipe) |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2948 | { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2949 | u32 state; |
| 2950 | |
Jani Nikula | 2a307c2 | 2016-11-30 17:43:04 +0200 | [diff] [blame] | 2951 | if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 2952 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2953 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2954 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2955 | |
| 2956 | return state; |
| 2957 | } |
| 2958 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2959 | static bool cursor_position(struct drm_i915_private *dev_priv, |
| 2960 | int pipe, int *x, int *y) |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2961 | { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2962 | u32 pos; |
| 2963 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2964 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2965 | |
| 2966 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2967 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2968 | *x = -*x; |
| 2969 | |
| 2970 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2971 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2972 | *y = -*y; |
| 2973 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2974 | return cursor_active(dev_priv, pipe); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2975 | } |
| 2976 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2977 | static const char *plane_type(enum drm_plane_type type) |
| 2978 | { |
| 2979 | switch (type) { |
| 2980 | case DRM_PLANE_TYPE_OVERLAY: |
| 2981 | return "OVL"; |
| 2982 | case DRM_PLANE_TYPE_PRIMARY: |
| 2983 | return "PRI"; |
| 2984 | case DRM_PLANE_TYPE_CURSOR: |
| 2985 | return "CUR"; |
| 2986 | /* |
| 2987 | * Deliberately omitting default: to generate compiler warnings |
| 2988 | * when a new drm_plane_type gets added. |
| 2989 | */ |
| 2990 | } |
| 2991 | |
| 2992 | return "unknown"; |
| 2993 | } |
| 2994 | |
| 2995 | static const char *plane_rotation(unsigned int rotation) |
| 2996 | { |
| 2997 | static char buf[48]; |
| 2998 | /* |
| 2999 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3000 | * will print them all to visualize if the values are misused |
| 3001 | */ |
| 3002 | snprintf(buf, sizeof(buf), |
| 3003 | "%s%s%s%s%s%s(0x%08x)", |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 3004 | (rotation & DRM_ROTATE_0) ? "0 " : "", |
| 3005 | (rotation & DRM_ROTATE_90) ? "90 " : "", |
| 3006 | (rotation & DRM_ROTATE_180) ? "180 " : "", |
| 3007 | (rotation & DRM_ROTATE_270) ? "270 " : "", |
| 3008 | (rotation & DRM_REFLECT_X) ? "FLIPX " : "", |
| 3009 | (rotation & DRM_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3010 | rotation); |
| 3011 | |
| 3012 | return buf; |
| 3013 | } |
| 3014 | |
| 3015 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3016 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3017 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3018 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3019 | struct intel_plane *intel_plane; |
| 3020 | |
| 3021 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3022 | struct drm_plane_state *state; |
| 3023 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3024 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3025 | |
| 3026 | if (!plane->state) { |
| 3027 | seq_puts(m, "plane->state is NULL!\n"); |
| 3028 | continue; |
| 3029 | } |
| 3030 | |
| 3031 | state = plane->state; |
| 3032 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3033 | if (state->fb) { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3034 | drm_get_format_name(state->fb->pixel_format, &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3035 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3036 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3037 | } |
| 3038 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3039 | 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", |
| 3040 | plane->base.id, |
| 3041 | plane_type(intel_plane->base.type), |
| 3042 | state->crtc_x, state->crtc_y, |
| 3043 | state->crtc_w, state->crtc_h, |
| 3044 | (state->src_x >> 16), |
| 3045 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3046 | (state->src_y >> 16), |
| 3047 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3048 | (state->src_w >> 16), |
| 3049 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3050 | (state->src_h >> 16), |
| 3051 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3052 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3053 | plane_rotation(state->rotation)); |
| 3054 | } |
| 3055 | } |
| 3056 | |
| 3057 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3058 | { |
| 3059 | struct intel_crtc_state *pipe_config; |
| 3060 | int num_scalers = intel_crtc->num_scalers; |
| 3061 | int i; |
| 3062 | |
| 3063 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3064 | |
| 3065 | /* Not all platformas have a scaler */ |
| 3066 | if (num_scalers) { |
| 3067 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3068 | num_scalers, |
| 3069 | pipe_config->scaler_state.scaler_users, |
| 3070 | pipe_config->scaler_state.scaler_id); |
| 3071 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3072 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3073 | struct intel_scaler *sc = |
| 3074 | &pipe_config->scaler_state.scalers[i]; |
| 3075 | |
| 3076 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3077 | i, yesno(sc->in_use), sc->mode); |
| 3078 | } |
| 3079 | seq_puts(m, "\n"); |
| 3080 | } else { |
| 3081 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3082 | } |
| 3083 | } |
| 3084 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3085 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3086 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3087 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3088 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3089 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3090 | struct drm_connector *connector; |
| 3091 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3092 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3093 | drm_modeset_lock_all(dev); |
| 3094 | seq_printf(m, "CRTC info\n"); |
| 3095 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3096 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3097 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3098 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3099 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3100 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3101 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3102 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3103 | 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] | 3104 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3105 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3106 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3107 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3108 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3109 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3110 | intel_crtc_info(m, crtc); |
| 3111 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3112 | active = cursor_position(dev_priv, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3113 | 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] | 3114 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3115 | x, y, crtc->base.cursor->state->crtc_w, |
| 3116 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3117 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3118 | intel_scaler_info(m, crtc); |
| 3119 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3120 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3121 | |
| 3122 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3123 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3124 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3125 | } |
| 3126 | |
| 3127 | seq_printf(m, "\n"); |
| 3128 | seq_printf(m, "Connector info\n"); |
| 3129 | seq_printf(m, "--------------\n"); |
| 3130 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3131 | intel_connector_info(m, connector); |
| 3132 | } |
| 3133 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3134 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3135 | |
| 3136 | return 0; |
| 3137 | } |
| 3138 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3139 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3140 | { |
| 3141 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3142 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3143 | enum intel_engine_id id; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3144 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3145 | intel_runtime_pm_get(dev_priv); |
| 3146 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3147 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3148 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 3149 | struct drm_i915_gem_request *rq; |
| 3150 | struct rb_node *rb; |
| 3151 | u64 addr; |
| 3152 | |
| 3153 | seq_printf(m, "%s\n", engine->name); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 3154 | 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] | 3155 | intel_engine_get_seqno(engine), |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 3156 | intel_engine_last_submit(engine), |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3157 | engine->hangcheck.seqno, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 3158 | jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp)); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3159 | |
| 3160 | rcu_read_lock(); |
| 3161 | |
| 3162 | seq_printf(m, "\tRequests:\n"); |
| 3163 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3164 | rq = list_first_entry(&engine->timeline->requests, |
| 3165 | struct drm_i915_gem_request, link); |
| 3166 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3167 | print_request(m, rq, "\t\tfirst "); |
| 3168 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3169 | rq = list_last_entry(&engine->timeline->requests, |
| 3170 | struct drm_i915_gem_request, link); |
| 3171 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3172 | print_request(m, rq, "\t\tlast "); |
| 3173 | |
| 3174 | rq = i915_gem_find_active_request(engine); |
| 3175 | if (rq) { |
| 3176 | print_request(m, rq, "\t\tactive "); |
| 3177 | seq_printf(m, |
| 3178 | "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n", |
| 3179 | rq->head, rq->postfix, rq->tail, |
| 3180 | rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, |
| 3181 | rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); |
| 3182 | } |
| 3183 | |
| 3184 | seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n", |
| 3185 | I915_READ(RING_START(engine->mmio_base)), |
| 3186 | rq ? i915_ggtt_offset(rq->ring->vma) : 0); |
| 3187 | seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n", |
| 3188 | I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR, |
| 3189 | rq ? rq->ring->head : 0); |
| 3190 | seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n", |
| 3191 | I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR, |
| 3192 | rq ? rq->ring->tail : 0); |
| 3193 | seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n", |
| 3194 | I915_READ(RING_CTL(engine->mmio_base)), |
| 3195 | I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : ""); |
| 3196 | |
| 3197 | rcu_read_unlock(); |
| 3198 | |
| 3199 | addr = intel_engine_get_active_head(engine); |
| 3200 | seq_printf(m, "\tACTHD: 0x%08x_%08x\n", |
| 3201 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3202 | addr = intel_engine_get_last_batch_head(engine); |
| 3203 | seq_printf(m, "\tBBADDR: 0x%08x_%08x\n", |
| 3204 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3205 | |
| 3206 | if (i915.enable_execlists) { |
| 3207 | u32 ptr, read, write; |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3208 | struct rb_node *rb; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3209 | |
| 3210 | seq_printf(m, "\tExeclist status: 0x%08x %08x\n", |
| 3211 | I915_READ(RING_EXECLIST_STATUS_LO(engine)), |
| 3212 | I915_READ(RING_EXECLIST_STATUS_HI(engine))); |
| 3213 | |
| 3214 | ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
| 3215 | read = GEN8_CSB_READ_PTR(ptr); |
| 3216 | write = GEN8_CSB_WRITE_PTR(ptr); |
| 3217 | seq_printf(m, "\tExeclist CSB read %d, write %d\n", |
| 3218 | read, write); |
| 3219 | if (read >= GEN8_CSB_ENTRIES) |
| 3220 | read = 0; |
| 3221 | if (write >= GEN8_CSB_ENTRIES) |
| 3222 | write = 0; |
| 3223 | if (read > write) |
| 3224 | write += GEN8_CSB_ENTRIES; |
| 3225 | while (read < write) { |
| 3226 | unsigned int idx = ++read % GEN8_CSB_ENTRIES; |
| 3227 | |
| 3228 | seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n", |
| 3229 | idx, |
| 3230 | I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)), |
| 3231 | I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx))); |
| 3232 | } |
| 3233 | |
| 3234 | rcu_read_lock(); |
| 3235 | rq = READ_ONCE(engine->execlist_port[0].request); |
| 3236 | if (rq) |
| 3237 | print_request(m, rq, "\t\tELSP[0] "); |
| 3238 | else |
| 3239 | seq_printf(m, "\t\tELSP[0] idle\n"); |
| 3240 | rq = READ_ONCE(engine->execlist_port[1].request); |
| 3241 | if (rq) |
| 3242 | print_request(m, rq, "\t\tELSP[1] "); |
| 3243 | else |
| 3244 | seq_printf(m, "\t\tELSP[1] idle\n"); |
| 3245 | rcu_read_unlock(); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3246 | |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3247 | spin_lock_irq(&engine->timeline->lock); |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3248 | for (rb = engine->execlist_first; rb; rb = rb_next(rb)) { |
| 3249 | rq = rb_entry(rb, typeof(*rq), priotree.node); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3250 | print_request(m, rq, "\t\tQ "); |
| 3251 | } |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3252 | spin_unlock_irq(&engine->timeline->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3253 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 3254 | seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n", |
| 3255 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 3256 | seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n", |
| 3257 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 3258 | seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n", |
| 3259 | I915_READ(RING_PP_DIR_DCLV(engine))); |
| 3260 | } |
| 3261 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 3262 | spin_lock_irq(&b->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3263 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 3264 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 3265 | |
| 3266 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 3267 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 3268 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 3269 | spin_unlock_irq(&b->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3270 | |
| 3271 | seq_puts(m, "\n"); |
| 3272 | } |
| 3273 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3274 | intel_runtime_pm_put(dev_priv); |
| 3275 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3276 | return 0; |
| 3277 | } |
| 3278 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3279 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3280 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3281 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3282 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3283 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3284 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3285 | enum intel_engine_id id; |
| 3286 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3287 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3288 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3289 | seq_puts(m, "Semaphores are disabled\n"); |
| 3290 | return 0; |
| 3291 | } |
| 3292 | |
| 3293 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3294 | if (ret) |
| 3295 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3296 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3297 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3298 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3299 | struct page *page; |
| 3300 | uint64_t *seqno; |
| 3301 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3302 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3303 | |
| 3304 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3305 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3306 | uint64_t offset; |
| 3307 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3308 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3309 | |
| 3310 | seq_puts(m, " Last signal:"); |
| 3311 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3312 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3313 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3314 | seqno[offset], offset * 8); |
| 3315 | } |
| 3316 | seq_putc(m, '\n'); |
| 3317 | |
| 3318 | seq_puts(m, " Last wait: "); |
| 3319 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3320 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3321 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3322 | seqno[offset], offset * 8); |
| 3323 | } |
| 3324 | seq_putc(m, '\n'); |
| 3325 | |
| 3326 | } |
| 3327 | kunmap_atomic(seqno); |
| 3328 | } else { |
| 3329 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3330 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3331 | for (j = 0; j < num_rings; j++) |
| 3332 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3333 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3334 | seq_putc(m, '\n'); |
| 3335 | } |
| 3336 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3337 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3338 | mutex_unlock(&dev->struct_mutex); |
| 3339 | return 0; |
| 3340 | } |
| 3341 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3342 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3343 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3344 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3345 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3346 | int i; |
| 3347 | |
| 3348 | drm_modeset_lock_all(dev); |
| 3349 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3350 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3351 | |
| 3352 | 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] | 3353 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
| 3354 | pll->config.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3355 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3356 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 3357 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 3358 | pll->config.hw_state.dpll_md); |
| 3359 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 3360 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 3361 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3362 | } |
| 3363 | drm_modeset_unlock_all(dev); |
| 3364 | |
| 3365 | return 0; |
| 3366 | } |
| 3367 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3368 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3369 | { |
| 3370 | int i; |
| 3371 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3372 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3373 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3374 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3375 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3376 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3377 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3378 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3379 | if (ret) |
| 3380 | return ret; |
| 3381 | |
| 3382 | intel_runtime_pm_get(dev_priv); |
| 3383 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3384 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3385 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3386 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3387 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3388 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3389 | i915_reg_t addr; |
| 3390 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3391 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3392 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3393 | addr = workarounds->reg[i].addr; |
| 3394 | mask = workarounds->reg[i].mask; |
| 3395 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3396 | read = I915_READ(addr); |
| 3397 | ok = (value & mask) == (read & mask); |
| 3398 | 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] | 3399 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3400 | } |
| 3401 | |
| 3402 | intel_runtime_pm_put(dev_priv); |
| 3403 | mutex_unlock(&dev->struct_mutex); |
| 3404 | |
| 3405 | return 0; |
| 3406 | } |
| 3407 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3408 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3409 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3410 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3411 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3412 | struct skl_ddb_allocation *ddb; |
| 3413 | struct skl_ddb_entry *entry; |
| 3414 | enum pipe pipe; |
| 3415 | int plane; |
| 3416 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3417 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3418 | return 0; |
| 3419 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3420 | drm_modeset_lock_all(dev); |
| 3421 | |
| 3422 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3423 | |
| 3424 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3425 | |
| 3426 | for_each_pipe(dev_priv, pipe) { |
| 3427 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3428 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3429 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3430 | entry = &ddb->plane[pipe][plane]; |
| 3431 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3432 | entry->start, entry->end, |
| 3433 | skl_ddb_entry_size(entry)); |
| 3434 | } |
| 3435 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3436 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3437 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3438 | entry->end, skl_ddb_entry_size(entry)); |
| 3439 | } |
| 3440 | |
| 3441 | drm_modeset_unlock_all(dev); |
| 3442 | |
| 3443 | return 0; |
| 3444 | } |
| 3445 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3446 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3447 | struct drm_device *dev, |
| 3448 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3449 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3450 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3451 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3452 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3453 | struct drm_connector *connector; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3454 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3455 | drm_for_each_connector(connector, dev) { |
| 3456 | if (connector->state->crtc != &intel_crtc->base) |
| 3457 | continue; |
| 3458 | |
| 3459 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3460 | } |
| 3461 | |
| 3462 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3463 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3464 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3465 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3466 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3467 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3468 | else |
| 3469 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3470 | |
| 3471 | seq_puts(m, "\n\n"); |
| 3472 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3473 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3474 | struct intel_panel *panel; |
| 3475 | |
| 3476 | mutex_lock(&drrs->mutex); |
| 3477 | /* DRRS Supported */ |
| 3478 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3479 | |
| 3480 | /* disable_drrs() will make drrs->dp NULL */ |
| 3481 | if (!drrs->dp) { |
| 3482 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3483 | mutex_unlock(&drrs->mutex); |
| 3484 | return; |
| 3485 | } |
| 3486 | |
| 3487 | panel = &drrs->dp->attached_connector->panel; |
| 3488 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3489 | drrs->busy_frontbuffer_bits); |
| 3490 | |
| 3491 | seq_puts(m, "\n\t\t"); |
| 3492 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3493 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3494 | vrefresh = panel->fixed_mode->vrefresh; |
| 3495 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3496 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3497 | vrefresh = panel->downclock_mode->vrefresh; |
| 3498 | } else { |
| 3499 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3500 | drrs->refresh_rate_type); |
| 3501 | mutex_unlock(&drrs->mutex); |
| 3502 | return; |
| 3503 | } |
| 3504 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3505 | |
| 3506 | seq_puts(m, "\n\t\t"); |
| 3507 | mutex_unlock(&drrs->mutex); |
| 3508 | } else { |
| 3509 | /* DRRS not supported. Print the VBT parameter*/ |
| 3510 | seq_puts(m, "\tDRRS Supported : No"); |
| 3511 | } |
| 3512 | seq_puts(m, "\n"); |
| 3513 | } |
| 3514 | |
| 3515 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3516 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3517 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3518 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3519 | struct intel_crtc *intel_crtc; |
| 3520 | int active_crtc_cnt = 0; |
| 3521 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3522 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3523 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3524 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3525 | active_crtc_cnt++; |
| 3526 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3527 | |
| 3528 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3529 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3530 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3531 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3532 | |
| 3533 | if (!active_crtc_cnt) |
| 3534 | seq_puts(m, "No active crtc found\n"); |
| 3535 | |
| 3536 | return 0; |
| 3537 | } |
| 3538 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3539 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3540 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3541 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3542 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3543 | struct intel_encoder *intel_encoder; |
| 3544 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3545 | struct drm_connector *connector; |
| 3546 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3547 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3548 | drm_for_each_connector(connector, dev) { |
| 3549 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3550 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3551 | |
| 3552 | intel_encoder = intel_attached_encoder(connector); |
| 3553 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3554 | continue; |
| 3555 | |
| 3556 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3557 | if (!intel_dig_port->dp.can_mst) |
| 3558 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3559 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3560 | seq_printf(m, "MST Source Port %c\n", |
| 3561 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3562 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3563 | } |
| 3564 | drm_modeset_unlock_all(dev); |
| 3565 | return 0; |
| 3566 | } |
| 3567 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3568 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3569 | const char __user *ubuf, |
| 3570 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3571 | { |
| 3572 | char *input_buffer; |
| 3573 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3574 | struct drm_device *dev; |
| 3575 | struct drm_connector *connector; |
| 3576 | struct list_head *connector_list; |
| 3577 | struct intel_dp *intel_dp; |
| 3578 | int val = 0; |
| 3579 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3580 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3581 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3582 | connector_list = &dev->mode_config.connector_list; |
| 3583 | |
| 3584 | if (len == 0) |
| 3585 | return 0; |
| 3586 | |
| 3587 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 3588 | if (!input_buffer) |
| 3589 | return -ENOMEM; |
| 3590 | |
| 3591 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 3592 | status = -EFAULT; |
| 3593 | goto out; |
| 3594 | } |
| 3595 | |
| 3596 | input_buffer[len] = '\0'; |
| 3597 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3598 | |
| 3599 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3600 | if (connector->connector_type != |
| 3601 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3602 | continue; |
| 3603 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 3604 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3605 | connector->encoder != NULL) { |
| 3606 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3607 | status = kstrtoint(input_buffer, 10, &val); |
| 3608 | if (status < 0) |
| 3609 | goto out; |
| 3610 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3611 | /* To prevent erroneous activation of the compliance |
| 3612 | * testing code, only accept an actual value of 1 here |
| 3613 | */ |
| 3614 | if (val == 1) |
| 3615 | intel_dp->compliance_test_active = 1; |
| 3616 | else |
| 3617 | intel_dp->compliance_test_active = 0; |
| 3618 | } |
| 3619 | } |
| 3620 | out: |
| 3621 | kfree(input_buffer); |
| 3622 | if (status < 0) |
| 3623 | return status; |
| 3624 | |
| 3625 | *offp += len; |
| 3626 | return len; |
| 3627 | } |
| 3628 | |
| 3629 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3630 | { |
| 3631 | struct drm_device *dev = m->private; |
| 3632 | struct drm_connector *connector; |
| 3633 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 3634 | struct intel_dp *intel_dp; |
| 3635 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3636 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3637 | if (connector->connector_type != |
| 3638 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3639 | continue; |
| 3640 | |
| 3641 | if (connector->status == connector_status_connected && |
| 3642 | connector->encoder != NULL) { |
| 3643 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3644 | if (intel_dp->compliance_test_active) |
| 3645 | seq_puts(m, "1"); |
| 3646 | else |
| 3647 | seq_puts(m, "0"); |
| 3648 | } else |
| 3649 | seq_puts(m, "0"); |
| 3650 | } |
| 3651 | |
| 3652 | return 0; |
| 3653 | } |
| 3654 | |
| 3655 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3656 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3657 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3658 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3659 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3660 | return single_open(file, i915_displayport_test_active_show, |
| 3661 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3662 | } |
| 3663 | |
| 3664 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3665 | .owner = THIS_MODULE, |
| 3666 | .open = i915_displayport_test_active_open, |
| 3667 | .read = seq_read, |
| 3668 | .llseek = seq_lseek, |
| 3669 | .release = single_release, |
| 3670 | .write = i915_displayport_test_active_write |
| 3671 | }; |
| 3672 | |
| 3673 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3674 | { |
| 3675 | struct drm_device *dev = m->private; |
| 3676 | struct drm_connector *connector; |
| 3677 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 3678 | struct intel_dp *intel_dp; |
| 3679 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3680 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3681 | if (connector->connector_type != |
| 3682 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3683 | continue; |
| 3684 | |
| 3685 | if (connector->status == connector_status_connected && |
| 3686 | connector->encoder != NULL) { |
| 3687 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3688 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 3689 | } else |
| 3690 | seq_puts(m, "0"); |
| 3691 | } |
| 3692 | |
| 3693 | return 0; |
| 3694 | } |
| 3695 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3696 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3697 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3698 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3699 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3700 | return single_open(file, i915_displayport_test_data_show, |
| 3701 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3702 | } |
| 3703 | |
| 3704 | static const struct file_operations i915_displayport_test_data_fops = { |
| 3705 | .owner = THIS_MODULE, |
| 3706 | .open = i915_displayport_test_data_open, |
| 3707 | .read = seq_read, |
| 3708 | .llseek = seq_lseek, |
| 3709 | .release = single_release |
| 3710 | }; |
| 3711 | |
| 3712 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3713 | { |
| 3714 | struct drm_device *dev = m->private; |
| 3715 | struct drm_connector *connector; |
| 3716 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 3717 | struct intel_dp *intel_dp; |
| 3718 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3719 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3720 | if (connector->connector_type != |
| 3721 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3722 | continue; |
| 3723 | |
| 3724 | if (connector->status == connector_status_connected && |
| 3725 | connector->encoder != NULL) { |
| 3726 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3727 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 3728 | } else |
| 3729 | seq_puts(m, "0"); |
| 3730 | } |
| 3731 | |
| 3732 | return 0; |
| 3733 | } |
| 3734 | |
| 3735 | static int i915_displayport_test_type_open(struct inode *inode, |
| 3736 | struct file *file) |
| 3737 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3738 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3739 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3740 | return single_open(file, i915_displayport_test_type_show, |
| 3741 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3742 | } |
| 3743 | |
| 3744 | static const struct file_operations i915_displayport_test_type_fops = { |
| 3745 | .owner = THIS_MODULE, |
| 3746 | .open = i915_displayport_test_type_open, |
| 3747 | .read = seq_read, |
| 3748 | .llseek = seq_lseek, |
| 3749 | .release = single_release |
| 3750 | }; |
| 3751 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3752 | 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] | 3753 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3754 | struct drm_i915_private *dev_priv = m->private; |
| 3755 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3756 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3757 | int num_levels; |
| 3758 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3759 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3760 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3761 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3762 | num_levels = 1; |
| 3763 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3764 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3765 | |
| 3766 | drm_modeset_lock_all(dev); |
| 3767 | |
| 3768 | for (level = 0; level < num_levels; level++) { |
| 3769 | unsigned int latency = wm[level]; |
| 3770 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3771 | /* |
| 3772 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3773 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3774 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3775 | if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) || |
| 3776 | IS_CHERRYVIEW(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3777 | latency *= 10; |
| 3778 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3779 | latency *= 5; |
| 3780 | |
| 3781 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3782 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3783 | } |
| 3784 | |
| 3785 | drm_modeset_unlock_all(dev); |
| 3786 | } |
| 3787 | |
| 3788 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3789 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3790 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3791 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3792 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3793 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3794 | latencies = dev_priv->wm.skl_latency; |
| 3795 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3796 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3797 | |
| 3798 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3799 | |
| 3800 | return 0; |
| 3801 | } |
| 3802 | |
| 3803 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3804 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3805 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3806 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3807 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3808 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3809 | latencies = dev_priv->wm.skl_latency; |
| 3810 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3811 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3812 | |
| 3813 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3814 | |
| 3815 | return 0; |
| 3816 | } |
| 3817 | |
| 3818 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3819 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3820 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3821 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3822 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3823 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3824 | latencies = dev_priv->wm.skl_latency; |
| 3825 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3826 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3827 | |
| 3828 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3829 | |
| 3830 | return 0; |
| 3831 | } |
| 3832 | |
| 3833 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3834 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3835 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3836 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3837 | if (INTEL_GEN(dev_priv) < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3838 | return -ENODEV; |
| 3839 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3840 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3841 | } |
| 3842 | |
| 3843 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3844 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3845 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3846 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3847 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3848 | return -ENODEV; |
| 3849 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3850 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3851 | } |
| 3852 | |
| 3853 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3854 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3855 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3856 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3857 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3858 | return -ENODEV; |
| 3859 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3860 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3861 | } |
| 3862 | |
| 3863 | 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] | 3864 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3865 | { |
| 3866 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3867 | struct drm_i915_private *dev_priv = m->private; |
| 3868 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3869 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3870 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3871 | int level; |
| 3872 | int ret; |
| 3873 | char tmp[32]; |
| 3874 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3875 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3876 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3877 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3878 | num_levels = 1; |
| 3879 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3880 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3881 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3882 | if (len >= sizeof(tmp)) |
| 3883 | return -EINVAL; |
| 3884 | |
| 3885 | if (copy_from_user(tmp, ubuf, len)) |
| 3886 | return -EFAULT; |
| 3887 | |
| 3888 | tmp[len] = '\0'; |
| 3889 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3890 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3891 | &new[0], &new[1], &new[2], &new[3], |
| 3892 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3893 | if (ret != num_levels) |
| 3894 | return -EINVAL; |
| 3895 | |
| 3896 | drm_modeset_lock_all(dev); |
| 3897 | |
| 3898 | for (level = 0; level < num_levels; level++) |
| 3899 | wm[level] = new[level]; |
| 3900 | |
| 3901 | drm_modeset_unlock_all(dev); |
| 3902 | |
| 3903 | return len; |
| 3904 | } |
| 3905 | |
| 3906 | |
| 3907 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3908 | size_t len, loff_t *offp) |
| 3909 | { |
| 3910 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3911 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3912 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3913 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3914 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3915 | latencies = dev_priv->wm.skl_latency; |
| 3916 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3917 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3918 | |
| 3919 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3920 | } |
| 3921 | |
| 3922 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3923 | size_t len, loff_t *offp) |
| 3924 | { |
| 3925 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3926 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3927 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3928 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3929 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3930 | latencies = dev_priv->wm.skl_latency; |
| 3931 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3932 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3933 | |
| 3934 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3935 | } |
| 3936 | |
| 3937 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3938 | size_t len, loff_t *offp) |
| 3939 | { |
| 3940 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3941 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3942 | uint16_t *latencies; |
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 (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3945 | latencies = dev_priv->wm.skl_latency; |
| 3946 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3947 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3948 | |
| 3949 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3950 | } |
| 3951 | |
| 3952 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3953 | .owner = THIS_MODULE, |
| 3954 | .open = pri_wm_latency_open, |
| 3955 | .read = seq_read, |
| 3956 | .llseek = seq_lseek, |
| 3957 | .release = single_release, |
| 3958 | .write = pri_wm_latency_write |
| 3959 | }; |
| 3960 | |
| 3961 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3962 | .owner = THIS_MODULE, |
| 3963 | .open = spr_wm_latency_open, |
| 3964 | .read = seq_read, |
| 3965 | .llseek = seq_lseek, |
| 3966 | .release = single_release, |
| 3967 | .write = spr_wm_latency_write |
| 3968 | }; |
| 3969 | |
| 3970 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3971 | .owner = THIS_MODULE, |
| 3972 | .open = cur_wm_latency_open, |
| 3973 | .read = seq_read, |
| 3974 | .llseek = seq_lseek, |
| 3975 | .release = single_release, |
| 3976 | .write = cur_wm_latency_write |
| 3977 | }; |
| 3978 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3979 | static int |
| 3980 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3981 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3982 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3983 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 3984 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3985 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3986 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3987 | } |
| 3988 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3989 | static int |
| 3990 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3991 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3992 | struct drm_i915_private *dev_priv = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3993 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3994 | /* |
| 3995 | * There is no safeguard against this debugfs entry colliding |
| 3996 | * with the hangcheck calling same i915_handle_error() in |
| 3997 | * parallel, causing an explosion. For now we assume that the |
| 3998 | * test harness is responsible enough not to inject gpu hangs |
| 3999 | * while it is writing to 'i915_wedged' |
| 4000 | */ |
| 4001 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4002 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4003 | return -EAGAIN; |
| 4004 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4005 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4006 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4007 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4008 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4009 | } |
| 4010 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4011 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4012 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4013 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4014 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4015 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4016 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4017 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4018 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4019 | |
| 4020 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4021 | return 0; |
| 4022 | } |
| 4023 | |
| 4024 | static int |
| 4025 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4026 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4027 | struct drm_i915_private *dev_priv = data; |
| 4028 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4029 | int ret; |
| 4030 | |
| 4031 | /* Lock against concurrent debugfs callers */ |
| 4032 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4033 | if (ret) |
| 4034 | return ret; |
| 4035 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4036 | mutex_unlock(&dev->struct_mutex); |
| 4037 | |
| 4038 | return 0; |
| 4039 | } |
| 4040 | |
| 4041 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4042 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4043 | "0x%08llx\n"); |
| 4044 | |
| 4045 | static int |
| 4046 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4047 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4048 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4049 | |
| 4050 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4051 | |
| 4052 | return 0; |
| 4053 | } |
| 4054 | |
| 4055 | static int |
| 4056 | i915_ring_test_irq_set(void *data, u64 val) |
| 4057 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4058 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4059 | |
Chris Wilson | 3a122c2 | 2016-06-17 14:35:05 +0100 | [diff] [blame] | 4060 | val &= INTEL_INFO(dev_priv)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4061 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4062 | dev_priv->gpu_error.test_irq_rings = val; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4063 | |
| 4064 | return 0; |
| 4065 | } |
| 4066 | |
| 4067 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4068 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4069 | "0x%08llx\n"); |
| 4070 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4071 | #define DROP_UNBOUND 0x1 |
| 4072 | #define DROP_BOUND 0x2 |
| 4073 | #define DROP_RETIRE 0x4 |
| 4074 | #define DROP_ACTIVE 0x8 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4075 | #define DROP_FREED 0x10 |
| 4076 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4077 | DROP_BOUND | \ |
| 4078 | DROP_RETIRE | \ |
| 4079 | DROP_ACTIVE | \ |
| 4080 | DROP_FREED) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4081 | static int |
| 4082 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4083 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4084 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4085 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4086 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4087 | } |
| 4088 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4089 | static int |
| 4090 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4091 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4092 | struct drm_i915_private *dev_priv = data; |
| 4093 | struct drm_device *dev = &dev_priv->drm; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4094 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4095 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4096 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4097 | |
| 4098 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4099 | * on ioctls on -EAGAIN. */ |
| 4100 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4101 | if (ret) |
| 4102 | return ret; |
| 4103 | |
| 4104 | if (val & DROP_ACTIVE) { |
Chris Wilson | 22dd3bb | 2016-09-09 14:11:50 +0100 | [diff] [blame] | 4105 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4106 | I915_WAIT_INTERRUPTIBLE | |
| 4107 | I915_WAIT_LOCKED); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4108 | if (ret) |
| 4109 | goto unlock; |
| 4110 | } |
| 4111 | |
| 4112 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4113 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4114 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4115 | if (val & DROP_BOUND) |
| 4116 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4117 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4118 | if (val & DROP_UNBOUND) |
| 4119 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4120 | |
| 4121 | unlock: |
| 4122 | mutex_unlock(&dev->struct_mutex); |
| 4123 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4124 | if (val & DROP_FREED) { |
| 4125 | synchronize_rcu(); |
| 4126 | flush_work(&dev_priv->mm.free_work); |
| 4127 | } |
| 4128 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4129 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4130 | } |
| 4131 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4132 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4133 | i915_drop_caches_get, i915_drop_caches_set, |
| 4134 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4135 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4136 | static int |
| 4137 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4138 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4139 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4140 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4141 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4142 | return -ENODEV; |
| 4143 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4144 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4145 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4146 | } |
| 4147 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4148 | static int |
| 4149 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4150 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4151 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4152 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4153 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4154 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4155 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4156 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4157 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4158 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4159 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4160 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4161 | if (ret) |
| 4162 | return ret; |
| 4163 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4164 | /* |
| 4165 | * Turbo will still be enabled, but won't go above the set value. |
| 4166 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4167 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4168 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4169 | hw_max = dev_priv->rps.max_freq; |
| 4170 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4171 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4172 | 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] | 4173 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4174 | return -EINVAL; |
| 4175 | } |
| 4176 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4177 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4178 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 4179 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4180 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4181 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4182 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4183 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4184 | } |
| 4185 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4186 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4187 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4188 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4189 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4190 | static int |
| 4191 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4192 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4193 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4194 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4195 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4196 | return -ENODEV; |
| 4197 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4198 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4199 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4200 | } |
| 4201 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4202 | static int |
| 4203 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4204 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4205 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4206 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4207 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4208 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4209 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4210 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4211 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4212 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4213 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4214 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4215 | if (ret) |
| 4216 | return ret; |
| 4217 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4218 | /* |
| 4219 | * Turbo will still be enabled, but won't go below the set value. |
| 4220 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4221 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4222 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4223 | hw_max = dev_priv->rps.max_freq; |
| 4224 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4225 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4226 | if (val < hw_min || |
| 4227 | val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4228 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4229 | return -EINVAL; |
| 4230 | } |
| 4231 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4232 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4233 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 4234 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4235 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4236 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4237 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4238 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4239 | } |
| 4240 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4241 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4242 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4243 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4244 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4245 | static int |
| 4246 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4247 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4248 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4249 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4250 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4251 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4252 | return -ENODEV; |
| 4253 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4254 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4255 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4256 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4257 | |
| 4258 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4259 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4260 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4261 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4262 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4263 | } |
| 4264 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4265 | static int |
| 4266 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4267 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4268 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4269 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4270 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4271 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4272 | return -ENODEV; |
| 4273 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4274 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4275 | return -EINVAL; |
| 4276 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4277 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4278 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4279 | |
| 4280 | /* Update the cache sharing policy here as well */ |
| 4281 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4282 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4283 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4284 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4285 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4286 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4287 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4288 | } |
| 4289 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4290 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4291 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4292 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4293 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4294 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4295 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4296 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 4297 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4298 | int ss; |
| 4299 | u32 sig1[ss_max], sig2[ss_max]; |
| 4300 | |
| 4301 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4302 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4303 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4304 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4305 | |
| 4306 | for (ss = 0; ss < ss_max; ss++) { |
| 4307 | unsigned int eu_cnt; |
| 4308 | |
| 4309 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4310 | /* skip disabled subslice */ |
| 4311 | continue; |
| 4312 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4313 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4314 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4315 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4316 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4317 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4318 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4319 | sseu->eu_total += eu_cnt; |
| 4320 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4321 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4322 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4323 | } |
| 4324 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4325 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4326 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4327 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4328 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4329 | int s, ss; |
| 4330 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4331 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4332 | /* BXT has a single slice and at most 3 subslices. */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4333 | if (IS_GEN9_LP(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4334 | s_max = 1; |
| 4335 | ss_max = 3; |
| 4336 | } |
| 4337 | |
| 4338 | for (s = 0; s < s_max; s++) { |
| 4339 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4340 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4341 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4342 | } |
| 4343 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4344 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4345 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4346 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4347 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4348 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4349 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4350 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4351 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4352 | |
| 4353 | for (s = 0; s < s_max; s++) { |
| 4354 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4355 | /* skip disabled slice */ |
| 4356 | continue; |
| 4357 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4358 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4359 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4360 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4361 | sseu->subslice_mask = |
| 4362 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4363 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4364 | for (ss = 0; ss < ss_max; ss++) { |
| 4365 | unsigned int eu_cnt; |
| 4366 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4367 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4368 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4369 | /* skip disabled subslice */ |
| 4370 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4371 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4372 | sseu->subslice_mask |= BIT(ss); |
| 4373 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4374 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4375 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4376 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4377 | sseu->eu_total += eu_cnt; |
| 4378 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4379 | sseu->eu_per_subslice, |
| 4380 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4381 | } |
| 4382 | } |
| 4383 | } |
| 4384 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4385 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4386 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4387 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4388 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4389 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4390 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4391 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4392 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4393 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4394 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4395 | sseu->eu_per_subslice = |
| 4396 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4397 | sseu->eu_total = sseu->eu_per_subslice * |
| 4398 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4399 | |
| 4400 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4401 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4402 | u8 subslice_7eu = |
| 4403 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4404 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4405 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4406 | } |
| 4407 | } |
| 4408 | } |
| 4409 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4410 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4411 | const struct sseu_dev_info *sseu) |
| 4412 | { |
| 4413 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4414 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 4415 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4416 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4417 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4418 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4419 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4420 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4421 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4422 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 4423 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4424 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4425 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4426 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4427 | sseu->eu_total); |
| 4428 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4429 | sseu->eu_per_subslice); |
| 4430 | |
| 4431 | if (!is_available_info) |
| 4432 | return; |
| 4433 | |
| 4434 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4435 | if (HAS_POOLED_EU(dev_priv)) |
| 4436 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4437 | |
| 4438 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4439 | yesno(sseu->has_slice_pg)); |
| 4440 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4441 | yesno(sseu->has_subslice_pg)); |
| 4442 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4443 | yesno(sseu->has_eu_pg)); |
| 4444 | } |
| 4445 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4446 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4447 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4448 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4449 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4450 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4451 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4452 | return -ENODEV; |
| 4453 | |
| 4454 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4455 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4456 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4457 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4458 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4459 | |
| 4460 | intel_runtime_pm_get(dev_priv); |
| 4461 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4462 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4463 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4464 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4465 | broadwell_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4466 | } else if (INTEL_GEN(dev_priv) >= 9) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4467 | gen9_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4468 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4469 | |
| 4470 | intel_runtime_pm_put(dev_priv); |
| 4471 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4472 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4473 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4474 | return 0; |
| 4475 | } |
| 4476 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4477 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4478 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4479 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4480 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4481 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4482 | return 0; |
| 4483 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4484 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4485 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4486 | |
| 4487 | return 0; |
| 4488 | } |
| 4489 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4490 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4491 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4492 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4493 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4494 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4495 | return 0; |
| 4496 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4497 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4498 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4499 | |
| 4500 | return 0; |
| 4501 | } |
| 4502 | |
| 4503 | static const struct file_operations i915_forcewake_fops = { |
| 4504 | .owner = THIS_MODULE, |
| 4505 | .open = i915_forcewake_open, |
| 4506 | .release = i915_forcewake_release, |
| 4507 | }; |
| 4508 | |
| 4509 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 4510 | { |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4511 | struct dentry *ent; |
| 4512 | |
| 4513 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4514 | S_IRUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4515 | root, to_i915(minor->dev), |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4516 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4517 | if (!ent) |
| 4518 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4519 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4520 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4521 | } |
| 4522 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4523 | static int i915_debugfs_create(struct dentry *root, |
| 4524 | struct drm_minor *minor, |
| 4525 | const char *name, |
| 4526 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4527 | { |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4528 | struct dentry *ent; |
| 4529 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4530 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4531 | S_IRUGO | S_IWUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4532 | root, to_i915(minor->dev), |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4533 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4534 | if (!ent) |
| 4535 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4536 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4537 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4538 | } |
| 4539 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4540 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4541 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4542 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4543 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 4544 | {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4545 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4546 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4547 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4548 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4549 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4550 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4551 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4552 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4553 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4554 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4555 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4556 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4557 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4558 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4559 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4560 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4561 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4562 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4563 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4564 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4565 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4566 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4567 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4568 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4569 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4570 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4571 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4572 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4573 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4574 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4575 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4576 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4577 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4578 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4579 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4580 | {"i915_engine_info", i915_engine_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4581 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4582 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4583 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4584 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4585 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4586 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4587 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4588 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4589 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4590 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4591 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4592 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4593 | const char *name; |
| 4594 | const struct file_operations *fops; |
| 4595 | } i915_debugfs_files[] = { |
| 4596 | {"i915_wedged", &i915_wedged_fops}, |
| 4597 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4598 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4599 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4600 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4601 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4602 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4603 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4604 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4605 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4606 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4607 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4608 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4609 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4610 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 4611 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4612 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4613 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4614 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
| 4615 | {"i915_guc_log_control", &i915_guc_log_control_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4616 | }; |
| 4617 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4618 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4619 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4620 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4621 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4622 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4623 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 4624 | if (ret) |
| 4625 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4626 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame^] | 4627 | ret = intel_pipe_crc_create(minor); |
| 4628 | if (ret) |
| 4629 | return ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4630 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4631 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4632 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 4633 | i915_debugfs_files[i].name, |
| 4634 | i915_debugfs_files[i].fops); |
| 4635 | if (ret) |
| 4636 | return ret; |
| 4637 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4638 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4639 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4640 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4641 | minor->debugfs_root, minor); |
| 4642 | } |
| 4643 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4644 | void i915_debugfs_unregister(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4645 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4646 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4647 | int i; |
| 4648 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4649 | drm_debugfs_remove_files(i915_debugfs_list, |
| 4650 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4651 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4652 | drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4653 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4654 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame^] | 4655 | intel_pipe_crc_cleanup(minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4656 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4657 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4658 | struct drm_info_list *info_list = |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4659 | (struct drm_info_list *)i915_debugfs_files[i].fops; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4660 | |
| 4661 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4662 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4663 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4664 | |
| 4665 | struct dpcd_block { |
| 4666 | /* DPCD dump start address. */ |
| 4667 | unsigned int offset; |
| 4668 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4669 | unsigned int end; |
| 4670 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4671 | size_t size; |
| 4672 | /* Only valid for eDP. */ |
| 4673 | bool edp; |
| 4674 | }; |
| 4675 | |
| 4676 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4677 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4678 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4679 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4680 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4681 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4682 | { .offset = DP_SET_POWER }, |
| 4683 | { .offset = DP_EDP_DPCD_REV }, |
| 4684 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4685 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4686 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4687 | }; |
| 4688 | |
| 4689 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4690 | { |
| 4691 | struct drm_connector *connector = m->private; |
| 4692 | struct intel_dp *intel_dp = |
| 4693 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4694 | uint8_t buf[16]; |
| 4695 | ssize_t err; |
| 4696 | int i; |
| 4697 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4698 | if (connector->status != connector_status_connected) |
| 4699 | return -ENODEV; |
| 4700 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4701 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4702 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4703 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4704 | |
| 4705 | if (b->edp && |
| 4706 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4707 | continue; |
| 4708 | |
| 4709 | /* low tech for now */ |
| 4710 | if (WARN_ON(size > sizeof(buf))) |
| 4711 | continue; |
| 4712 | |
| 4713 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 4714 | if (err <= 0) { |
| 4715 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 4716 | size, b->offset, err); |
| 4717 | continue; |
| 4718 | } |
| 4719 | |
| 4720 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4721 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4722 | |
| 4723 | return 0; |
| 4724 | } |
| 4725 | |
| 4726 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 4727 | { |
| 4728 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 4729 | } |
| 4730 | |
| 4731 | static const struct file_operations i915_dpcd_fops = { |
| 4732 | .owner = THIS_MODULE, |
| 4733 | .open = i915_dpcd_open, |
| 4734 | .read = seq_read, |
| 4735 | .llseek = seq_lseek, |
| 4736 | .release = single_release, |
| 4737 | }; |
| 4738 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4739 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4740 | { |
| 4741 | struct drm_connector *connector = m->private; |
| 4742 | struct intel_dp *intel_dp = |
| 4743 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4744 | |
| 4745 | if (connector->status != connector_status_connected) |
| 4746 | return -ENODEV; |
| 4747 | |
| 4748 | seq_printf(m, "Panel power up delay: %d\n", |
| 4749 | intel_dp->panel_power_up_delay); |
| 4750 | seq_printf(m, "Panel power down delay: %d\n", |
| 4751 | intel_dp->panel_power_down_delay); |
| 4752 | seq_printf(m, "Backlight on delay: %d\n", |
| 4753 | intel_dp->backlight_on_delay); |
| 4754 | seq_printf(m, "Backlight off delay: %d\n", |
| 4755 | intel_dp->backlight_off_delay); |
| 4756 | |
| 4757 | return 0; |
| 4758 | } |
| 4759 | |
| 4760 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 4761 | { |
| 4762 | return single_open(file, i915_panel_show, inode->i_private); |
| 4763 | } |
| 4764 | |
| 4765 | static const struct file_operations i915_panel_fops = { |
| 4766 | .owner = THIS_MODULE, |
| 4767 | .open = i915_panel_open, |
| 4768 | .read = seq_read, |
| 4769 | .llseek = seq_lseek, |
| 4770 | .release = single_release, |
| 4771 | }; |
| 4772 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4773 | /** |
| 4774 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4775 | * @connector: pointer to a registered drm_connector |
| 4776 | * |
| 4777 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4778 | * drm_debugfs_connector_remove(). |
| 4779 | * |
| 4780 | * Returns 0 on success, negative error codes on error. |
| 4781 | */ |
| 4782 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 4783 | { |
| 4784 | struct dentry *root = connector->debugfs_entry; |
| 4785 | |
| 4786 | /* The connector must have been registered beforehands. */ |
| 4787 | if (!root) |
| 4788 | return -ENODEV; |
| 4789 | |
| 4790 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4791 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4792 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 4793 | connector, &i915_dpcd_fops); |
| 4794 | |
| 4795 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 4796 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 4797 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4798 | |
| 4799 | return 0; |
| 4800 | } |