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 | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 30 | #include <linux/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 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 38 | static __always_inline void seq_print_param(struct seq_file *m, |
| 39 | const char *name, |
| 40 | const char *type, |
| 41 | const void *x) |
| 42 | { |
| 43 | if (!__builtin_strcmp(type, "bool")) |
| 44 | seq_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x)); |
| 45 | else if (!__builtin_strcmp(type, "int")) |
| 46 | seq_printf(m, "i915.%s=%d\n", name, *(const int *)x); |
| 47 | else if (!__builtin_strcmp(type, "unsigned int")) |
| 48 | seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x); |
Chris Wilson | 1d6aa7a | 2017-02-21 16:26:19 +0000 | [diff] [blame] | 49 | else if (!__builtin_strcmp(type, "char *")) |
| 50 | seq_printf(m, "i915.%s=%s\n", name, *(const char **)x); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 51 | else |
| 52 | BUILD_BUG(); |
| 53 | } |
| 54 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 55 | static int i915_capabilities(struct seq_file *m, void *data) |
| 56 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 57 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 58 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 59 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 60 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 61 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 62 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 63 | |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 64 | #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] | 65 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 66 | #undef PRINT_FLAG |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 67 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 68 | kernel_param_lock(THIS_MODULE); |
| 69 | #define PRINT_PARAM(T, x) seq_print_param(m, #x, #T, &i915.x); |
| 70 | I915_PARAMS_FOR_EACH(PRINT_PARAM); |
| 71 | #undef PRINT_PARAM |
| 72 | kernel_param_unlock(THIS_MODULE); |
| 73 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 74 | return 0; |
| 75 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 76 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 77 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 78 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 79 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 82 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 83 | { |
| 84 | return obj->pin_display ? 'p' : ' '; |
| 85 | } |
| 86 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 87 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 88 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 89 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 90 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 91 | case I915_TILING_NONE: return ' '; |
| 92 | case I915_TILING_X: return 'X'; |
| 93 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 94 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 97 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 98 | { |
Chris Wilson | 275f039 | 2016-10-24 13:42:14 +0100 | [diff] [blame] | 99 | return !list_empty(&obj->userfault_link) ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 102 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 103 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 104 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 107 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 108 | { |
| 109 | u64 size = 0; |
| 110 | struct i915_vma *vma; |
| 111 | |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 112 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 113 | if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 114 | size += vma->node.size; |
| 115 | } |
| 116 | |
| 117 | return size; |
| 118 | } |
| 119 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 120 | static void |
| 121 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 122 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 123 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 124 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 125 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 126 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 127 | int pin_count = 0; |
| 128 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 129 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 130 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 131 | 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] | 132 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 133 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 134 | get_pin_flag(obj), |
| 135 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 136 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 137 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 138 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 139 | obj->base.read_domains, |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 140 | obj->base.write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 141 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 142 | obj->mm.dirty ? " dirty" : "", |
| 143 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 144 | if (obj->base.name) |
| 145 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 146 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 147 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 148 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 149 | } |
| 150 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 151 | if (obj->pin_display) |
| 152 | seq_printf(m, " (display)"); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 153 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 154 | if (!drm_mm_node_allocated(&vma->node)) |
| 155 | continue; |
| 156 | |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 157 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 158 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 159 | vma->node.start, vma->node.size); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 160 | if (i915_vma_is_ggtt(vma)) { |
| 161 | switch (vma->ggtt_view.type) { |
| 162 | case I915_GGTT_VIEW_NORMAL: |
| 163 | seq_puts(m, ", normal"); |
| 164 | break; |
| 165 | |
| 166 | case I915_GGTT_VIEW_PARTIAL: |
| 167 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 168 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 169 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 170 | break; |
| 171 | |
| 172 | case I915_GGTT_VIEW_ROTATED: |
| 173 | seq_printf(m, ", rotated [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 174 | vma->ggtt_view.rotated.plane[0].width, |
| 175 | vma->ggtt_view.rotated.plane[0].height, |
| 176 | vma->ggtt_view.rotated.plane[0].stride, |
| 177 | vma->ggtt_view.rotated.plane[0].offset, |
| 178 | vma->ggtt_view.rotated.plane[1].width, |
| 179 | vma->ggtt_view.rotated.plane[1].height, |
| 180 | vma->ggtt_view.rotated.plane[1].stride, |
| 181 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 182 | break; |
| 183 | |
| 184 | default: |
| 185 | MISSING_CASE(vma->ggtt_view.type); |
| 186 | break; |
| 187 | } |
| 188 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 189 | if (vma->fence) |
| 190 | seq_printf(m, " , fence: %d%s", |
| 191 | vma->fence->id, |
| 192 | i915_gem_active_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 193 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 194 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 195 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 196 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 197 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 198 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 199 | if (engine) |
| 200 | seq_printf(m, " (%s)", engine->name); |
| 201 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 202 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 203 | if (frontbuffer_bits) |
| 204 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 205 | } |
| 206 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 207 | static int obj_rank_by_stolen(const void *A, const void *B) |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 208 | { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 209 | const struct drm_i915_gem_object *a = |
| 210 | *(const struct drm_i915_gem_object **)A; |
| 211 | const struct drm_i915_gem_object *b = |
| 212 | *(const struct drm_i915_gem_object **)B; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 213 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 214 | if (a->stolen->start < b->stolen->start) |
| 215 | return -1; |
| 216 | if (a->stolen->start > b->stolen->start) |
| 217 | return 1; |
| 218 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 222 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 223 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 224 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 225 | struct drm_i915_gem_object **objects; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 226 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 227 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 228 | unsigned long total, count, n; |
| 229 | int ret; |
| 230 | |
| 231 | total = READ_ONCE(dev_priv->mm.object_count); |
| 232 | objects = drm_malloc_ab(total, sizeof(*objects)); |
| 233 | if (!objects) |
| 234 | return -ENOMEM; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 235 | |
| 236 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 237 | if (ret) |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 238 | goto out; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 239 | |
| 240 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 241 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 242 | if (count == total) |
| 243 | break; |
| 244 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 245 | if (obj->stolen == NULL) |
| 246 | continue; |
| 247 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 248 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 249 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 250 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 251 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 252 | } |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 253 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 254 | if (count == total) |
| 255 | break; |
| 256 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 257 | if (obj->stolen == NULL) |
| 258 | continue; |
| 259 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 260 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 261 | total_obj_size += obj->base.size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 262 | } |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 263 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 264 | sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL); |
| 265 | |
| 266 | seq_puts(m, "Stolen:\n"); |
| 267 | for (n = 0; n < count; n++) { |
| 268 | seq_puts(m, " "); |
| 269 | describe_obj(m, objects[n]); |
| 270 | seq_putc(m, '\n'); |
| 271 | } |
| 272 | seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 273 | count, total_obj_size, total_gtt_size); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 274 | |
| 275 | mutex_unlock(&dev->struct_mutex); |
| 276 | out: |
| 277 | drm_free_large(objects); |
| 278 | return ret; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 281 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 282 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 283 | unsigned long count; |
| 284 | u64 total, unbound; |
| 285 | u64 global, shared; |
| 286 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | static int per_file_stats(int id, void *ptr, void *data) |
| 290 | { |
| 291 | struct drm_i915_gem_object *obj = ptr; |
| 292 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 293 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 294 | |
| 295 | stats->count++; |
| 296 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 297 | if (!obj->bind_count) |
| 298 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 299 | if (obj->base.name || obj->base.dma_buf) |
| 300 | stats->shared += obj->base.size; |
| 301 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 302 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 303 | if (!drm_mm_node_allocated(&vma->node)) |
| 304 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 305 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 306 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 307 | stats->global += vma->node.size; |
| 308 | } else { |
| 309 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 310 | |
Chris Wilson | 2bfa996 | 2016-08-04 07:52:25 +0100 | [diff] [blame] | 311 | if (ppgtt->base.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 312 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 313 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 314 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 315 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 316 | stats->active += vma->node.size; |
| 317 | else |
| 318 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 324 | #define print_file_stats(m, name, stats) do { \ |
| 325 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 326 | 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] | 327 | name, \ |
| 328 | stats.count, \ |
| 329 | stats.total, \ |
| 330 | stats.active, \ |
| 331 | stats.inactive, \ |
| 332 | stats.global, \ |
| 333 | stats.shared, \ |
| 334 | stats.unbound); \ |
| 335 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 336 | |
| 337 | static void print_batch_pool_stats(struct seq_file *m, |
| 338 | struct drm_i915_private *dev_priv) |
| 339 | { |
| 340 | struct drm_i915_gem_object *obj; |
| 341 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 342 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 343 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 344 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 345 | |
| 346 | memset(&stats, 0, sizeof(stats)); |
| 347 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 348 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 349 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 350 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 351 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 352 | batch_pool_link) |
| 353 | per_file_stats(0, obj, &stats); |
| 354 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 355 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 356 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 357 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 358 | } |
| 359 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 360 | static int per_file_ctx_stats(int id, void *ptr, void *data) |
| 361 | { |
| 362 | struct i915_gem_context *ctx = ptr; |
| 363 | int n; |
| 364 | |
| 365 | for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) { |
| 366 | if (ctx->engine[n].state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 367 | per_file_stats(0, ctx->engine[n].state->obj, data); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 368 | if (ctx->engine[n].ring) |
Chris Wilson | 57e8853 | 2016-08-15 10:48:57 +0100 | [diff] [blame] | 369 | per_file_stats(0, ctx->engine[n].ring->vma->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | static void print_context_stats(struct seq_file *m, |
| 376 | struct drm_i915_private *dev_priv) |
| 377 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 378 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 379 | struct file_stats stats; |
| 380 | struct drm_file *file; |
| 381 | |
| 382 | memset(&stats, 0, sizeof(stats)); |
| 383 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 384 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 385 | if (dev_priv->kernel_context) |
| 386 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 387 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 388 | list_for_each_entry(file, &dev->filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 389 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 390 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 391 | } |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 392 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 393 | |
| 394 | print_file_stats(m, "[k]contexts", stats); |
| 395 | } |
| 396 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 397 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 398 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 399 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 400 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 401 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 402 | u32 count, mapped_count, purgeable_count, dpy_count; |
| 403 | u64 size, mapped_size, purgeable_size, dpy_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 404 | struct drm_i915_gem_object *obj; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 405 | struct drm_file *file; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 406 | int ret; |
| 407 | |
| 408 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 409 | if (ret) |
| 410 | return ret; |
| 411 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 412 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 413 | dev_priv->mm.object_count, |
| 414 | dev_priv->mm.object_memory); |
| 415 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 416 | size = count = 0; |
| 417 | mapped_size = mapped_count = 0; |
| 418 | purgeable_size = purgeable_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 419 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 420 | size += obj->base.size; |
| 421 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 422 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 423 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 424 | purgeable_size += obj->base.size; |
| 425 | ++purgeable_count; |
| 426 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 427 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 428 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 429 | mapped_count++; |
| 430 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 431 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 432 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 433 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 434 | |
| 435 | size = count = dpy_size = dpy_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 436 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 437 | size += obj->base.size; |
| 438 | ++count; |
| 439 | |
| 440 | if (obj->pin_display) { |
| 441 | dpy_size += obj->base.size; |
| 442 | ++dpy_count; |
| 443 | } |
| 444 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 445 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 446 | purgeable_size += obj->base.size; |
| 447 | ++purgeable_count; |
| 448 | } |
| 449 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 450 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 451 | mapped_count++; |
| 452 | mapped_size += obj->base.size; |
| 453 | } |
| 454 | } |
| 455 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 456 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 457 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 458 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 459 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 460 | mapped_count, mapped_size); |
| 461 | seq_printf(m, "%u display objects (pinned), %llu bytes\n", |
| 462 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 463 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 464 | seq_printf(m, "%llu [%llu] gtt total\n", |
Chris Wilson | 381b943 | 2017-02-15 08:43:54 +0000 | [diff] [blame] | 465 | ggtt->base.total, ggtt->mappable_end); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 466 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 467 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 468 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 469 | mutex_unlock(&dev->struct_mutex); |
| 470 | |
| 471 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 472 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 473 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 474 | struct file_stats stats; |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 475 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 476 | struct drm_i915_gem_request *request; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 477 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 478 | |
| 479 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 480 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 481 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 482 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 483 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 484 | /* |
| 485 | * Although we have a valid reference on file->pid, that does |
| 486 | * not guarantee that the task_struct who called get_pid() is |
| 487 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 488 | * Therefore, we need to protect this ->comm access using RCU. |
| 489 | */ |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 490 | mutex_lock(&dev->struct_mutex); |
| 491 | request = list_first_entry_or_null(&file_priv->mm.request_list, |
| 492 | struct drm_i915_gem_request, |
Chris Wilson | c8659ef | 2017-03-02 12:25:25 +0000 | [diff] [blame] | 493 | client_link); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 494 | rcu_read_lock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 495 | task = pid_task(request && request->ctx->pid ? |
| 496 | request->ctx->pid : file->pid, |
| 497 | PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 498 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 499 | rcu_read_unlock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 500 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 501 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 502 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 503 | |
| 504 | return 0; |
| 505 | } |
| 506 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 507 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 508 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 509 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 510 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 511 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 5f4b091 | 2016-08-19 12:56:25 +0100 | [diff] [blame] | 512 | bool show_pin_display_only = !!node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 513 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 514 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 515 | int count, ret; |
| 516 | |
| 517 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 518 | if (ret) |
| 519 | return ret; |
| 520 | |
| 521 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 522 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 523 | if (show_pin_display_only && !obj->pin_display) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 524 | continue; |
| 525 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 526 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 527 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 528 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 529 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 530 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 531 | count++; |
| 532 | } |
| 533 | |
| 534 | mutex_unlock(&dev->struct_mutex); |
| 535 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 536 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 537 | count, total_obj_size, total_gtt_size); |
| 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 542 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 543 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 544 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 545 | struct drm_device *dev = &dev_priv->drm; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 546 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 547 | int ret; |
| 548 | |
| 549 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 550 | if (ret) |
| 551 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 552 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 553 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 554 | const char pipe = pipe_name(crtc->pipe); |
| 555 | const char plane = plane_name(crtc->plane); |
Maarten Lankhorst | 51cbaf0 | 2016-05-17 15:07:49 +0200 | [diff] [blame] | 556 | struct intel_flip_work *work; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 557 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 558 | spin_lock_irq(&dev->event_lock); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 559 | work = crtc->flip_work; |
| 560 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 561 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 562 | pipe, plane); |
| 563 | } else { |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 564 | u32 pending; |
| 565 | u32 addr; |
| 566 | |
| 567 | pending = atomic_read(&work->pending); |
| 568 | if (pending) { |
| 569 | seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n", |
| 570 | pipe, plane); |
| 571 | } else { |
| 572 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
| 573 | pipe, plane); |
| 574 | } |
| 575 | if (work->flip_queued_req) { |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 576 | struct intel_engine_cs *engine = work->flip_queued_req->engine; |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 577 | |
Chris Wilson | 312c3c4 | 2016-11-24 14:47:50 +0000 | [diff] [blame] | 578 | 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] | 579 | engine->name, |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 580 | work->flip_queued_req->global_seqno, |
Chris Wilson | 312c3c4 | 2016-11-24 14:47:50 +0000 | [diff] [blame] | 581 | intel_engine_last_submit(engine), |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 582 | intel_engine_get_seqno(engine), |
Chris Wilson | f69a02c | 2016-07-01 17:23:16 +0100 | [diff] [blame] | 583 | i915_gem_request_completed(work->flip_queued_req)); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 584 | } else |
| 585 | seq_printf(m, "Flip not associated with any ring\n"); |
| 586 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 587 | work->flip_queued_vblank, |
| 588 | work->flip_ready_vblank, |
| 589 | intel_crtc_get_vblank_counter(crtc)); |
| 590 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
| 591 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 592 | if (INTEL_GEN(dev_priv) >= 4) |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 593 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 594 | else |
| 595 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 596 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 597 | |
| 598 | if (work->pending_flip_obj) { |
| 599 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 600 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 601 | } |
| 602 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 603 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 604 | } |
| 605 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 606 | mutex_unlock(&dev->struct_mutex); |
| 607 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 608 | return 0; |
| 609 | } |
| 610 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 611 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 612 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 613 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 614 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 615 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 616 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 617 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 618 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 619 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 620 | |
| 621 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 622 | if (ret) |
| 623 | return ret; |
| 624 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 625 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 626 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 627 | int count; |
| 628 | |
| 629 | count = 0; |
| 630 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 631 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 632 | batch_pool_link) |
| 633 | count++; |
| 634 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 635 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 636 | |
| 637 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 638 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 639 | batch_pool_link) { |
| 640 | seq_puts(m, " "); |
| 641 | describe_obj(m, obj); |
| 642 | seq_putc(m, '\n'); |
| 643 | } |
| 644 | |
| 645 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 646 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 647 | } |
| 648 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 649 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 650 | |
| 651 | mutex_unlock(&dev->struct_mutex); |
| 652 | |
| 653 | return 0; |
| 654 | } |
| 655 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 656 | static void print_request(struct seq_file *m, |
| 657 | struct drm_i915_gem_request *rq, |
| 658 | const char *prefix) |
| 659 | { |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 660 | 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] | 661 | rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno, |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 662 | rq->priotree.priority, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 663 | jiffies_to_msecs(jiffies - rq->emitted_jiffies), |
Chris Wilson | 562f5d4 | 2016-10-28 13:58:54 +0100 | [diff] [blame] | 664 | rq->timeline->common->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 665 | } |
| 666 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 667 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 668 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 669 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 670 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 671 | struct drm_i915_gem_request *req; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 672 | struct intel_engine_cs *engine; |
| 673 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 674 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 675 | |
| 676 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 677 | if (ret) |
| 678 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 679 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 680 | any = 0; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 681 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 682 | int count; |
| 683 | |
| 684 | count = 0; |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 685 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 686 | count++; |
| 687 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 688 | continue; |
| 689 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 690 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 691 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 692 | print_request(m, req, " "); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 693 | |
| 694 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 695 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 696 | mutex_unlock(&dev->struct_mutex); |
| 697 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 698 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 699 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 700 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 701 | return 0; |
| 702 | } |
| 703 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 704 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 705 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 706 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 707 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 708 | struct rb_node *rb; |
| 709 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 710 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 711 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 712 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 713 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 714 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 715 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 716 | |
| 717 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 718 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 719 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 720 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 721 | } |
| 722 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 723 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 724 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 725 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 726 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 727 | enum intel_engine_id id; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 728 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 729 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 730 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 731 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | |
| 736 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 737 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 738 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 739 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 740 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 741 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 742 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 743 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 744 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 745 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 746 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 747 | I915_READ(GEN8_MASTER_IRQ)); |
| 748 | |
| 749 | seq_printf(m, "Display IER:\t%08x\n", |
| 750 | I915_READ(VLV_IER)); |
| 751 | seq_printf(m, "Display IIR:\t%08x\n", |
| 752 | I915_READ(VLV_IIR)); |
| 753 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 754 | I915_READ(VLV_IIR_RW)); |
| 755 | seq_printf(m, "Display IMR:\t%08x\n", |
| 756 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 757 | for_each_pipe(dev_priv, pipe) { |
| 758 | enum intel_display_power_domain power_domain; |
| 759 | |
| 760 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 761 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 762 | power_domain)) { |
| 763 | seq_printf(m, "Pipe %c power disabled\n", |
| 764 | pipe_name(pipe)); |
| 765 | continue; |
| 766 | } |
| 767 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 768 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 769 | pipe_name(pipe), |
| 770 | I915_READ(PIPESTAT(pipe))); |
| 771 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 772 | intel_display_power_put(dev_priv, power_domain); |
| 773 | } |
| 774 | |
| 775 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 776 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 777 | I915_READ(PORT_HOTPLUG_EN)); |
| 778 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 779 | I915_READ(VLV_DPFLIPSTAT)); |
| 780 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 781 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 782 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 783 | |
| 784 | for (i = 0; i < 4; i++) { |
| 785 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 786 | i, I915_READ(GEN8_GT_IMR(i))); |
| 787 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 788 | i, I915_READ(GEN8_GT_IIR(i))); |
| 789 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 790 | i, I915_READ(GEN8_GT_IER(i))); |
| 791 | } |
| 792 | |
| 793 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 794 | I915_READ(GEN8_PCU_IMR)); |
| 795 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 796 | I915_READ(GEN8_PCU_IIR)); |
| 797 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 798 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 799 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 800 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 801 | I915_READ(GEN8_MASTER_IRQ)); |
| 802 | |
| 803 | for (i = 0; i < 4; i++) { |
| 804 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 805 | i, I915_READ(GEN8_GT_IMR(i))); |
| 806 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 807 | i, I915_READ(GEN8_GT_IIR(i))); |
| 808 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 809 | i, I915_READ(GEN8_GT_IER(i))); |
| 810 | } |
| 811 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 812 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 813 | enum intel_display_power_domain power_domain; |
| 814 | |
| 815 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 816 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 817 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 818 | seq_printf(m, "Pipe %c power disabled\n", |
| 819 | pipe_name(pipe)); |
| 820 | continue; |
| 821 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 822 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 823 | pipe_name(pipe), |
| 824 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 825 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 826 | pipe_name(pipe), |
| 827 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 828 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 829 | pipe_name(pipe), |
| 830 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 831 | |
| 832 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 836 | I915_READ(GEN8_DE_PORT_IMR)); |
| 837 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 838 | I915_READ(GEN8_DE_PORT_IIR)); |
| 839 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 840 | I915_READ(GEN8_DE_PORT_IER)); |
| 841 | |
| 842 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 843 | I915_READ(GEN8_DE_MISC_IMR)); |
| 844 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 845 | I915_READ(GEN8_DE_MISC_IIR)); |
| 846 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 847 | I915_READ(GEN8_DE_MISC_IER)); |
| 848 | |
| 849 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 850 | I915_READ(GEN8_PCU_IMR)); |
| 851 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 852 | I915_READ(GEN8_PCU_IIR)); |
| 853 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 854 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 855 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 856 | seq_printf(m, "Display IER:\t%08x\n", |
| 857 | I915_READ(VLV_IER)); |
| 858 | seq_printf(m, "Display IIR:\t%08x\n", |
| 859 | I915_READ(VLV_IIR)); |
| 860 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 861 | I915_READ(VLV_IIR_RW)); |
| 862 | seq_printf(m, "Display IMR:\t%08x\n", |
| 863 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 864 | for_each_pipe(dev_priv, pipe) { |
| 865 | enum intel_display_power_domain power_domain; |
| 866 | |
| 867 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 868 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 869 | power_domain)) { |
| 870 | seq_printf(m, "Pipe %c power disabled\n", |
| 871 | pipe_name(pipe)); |
| 872 | continue; |
| 873 | } |
| 874 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 875 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 876 | pipe_name(pipe), |
| 877 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 878 | intel_display_power_put(dev_priv, power_domain); |
| 879 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 880 | |
| 881 | seq_printf(m, "Master IER:\t%08x\n", |
| 882 | I915_READ(VLV_MASTER_IER)); |
| 883 | |
| 884 | seq_printf(m, "Render IER:\t%08x\n", |
| 885 | I915_READ(GTIER)); |
| 886 | seq_printf(m, "Render IIR:\t%08x\n", |
| 887 | I915_READ(GTIIR)); |
| 888 | seq_printf(m, "Render IMR:\t%08x\n", |
| 889 | I915_READ(GTIMR)); |
| 890 | |
| 891 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 892 | I915_READ(GEN6_PMIER)); |
| 893 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 894 | I915_READ(GEN6_PMIIR)); |
| 895 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 896 | I915_READ(GEN6_PMIMR)); |
| 897 | |
| 898 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 899 | I915_READ(PORT_HOTPLUG_EN)); |
| 900 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 901 | I915_READ(VLV_DPFLIPSTAT)); |
| 902 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 903 | I915_READ(DPINVGTT)); |
| 904 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 905 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 906 | seq_printf(m, "Interrupt enable: %08x\n", |
| 907 | I915_READ(IER)); |
| 908 | seq_printf(m, "Interrupt identity: %08x\n", |
| 909 | I915_READ(IIR)); |
| 910 | seq_printf(m, "Interrupt mask: %08x\n", |
| 911 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 912 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 913 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 914 | pipe_name(pipe), |
| 915 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 916 | } else { |
| 917 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 918 | I915_READ(DEIER)); |
| 919 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 920 | I915_READ(DEIIR)); |
| 921 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 922 | I915_READ(DEIMR)); |
| 923 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 924 | I915_READ(SDEIER)); |
| 925 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 926 | I915_READ(SDEIIR)); |
| 927 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 928 | I915_READ(SDEIMR)); |
| 929 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 930 | I915_READ(GTIER)); |
| 931 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 932 | I915_READ(GTIIR)); |
| 933 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 934 | I915_READ(GTIMR)); |
| 935 | } |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 936 | for_each_engine(engine, dev_priv, id) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 937 | if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 938 | seq_printf(m, |
| 939 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 940 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 941 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 942 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 943 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 944 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 945 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 946 | return 0; |
| 947 | } |
| 948 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 949 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 950 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 951 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 952 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 953 | int i, ret; |
| 954 | |
| 955 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 956 | if (ret) |
| 957 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 958 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 959 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 960 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 961 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 962 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 963 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 964 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 965 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 966 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 967 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 968 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 969 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 970 | } |
| 971 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 972 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 973 | return 0; |
| 974 | } |
| 975 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 976 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 977 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 978 | size_t count, loff_t *pos) |
| 979 | { |
| 980 | struct i915_gpu_state *error = file->private_data; |
| 981 | struct drm_i915_error_state_buf str; |
| 982 | ssize_t ret; |
| 983 | loff_t tmp; |
| 984 | |
| 985 | if (!error) |
| 986 | return 0; |
| 987 | |
| 988 | ret = i915_error_state_buf_init(&str, error->i915, count, *pos); |
| 989 | if (ret) |
| 990 | return ret; |
| 991 | |
| 992 | ret = i915_error_state_to_str(&str, error); |
| 993 | if (ret) |
| 994 | goto out; |
| 995 | |
| 996 | tmp = 0; |
| 997 | ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes); |
| 998 | if (ret < 0) |
| 999 | goto out; |
| 1000 | |
| 1001 | *pos = str.start + ret; |
| 1002 | out: |
| 1003 | i915_error_state_buf_release(&str); |
| 1004 | return ret; |
| 1005 | } |
| 1006 | |
| 1007 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 1008 | { |
| 1009 | i915_gpu_state_put(file->private_data); |
| 1010 | return 0; |
| 1011 | } |
| 1012 | |
| 1013 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 1014 | { |
| 1015 | struct i915_gpu_state *gpu; |
| 1016 | |
| 1017 | gpu = i915_capture_gpu_state(inode->i_private); |
| 1018 | if (!gpu) |
| 1019 | return -ENOMEM; |
| 1020 | |
| 1021 | file->private_data = gpu; |
| 1022 | return 0; |
| 1023 | } |
| 1024 | |
| 1025 | static const struct file_operations i915_gpu_info_fops = { |
| 1026 | .owner = THIS_MODULE, |
| 1027 | .open = i915_gpu_info_open, |
| 1028 | .read = gpu_state_read, |
| 1029 | .llseek = default_llseek, |
| 1030 | .release = gpu_state_release, |
| 1031 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1032 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1033 | static ssize_t |
| 1034 | i915_error_state_write(struct file *filp, |
| 1035 | const char __user *ubuf, |
| 1036 | size_t cnt, |
| 1037 | loff_t *ppos) |
| 1038 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1039 | struct i915_gpu_state *error = filp->private_data; |
| 1040 | |
| 1041 | if (!error) |
| 1042 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1043 | |
| 1044 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1045 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1046 | |
| 1047 | return cnt; |
| 1048 | } |
| 1049 | |
| 1050 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1051 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1052 | file->private_data = i915_first_error_state(inode->i_private); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1053 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1054 | } |
| 1055 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1056 | static const struct file_operations i915_error_state_fops = { |
| 1057 | .owner = THIS_MODULE, |
| 1058 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1059 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1060 | .write = i915_error_state_write, |
| 1061 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1062 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1063 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1064 | #endif |
| 1065 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1066 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1067 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1068 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1069 | struct drm_i915_private *dev_priv = data; |
| 1070 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1071 | int ret; |
| 1072 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1073 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1074 | if (ret) |
| 1075 | return ret; |
| 1076 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1077 | ret = i915_gem_set_global_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1078 | mutex_unlock(&dev->struct_mutex); |
| 1079 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1080 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1081 | } |
| 1082 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1083 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
Chris Wilson | 9b6586a | 2017-02-23 07:44:08 +0000 | [diff] [blame] | 1084 | NULL, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1085 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1086 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1087 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1088 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1089 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1090 | int ret = 0; |
| 1091 | |
| 1092 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1093 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1094 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1095 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1096 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1097 | |
| 1098 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1099 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1100 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1101 | MEMSTAT_VID_SHIFT); |
| 1102 | seq_printf(m, "Current P-state: %d\n", |
| 1103 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1104 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1105 | u32 freq_sts; |
| 1106 | |
| 1107 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1108 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1109 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1110 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1111 | |
| 1112 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1113 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1114 | |
| 1115 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1116 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1117 | |
| 1118 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1119 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1120 | |
| 1121 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1122 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1123 | |
| 1124 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1125 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1126 | |
| 1127 | seq_printf(m, |
| 1128 | "efficient (RPe) frequency: %d MHz\n", |
| 1129 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1130 | mutex_unlock(&dev_priv->rps.hw_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1131 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1132 | u32 rp_state_limits; |
| 1133 | u32 gt_perf_status; |
| 1134 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1135 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1136 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1137 | u32 rpupei, rpcurup, rpprevup; |
| 1138 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1139 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1140 | int max_freq; |
| 1141 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1142 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1143 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1144 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1145 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1146 | } else { |
| 1147 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1148 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1149 | } |
| 1150 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1151 | /* RPSTAT1 is in the GT power well */ |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1152 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1153 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1154 | reqf = I915_READ(GEN6_RPNSWREQ); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1155 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1156 | reqf >>= 23; |
| 1157 | else { |
| 1158 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1159 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1160 | reqf >>= 24; |
| 1161 | else |
| 1162 | reqf >>= 25; |
| 1163 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1164 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1165 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1166 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1167 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1168 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1169 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1170 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1171 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1172 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1173 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1174 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1175 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1176 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1177 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1178 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1179 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1180 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1181 | else |
| 1182 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1183 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1184 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1185 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1186 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1187 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1188 | pm_ier = I915_READ(GEN6_PMIER); |
| 1189 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1190 | pm_isr = I915_READ(GEN6_PMISR); |
| 1191 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1192 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1193 | } else { |
| 1194 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1195 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1196 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1197 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1198 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1199 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1200 | 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] | 1201 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1202 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
| 1203 | dev_priv->rps.pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1204 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1205 | seq_printf(m, "Render p-state ratio: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1206 | (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1207 | seq_printf(m, "Render p-state VID: %d\n", |
| 1208 | gt_perf_status & 0xff); |
| 1209 | seq_printf(m, "Render p-state limit: %d\n", |
| 1210 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1211 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1212 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1213 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1214 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1215 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1216 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1217 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1218 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1219 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1220 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1221 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1222 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1223 | seq_printf(m, "Up threshold: %d%%\n", |
| 1224 | dev_priv->rps.up_threshold); |
| 1225 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1226 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1227 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1228 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1229 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1230 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1231 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1232 | seq_printf(m, "Down threshold: %d%%\n", |
| 1233 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1234 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1235 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1236 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1237 | max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1238 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1239 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1240 | |
| 1241 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1242 | max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1243 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1244 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1245 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1246 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1247 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1248 | max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1249 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1250 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1251 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1252 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1253 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1254 | seq_printf(m, "Current freq: %d MHz\n", |
| 1255 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1256 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1257 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1258 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1259 | seq_printf(m, "Min freq: %d MHz\n", |
| 1260 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1261 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1262 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1263 | seq_printf(m, "Max freq: %d MHz\n", |
| 1264 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1265 | seq_printf(m, |
| 1266 | "efficient (RPe) frequency: %d MHz\n", |
| 1267 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1268 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1269 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1270 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1271 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1272 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk.hw.cdclk); |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1273 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1274 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1275 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1276 | intel_runtime_pm_put(dev_priv); |
| 1277 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1278 | } |
| 1279 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1280 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1281 | struct seq_file *m, |
| 1282 | struct intel_instdone *instdone) |
| 1283 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1284 | int slice; |
| 1285 | int subslice; |
| 1286 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1287 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1288 | instdone->instdone); |
| 1289 | |
| 1290 | if (INTEL_GEN(dev_priv) <= 3) |
| 1291 | return; |
| 1292 | |
| 1293 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1294 | instdone->slice_common); |
| 1295 | |
| 1296 | if (INTEL_GEN(dev_priv) <= 6) |
| 1297 | return; |
| 1298 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1299 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1300 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1301 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1302 | |
| 1303 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1304 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1305 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1306 | } |
| 1307 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1308 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1309 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1310 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1311 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1312 | u64 acthd[I915_NUM_ENGINES]; |
| 1313 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1314 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1315 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1316 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1317 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1318 | seq_puts(m, "Wedged\n"); |
| 1319 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
| 1320 | seq_puts(m, "Reset in progress: struct_mutex backoff\n"); |
| 1321 | if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags)) |
| 1322 | seq_puts(m, "Reset in progress: reset handoff to waiter\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1323 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1324 | seq_puts(m, "Waiter holding struct mutex\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1325 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1326 | seq_puts(m, "struct_mutex blocked for reset\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1327 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1328 | if (!i915.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1329 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1330 | return 0; |
| 1331 | } |
| 1332 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1333 | intel_runtime_pm_get(dev_priv); |
| 1334 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1335 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1336 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1337 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1338 | } |
| 1339 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1340 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1341 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1342 | intel_runtime_pm_put(dev_priv); |
| 1343 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1344 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1345 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1346 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1347 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1348 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1349 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1350 | else |
| 1351 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1352 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1353 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1354 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1355 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1356 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1357 | struct rb_node *rb; |
| 1358 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1359 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1360 | seq_printf(m, "\tseqno = %x [current %x, last %x], inflight %d\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1361 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1362 | intel_engine_last_submit(engine), |
| 1363 | engine->timeline->inflight_seqnos); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1364 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1365 | yesno(intel_engine_has_waiter(engine)), |
| 1366 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1367 | &dev_priv->gpu_error.missed_irq_rings)), |
| 1368 | yesno(engine->hangcheck.stalled)); |
| 1369 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1370 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1371 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 1372 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1373 | |
| 1374 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1375 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1376 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1377 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1378 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1379 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1380 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1381 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1382 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1383 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1384 | engine->hangcheck.action, |
| 1385 | jiffies_to_msecs(jiffies - |
| 1386 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1387 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1388 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1389 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1390 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1391 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1392 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1393 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1394 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1395 | i915_instdone_info(dev_priv, m, |
| 1396 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1397 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | return 0; |
| 1401 | } |
| 1402 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1403 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1404 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1405 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1406 | u32 rgvmodectl, rstdbyctl; |
| 1407 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1408 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1409 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1410 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1411 | crstandvid = I915_READ16(CRSTANDVID); |
| 1412 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1413 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1414 | seq_printf(m, "Boost freq: %d\n", |
| 1415 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1416 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1417 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1418 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1419 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1420 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1421 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1422 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1423 | seq_printf(m, "Starting frequency: P%d\n", |
| 1424 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1425 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1426 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1427 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1428 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1429 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1430 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1431 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1432 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1433 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1434 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1435 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1436 | break; |
| 1437 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1438 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1439 | break; |
| 1440 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1441 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1442 | break; |
| 1443 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1444 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1445 | break; |
| 1446 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1447 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1448 | break; |
| 1449 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1450 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1451 | break; |
| 1452 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1453 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1454 | break; |
| 1455 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1456 | |
| 1457 | return 0; |
| 1458 | } |
| 1459 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1460 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1461 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1462 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1463 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1464 | |
| 1465 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1466 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1467 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1468 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1469 | fw_domain->wake_count); |
| 1470 | } |
| 1471 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1472 | |
| 1473 | return 0; |
| 1474 | } |
| 1475 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1476 | static void print_rc6_res(struct seq_file *m, |
| 1477 | const char *title, |
| 1478 | const i915_reg_t reg) |
| 1479 | { |
| 1480 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1481 | |
| 1482 | seq_printf(m, "%s %u (%llu us)\n", |
| 1483 | title, I915_READ(reg), |
| 1484 | intel_rc6_residency_us(dev_priv, reg)); |
| 1485 | } |
| 1486 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1487 | static int vlv_drpc_info(struct seq_file *m) |
| 1488 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1489 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1490 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1491 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1492 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1493 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1494 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1495 | |
| 1496 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1497 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1498 | seq_printf(m, "Turbo enabled: %s\n", |
| 1499 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1500 | seq_printf(m, "HW control enabled: %s\n", |
| 1501 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1502 | seq_printf(m, "SW control enabled: %s\n", |
| 1503 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1504 | GEN6_RP_MEDIA_SW_MODE)); |
| 1505 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1506 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1507 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1508 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1509 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1510 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1511 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1512 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1513 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1514 | print_rc6_res(m, "Media RC6 residency since boot:", VLV_GT_MEDIA_RC6); |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1515 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1516 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1517 | } |
| 1518 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1519 | static int gen6_drpc_info(struct seq_file *m) |
| 1520 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1521 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1522 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1523 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1524 | unsigned forcewake_count; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1525 | int count = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1526 | |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1527 | forcewake_count = READ_ONCE(dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1528 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1529 | seq_puts(m, "RC information inaccurate because somebody " |
| 1530 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1531 | } else { |
| 1532 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1533 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1534 | udelay(10); |
| 1535 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1536 | } |
| 1537 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1538 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1539 | 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] | 1540 | |
| 1541 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1542 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1543 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1544 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1545 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1546 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1547 | |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1548 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1549 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1550 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1551 | |
| 1552 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1553 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1554 | seq_printf(m, "HW control enabled: %s\n", |
| 1555 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1556 | seq_printf(m, "SW control enabled: %s\n", |
| 1557 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1558 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1559 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1560 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1561 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1562 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1563 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1564 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1565 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1566 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1567 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1568 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1569 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1570 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1571 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1572 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1573 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1574 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1575 | case GEN6_RC0: |
| 1576 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1577 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1578 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1579 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1580 | break; |
| 1581 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1582 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1583 | break; |
| 1584 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1585 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1586 | break; |
| 1587 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1588 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1589 | break; |
| 1590 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1591 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1592 | break; |
| 1593 | } |
| 1594 | |
| 1595 | seq_printf(m, "Core Power Down: %s\n", |
| 1596 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1597 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1598 | seq_printf(m, "Render Power Well: %s\n", |
| 1599 | (gen9_powergate_status & |
| 1600 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1601 | seq_printf(m, "Media Power Well: %s\n", |
| 1602 | (gen9_powergate_status & |
| 1603 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1604 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1605 | |
| 1606 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1607 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1608 | GEN6_GT_GFX_RC6_LOCKED); |
| 1609 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1610 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1611 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1612 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1613 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1614 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1615 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1616 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1617 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1618 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1619 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1620 | } |
| 1621 | |
| 1622 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1623 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1624 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1625 | int err; |
| 1626 | |
| 1627 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1628 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1629 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1630 | err = vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1631 | else if (INTEL_GEN(dev_priv) >= 6) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1632 | err = gen6_drpc_info(m); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1633 | else |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1634 | err = ironlake_drpc_info(m); |
| 1635 | |
| 1636 | intel_runtime_pm_put(dev_priv); |
| 1637 | |
| 1638 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1639 | } |
| 1640 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1641 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1642 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1643 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1644 | |
| 1645 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1646 | dev_priv->fb_tracking.busy_bits); |
| 1647 | |
| 1648 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1649 | dev_priv->fb_tracking.flip_bits); |
| 1650 | |
| 1651 | return 0; |
| 1652 | } |
| 1653 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1654 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1655 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1656 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1657 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1658 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1659 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1660 | return 0; |
| 1661 | } |
| 1662 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1663 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1664 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1665 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1666 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1667 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1668 | else |
| 1669 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1670 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1671 | |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1672 | if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) { |
| 1673 | uint32_t mask = INTEL_GEN(dev_priv) >= 8 ? |
| 1674 | BDW_FBC_COMPRESSION_MASK : |
| 1675 | IVB_FBC_COMPRESSION_MASK; |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1676 | seq_printf(m, "Compressing: %s\n", |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1677 | yesno(I915_READ(FBC_STATUS2) & mask)); |
| 1678 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1679 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1680 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1681 | intel_runtime_pm_put(dev_priv); |
| 1682 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1683 | return 0; |
| 1684 | } |
| 1685 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1686 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1687 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1688 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1689 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1690 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1691 | return -ENODEV; |
| 1692 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1693 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1694 | |
| 1695 | return 0; |
| 1696 | } |
| 1697 | |
| 1698 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1699 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1700 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1701 | u32 reg; |
| 1702 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1703 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1704 | return -ENODEV; |
| 1705 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1706 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1707 | |
| 1708 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1709 | dev_priv->fbc.false_color = val; |
| 1710 | |
| 1711 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1712 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1713 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1714 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1715 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1716 | return 0; |
| 1717 | } |
| 1718 | |
| 1719 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1720 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1721 | "%llu\n"); |
| 1722 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1723 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1724 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1725 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1726 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1727 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1728 | seq_puts(m, "not supported\n"); |
| 1729 | return 0; |
| 1730 | } |
| 1731 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1732 | intel_runtime_pm_get(dev_priv); |
| 1733 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1734 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1735 | yesno(i915.enable_ips)); |
| 1736 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1737 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1738 | seq_puts(m, "Currently: unknown\n"); |
| 1739 | } else { |
| 1740 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1741 | seq_puts(m, "Currently: enabled\n"); |
| 1742 | else |
| 1743 | seq_puts(m, "Currently: disabled\n"); |
| 1744 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1745 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1746 | intel_runtime_pm_put(dev_priv); |
| 1747 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1748 | return 0; |
| 1749 | } |
| 1750 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1751 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1752 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1753 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1754 | bool sr_enabled = false; |
| 1755 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1756 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1757 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1758 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1759 | if (INTEL_GEN(dev_priv) >= 9) |
| 1760 | /* no global SR status; inspect per-plane WM */; |
| 1761 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1762 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1763 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1764 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1765 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1766 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1767 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1768 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1769 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1770 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1771 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1772 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1773 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1774 | intel_runtime_pm_put(dev_priv); |
| 1775 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1776 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1777 | |
| 1778 | return 0; |
| 1779 | } |
| 1780 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1781 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1782 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1783 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1784 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1785 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1786 | int ret; |
| 1787 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1788 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1789 | return -ENODEV; |
| 1790 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1791 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1792 | if (ret) |
| 1793 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1794 | |
| 1795 | temp = i915_mch_val(dev_priv); |
| 1796 | chipset = i915_chipset_val(dev_priv); |
| 1797 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1798 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1799 | |
| 1800 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1801 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1802 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1803 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1804 | |
| 1805 | return 0; |
| 1806 | } |
| 1807 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1808 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1809 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1810 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1811 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1812 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1813 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1814 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1815 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1816 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1817 | return 0; |
| 1818 | } |
| 1819 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1820 | intel_runtime_pm_get(dev_priv); |
| 1821 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1822 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1823 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1824 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1825 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1826 | if (IS_GEN9_BC(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1827 | /* Convert GT frequency to 50 HZ units */ |
| 1828 | min_gpu_freq = |
| 1829 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1830 | max_gpu_freq = |
| 1831 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1832 | } else { |
| 1833 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1834 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1835 | } |
| 1836 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1837 | 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] | 1838 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1839 | 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] | 1840 | ia_freq = gpu_freq; |
| 1841 | sandybridge_pcode_read(dev_priv, |
| 1842 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1843 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1844 | 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] | 1845 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1846 | (IS_GEN9_BC(dev_priv) ? |
| 1847 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1848 | ((ia_freq >> 0) & 0xff) * 100, |
| 1849 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1850 | } |
| 1851 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1852 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1853 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1854 | out: |
| 1855 | intel_runtime_pm_put(dev_priv); |
| 1856 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1857 | } |
| 1858 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1859 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1860 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1861 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1862 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1863 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1864 | int ret; |
| 1865 | |
| 1866 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1867 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1868 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1869 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1870 | if (opregion->header) |
| 1871 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1872 | |
| 1873 | mutex_unlock(&dev->struct_mutex); |
| 1874 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1875 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1876 | return 0; |
| 1877 | } |
| 1878 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1879 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1880 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1881 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1882 | |
| 1883 | if (opregion->vbt) |
| 1884 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1885 | |
| 1886 | return 0; |
| 1887 | } |
| 1888 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1889 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1890 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1891 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1892 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1893 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1894 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1895 | int ret; |
| 1896 | |
| 1897 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1898 | if (ret) |
| 1899 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1900 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1901 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1902 | if (dev_priv->fbdev) { |
| 1903 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1904 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1905 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1906 | fbdev_fb->base.width, |
| 1907 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1908 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1909 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1910 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1911 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1912 | describe_obj(m, fbdev_fb->obj); |
| 1913 | seq_putc(m, '\n'); |
| 1914 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1915 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1916 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1917 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1918 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1919 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1920 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1921 | continue; |
| 1922 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1923 | 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] | 1924 | fb->base.width, |
| 1925 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1926 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1927 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1928 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1929 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1930 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1931 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1932 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1933 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1934 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1935 | |
| 1936 | return 0; |
| 1937 | } |
| 1938 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1939 | 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] | 1940 | { |
Chris Wilson | fe085f1 | 2017-03-21 10:25:52 +0000 | [diff] [blame^] | 1941 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)", |
| 1942 | ring->space, ring->head, ring->tail); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1943 | } |
| 1944 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1945 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1946 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1947 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1948 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1949 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1950 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1951 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1952 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1953 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1954 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1955 | if (ret) |
| 1956 | return ret; |
| 1957 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1958 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1959 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1960 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1961 | struct task_struct *task; |
| 1962 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1963 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1964 | if (task) { |
| 1965 | seq_printf(m, "(%s [%d]) ", |
| 1966 | task->comm, task->pid); |
| 1967 | put_task_struct(task); |
| 1968 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1969 | } else if (IS_ERR(ctx->file_priv)) { |
| 1970 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1971 | } else { |
| 1972 | seq_puts(m, "(kernel) "); |
| 1973 | } |
| 1974 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1975 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1976 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1977 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1978 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1979 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 1980 | |
| 1981 | seq_printf(m, "%s: ", engine->name); |
| 1982 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 1983 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1984 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1985 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1986 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1987 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1988 | } |
| 1989 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1990 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1991 | } |
| 1992 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1993 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1994 | |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1998 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1999 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2000 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2001 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2002 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2003 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2004 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2005 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2006 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2007 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2008 | if (!vma) { |
| 2009 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2010 | return; |
| 2011 | } |
| 2012 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2013 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 2014 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 2015 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2016 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2017 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2018 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2019 | return; |
| 2020 | } |
| 2021 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2022 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 2023 | if (page) { |
| 2024 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2025 | |
| 2026 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2027 | seq_printf(m, |
| 2028 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2029 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2030 | reg_state[j], reg_state[j + 1], |
| 2031 | reg_state[j + 2], reg_state[j + 3]); |
| 2032 | } |
| 2033 | kunmap_atomic(reg_state); |
| 2034 | } |
| 2035 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2036 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2037 | seq_putc(m, '\n'); |
| 2038 | } |
| 2039 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2040 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2041 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2042 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2043 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2044 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2045 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2046 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2047 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2048 | |
| 2049 | if (!i915.enable_execlists) { |
| 2050 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2051 | return 0; |
| 2052 | } |
| 2053 | |
| 2054 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2055 | if (ret) |
| 2056 | return ret; |
| 2057 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2058 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2059 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2060 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2061 | |
| 2062 | mutex_unlock(&dev->struct_mutex); |
| 2063 | |
| 2064 | return 0; |
| 2065 | } |
| 2066 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2067 | static const char *swizzle_string(unsigned swizzle) |
| 2068 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2069 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2070 | case I915_BIT_6_SWIZZLE_NONE: |
| 2071 | return "none"; |
| 2072 | case I915_BIT_6_SWIZZLE_9: |
| 2073 | return "bit9"; |
| 2074 | case I915_BIT_6_SWIZZLE_9_10: |
| 2075 | return "bit9/bit10"; |
| 2076 | case I915_BIT_6_SWIZZLE_9_11: |
| 2077 | return "bit9/bit11"; |
| 2078 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2079 | return "bit9/bit10/bit11"; |
| 2080 | case I915_BIT_6_SWIZZLE_9_17: |
| 2081 | return "bit9/bit17"; |
| 2082 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2083 | return "bit9/bit10/bit17"; |
| 2084 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2085 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2086 | } |
| 2087 | |
| 2088 | return "bug"; |
| 2089 | } |
| 2090 | |
| 2091 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2092 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2093 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2094 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2095 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2096 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2097 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2098 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2099 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2100 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2101 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2102 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2103 | seq_printf(m, "DDC = 0x%08x\n", |
| 2104 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2105 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2106 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2107 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2108 | I915_READ16(C0DRB3)); |
| 2109 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2110 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2111 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2112 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2113 | I915_READ(MAD_DIMM_C0)); |
| 2114 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2115 | I915_READ(MAD_DIMM_C1)); |
| 2116 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2117 | I915_READ(MAD_DIMM_C2)); |
| 2118 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2119 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2120 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2121 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2122 | I915_READ(GAMTARBMODE)); |
| 2123 | else |
| 2124 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2125 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2126 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2127 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2128 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2129 | |
| 2130 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2131 | seq_puts(m, "L-shaped memory detected\n"); |
| 2132 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2133 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2134 | |
| 2135 | return 0; |
| 2136 | } |
| 2137 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2138 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2139 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2140 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2141 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2142 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2143 | |
| 2144 | if (!ppgtt) { |
| 2145 | seq_printf(m, " no ppgtt for context %d\n", |
| 2146 | ctx->user_handle); |
| 2147 | return 0; |
| 2148 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2149 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2150 | if (i915_gem_context_is_default(ctx)) |
| 2151 | seq_puts(m, " default context:\n"); |
| 2152 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2153 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2154 | ppgtt->debug_dump(ppgtt, m); |
| 2155 | |
| 2156 | return 0; |
| 2157 | } |
| 2158 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2159 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2160 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2161 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2162 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2163 | struct intel_engine_cs *engine; |
| 2164 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2165 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2166 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2167 | if (!ppgtt) |
| 2168 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2169 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2170 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2171 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2172 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2173 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2174 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2175 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2176 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2177 | } |
| 2178 | } |
| 2179 | } |
| 2180 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2181 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2182 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2183 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2184 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2185 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2186 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2187 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2188 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2189 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2190 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2191 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2192 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2193 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2194 | I915_READ(RING_MODE_GEN7(engine))); |
| 2195 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2196 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2197 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2198 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2199 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2200 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2201 | } |
| 2202 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2203 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2204 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2205 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2206 | 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] | 2207 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2208 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2209 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2210 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2211 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2212 | } |
| 2213 | |
| 2214 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2215 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2216 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2217 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2218 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2219 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2220 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2221 | mutex_lock(&dev->filelist_mutex); |
| 2222 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2223 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2224 | goto out_unlock; |
| 2225 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2226 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2227 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2228 | if (INTEL_GEN(dev_priv) >= 8) |
| 2229 | gen8_ppgtt_info(m, dev_priv); |
| 2230 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2231 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2232 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2233 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2234 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2235 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2236 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2237 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2238 | if (!task) { |
| 2239 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2240 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2241 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2242 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2243 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2244 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2245 | (void *)(unsigned long)m); |
| 2246 | } |
| 2247 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2248 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2249 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2250 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2251 | out_unlock: |
| 2252 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2253 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2254 | } |
| 2255 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2256 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2257 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2258 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2259 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2260 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2261 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2262 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2263 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2264 | |
| 2265 | return count; |
| 2266 | } |
| 2267 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2268 | static const char *rps_power_to_str(unsigned int power) |
| 2269 | { |
| 2270 | static const char * const strings[] = { |
| 2271 | [LOW_POWER] = "low power", |
| 2272 | [BETWEEN] = "mixed", |
| 2273 | [HIGH_POWER] = "high power", |
| 2274 | }; |
| 2275 | |
| 2276 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2277 | return "unknown"; |
| 2278 | |
| 2279 | return strings[power]; |
| 2280 | } |
| 2281 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2282 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2283 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2284 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2285 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2286 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2287 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2288 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2289 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2290 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2291 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2292 | seq_printf(m, "Frequency requested %d\n", |
| 2293 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 2294 | 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] | 2295 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2296 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2297 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2298 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2299 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
| 2300 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq), |
| 2301 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
| 2302 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2303 | |
| 2304 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2305 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2306 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2307 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2308 | struct task_struct *task; |
| 2309 | |
| 2310 | rcu_read_lock(); |
| 2311 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2312 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2313 | task ? task->comm : "<unknown>", |
| 2314 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2315 | file_priv->rps.boosts, |
| 2316 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2317 | rcu_read_unlock(); |
| 2318 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2319 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2320 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2321 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2322 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2323 | if (INTEL_GEN(dev_priv) >= 6 && |
| 2324 | dev_priv->rps.enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2325 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2326 | u32 rpup, rpupei; |
| 2327 | u32 rpdown, rpdownei; |
| 2328 | |
| 2329 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2330 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2331 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2332 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2333 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2334 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2335 | |
| 2336 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
| 2337 | rps_power_to_str(dev_priv->rps.power)); |
| 2338 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2339 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2340 | dev_priv->rps.up_threshold); |
| 2341 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2342 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2343 | dev_priv->rps.down_threshold); |
| 2344 | } else { |
| 2345 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2346 | } |
| 2347 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2348 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2349 | } |
| 2350 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2351 | static int i915_llc(struct seq_file *m, void *data) |
| 2352 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2353 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2354 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2355 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2356 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2357 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2358 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2359 | |
| 2360 | return 0; |
| 2361 | } |
| 2362 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2363 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2364 | { |
| 2365 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2366 | struct intel_uc_fw *huc_fw = &dev_priv->huc.fw; |
| 2367 | |
| 2368 | if (!HAS_HUC_UCODE(dev_priv)) |
| 2369 | return 0; |
| 2370 | |
| 2371 | seq_puts(m, "HuC firmware status:\n"); |
| 2372 | seq_printf(m, "\tpath: %s\n", huc_fw->path); |
| 2373 | seq_printf(m, "\tfetch: %s\n", |
| 2374 | intel_uc_fw_status_repr(huc_fw->fetch_status)); |
| 2375 | seq_printf(m, "\tload: %s\n", |
| 2376 | intel_uc_fw_status_repr(huc_fw->load_status)); |
| 2377 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2378 | huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted); |
| 2379 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2380 | huc_fw->major_ver_found, huc_fw->minor_ver_found); |
| 2381 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2382 | huc_fw->header_offset, huc_fw->header_size); |
| 2383 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2384 | huc_fw->ucode_offset, huc_fw->ucode_size); |
| 2385 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2386 | huc_fw->rsa_offset, huc_fw->rsa_size); |
| 2387 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2388 | intel_runtime_pm_get(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2389 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2390 | intel_runtime_pm_put(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2391 | |
| 2392 | return 0; |
| 2393 | } |
| 2394 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2395 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2396 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2397 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2398 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2399 | u32 tmp, i; |
| 2400 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2401 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2402 | return 0; |
| 2403 | |
| 2404 | seq_printf(m, "GuC firmware status:\n"); |
| 2405 | seq_printf(m, "\tpath: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2406 | guc_fw->path); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2407 | seq_printf(m, "\tfetch: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2408 | intel_uc_fw_status_repr(guc_fw->fetch_status)); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2409 | seq_printf(m, "\tload: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2410 | intel_uc_fw_status_repr(guc_fw->load_status)); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2411 | seq_printf(m, "\tversion wanted: %d.%d\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2412 | guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2413 | seq_printf(m, "\tversion found: %d.%d\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2414 | guc_fw->major_ver_found, guc_fw->minor_ver_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2415 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2416 | guc_fw->header_offset, guc_fw->header_size); |
| 2417 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2418 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2419 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2420 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2421 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2422 | intel_runtime_pm_get(dev_priv); |
| 2423 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2424 | tmp = I915_READ(GUC_STATUS); |
| 2425 | |
| 2426 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2427 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2428 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2429 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2430 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2431 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2432 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2433 | seq_puts(m, "\nScratch registers:\n"); |
| 2434 | for (i = 0; i < 16; i++) |
| 2435 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2436 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2437 | intel_runtime_pm_put(dev_priv); |
| 2438 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2439 | return 0; |
| 2440 | } |
| 2441 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2442 | static void i915_guc_log_info(struct seq_file *m, |
| 2443 | struct drm_i915_private *dev_priv) |
| 2444 | { |
| 2445 | struct intel_guc *guc = &dev_priv->guc; |
| 2446 | |
| 2447 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2448 | |
| 2449 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2450 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2451 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2452 | |
| 2453 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2454 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2455 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2456 | |
| 2457 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2458 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2459 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2460 | |
| 2461 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2462 | guc->log.flush_interrupt_count); |
| 2463 | |
| 2464 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2465 | guc->log.capture_miss_count); |
| 2466 | } |
| 2467 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2468 | static void i915_guc_client_info(struct seq_file *m, |
| 2469 | struct drm_i915_private *dev_priv, |
| 2470 | struct i915_guc_client *client) |
| 2471 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2472 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2473 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2474 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2475 | |
| 2476 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2477 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2478 | 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] | 2479 | client->doorbell_id, client->doorbell_offset, client->doorbell_cookie); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2480 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2481 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2482 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2483 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2484 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2485 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2486 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2487 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2488 | u64 submissions = client->submissions[id]; |
| 2489 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2490 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2491 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2492 | } |
| 2493 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2494 | } |
| 2495 | |
| 2496 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2497 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2498 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2499 | const struct intel_guc *guc = &dev_priv->guc; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2500 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2501 | enum intel_engine_id id; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2502 | u64 total; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2503 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2504 | if (!guc->execbuf_client) { |
| 2505 | seq_printf(m, "GuC submission %s\n", |
| 2506 | HAS_GUC_SCHED(dev_priv) ? |
| 2507 | "disabled" : |
| 2508 | "not supported"); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2509 | return 0; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2510 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2511 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2512 | seq_printf(m, "Doorbell map:\n"); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2513 | seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap); |
| 2514 | 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] | 2515 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2516 | seq_printf(m, "GuC total action count: %llu\n", guc->action_count); |
| 2517 | seq_printf(m, "GuC action failure count: %u\n", guc->action_fail); |
| 2518 | seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd); |
| 2519 | seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status); |
| 2520 | 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] | 2521 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2522 | total = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2523 | seq_printf(m, "\nGuC submissions:\n"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2524 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2525 | u64 submissions = guc->submissions[id]; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2526 | total += submissions; |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2527 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2528 | engine->name, submissions, guc->last_seqno[id]); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2529 | } |
| 2530 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2531 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2532 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2533 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2534 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2535 | i915_guc_log_info(m, dev_priv); |
| 2536 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2537 | /* Add more as required ... */ |
| 2538 | |
| 2539 | return 0; |
| 2540 | } |
| 2541 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2542 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2543 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2544 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2545 | struct drm_i915_gem_object *obj; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2546 | int i = 0, pg; |
| 2547 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2548 | if (!dev_priv->guc.log.vma) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2549 | return 0; |
| 2550 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2551 | obj = dev_priv->guc.log.vma->obj; |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2552 | for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) { |
| 2553 | u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg)); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2554 | |
| 2555 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2556 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2557 | *(log + i), *(log + i + 1), |
| 2558 | *(log + i + 2), *(log + i + 3)); |
| 2559 | |
| 2560 | kunmap_atomic(log); |
| 2561 | } |
| 2562 | |
| 2563 | seq_putc(m, '\n'); |
| 2564 | |
| 2565 | return 0; |
| 2566 | } |
| 2567 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2568 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2569 | { |
| 2570 | struct drm_device *dev = data; |
| 2571 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2572 | |
| 2573 | if (!dev_priv->guc.log.vma) |
| 2574 | return -EINVAL; |
| 2575 | |
| 2576 | *val = i915.guc_log_level; |
| 2577 | |
| 2578 | return 0; |
| 2579 | } |
| 2580 | |
| 2581 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2582 | { |
| 2583 | struct drm_device *dev = data; |
| 2584 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2585 | int ret; |
| 2586 | |
| 2587 | if (!dev_priv->guc.log.vma) |
| 2588 | return -EINVAL; |
| 2589 | |
| 2590 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2591 | if (ret) |
| 2592 | return ret; |
| 2593 | |
| 2594 | intel_runtime_pm_get(dev_priv); |
| 2595 | ret = i915_guc_log_control(dev_priv, val); |
| 2596 | intel_runtime_pm_put(dev_priv); |
| 2597 | |
| 2598 | mutex_unlock(&dev->struct_mutex); |
| 2599 | return ret; |
| 2600 | } |
| 2601 | |
| 2602 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2603 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2604 | "%lld\n"); |
| 2605 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2606 | static const char *psr2_live_status(u32 val) |
| 2607 | { |
| 2608 | static const char * const live_status[] = { |
| 2609 | "IDLE", |
| 2610 | "CAPTURE", |
| 2611 | "CAPTURE_FS", |
| 2612 | "SLEEP", |
| 2613 | "BUFON_FW", |
| 2614 | "ML_UP", |
| 2615 | "SU_STANDBY", |
| 2616 | "FAST_SLEEP", |
| 2617 | "DEEP_SLEEP", |
| 2618 | "BUF_ON", |
| 2619 | "TG_ON" |
| 2620 | }; |
| 2621 | |
| 2622 | val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT; |
| 2623 | if (val < ARRAY_SIZE(live_status)) |
| 2624 | return live_status[val]; |
| 2625 | |
| 2626 | return "unknown"; |
| 2627 | } |
| 2628 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2629 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2630 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2631 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2632 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2633 | u32 stat[3]; |
| 2634 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2635 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2636 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2637 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2638 | seq_puts(m, "PSR not supported\n"); |
| 2639 | return 0; |
| 2640 | } |
| 2641 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2642 | intel_runtime_pm_get(dev_priv); |
| 2643 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2644 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2645 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2646 | 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] | 2647 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2648 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2649 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2650 | dev_priv->psr.busy_frontbuffer_bits); |
| 2651 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2652 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2653 | |
Nagaraju, Vathsala | 7e3eb59 | 2016-12-09 23:42:09 +0530 | [diff] [blame] | 2654 | if (HAS_DDI(dev_priv)) { |
| 2655 | if (dev_priv->psr.psr2_support) |
| 2656 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2657 | else |
| 2658 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
| 2659 | } else { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2660 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2661 | enum transcoder cpu_transcoder = |
| 2662 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2663 | enum intel_display_power_domain power_domain; |
| 2664 | |
| 2665 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2666 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2667 | power_domain)) |
| 2668 | continue; |
| 2669 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2670 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2671 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2672 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2673 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2674 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2675 | |
| 2676 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2677 | } |
| 2678 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2679 | |
| 2680 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2681 | yesno(dev_priv->psr.link_standby)); |
| 2682 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2683 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2684 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2685 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2686 | for_each_pipe(dev_priv, pipe) { |
| 2687 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2688 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2689 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2690 | } |
| 2691 | seq_puts(m, "\n"); |
| 2692 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2693 | /* |
| 2694 | * VLV/CHV PSR has no kind of performance counter |
| 2695 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2696 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2697 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2698 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2699 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2700 | |
| 2701 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2702 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2703 | if (dev_priv->psr.psr2_support) { |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2704 | u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2705 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2706 | seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n", |
| 2707 | psr2, psr2_live_status(psr2)); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2708 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2709 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2710 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2711 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2712 | return 0; |
| 2713 | } |
| 2714 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2715 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2716 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2717 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2718 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2719 | struct intel_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2720 | struct drm_connector_list_iter conn_iter; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2721 | struct intel_dp *intel_dp = NULL; |
| 2722 | int ret; |
| 2723 | u8 crc[6]; |
| 2724 | |
| 2725 | drm_modeset_lock_all(dev); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2726 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 2727 | for_each_intel_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2728 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2729 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2730 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2731 | continue; |
| 2732 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2733 | crtc = connector->base.state->crtc; |
| 2734 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2735 | continue; |
| 2736 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2737 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2738 | continue; |
| 2739 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2740 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2741 | |
| 2742 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2743 | if (ret) |
| 2744 | goto out; |
| 2745 | |
| 2746 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2747 | crc[0], crc[1], crc[2], |
| 2748 | crc[3], crc[4], crc[5]); |
| 2749 | goto out; |
| 2750 | } |
| 2751 | ret = -ENODEV; |
| 2752 | out: |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2753 | drm_connector_list_iter_end(&conn_iter); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2754 | drm_modeset_unlock_all(dev); |
| 2755 | return ret; |
| 2756 | } |
| 2757 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2758 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2759 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2760 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2761 | u64 power; |
| 2762 | u32 units; |
| 2763 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2764 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2765 | return -ENODEV; |
| 2766 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2767 | intel_runtime_pm_get(dev_priv); |
| 2768 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2769 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2770 | power = (power & 0x1f00) >> 8; |
| 2771 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2772 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2773 | power *= units; |
| 2774 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2775 | intel_runtime_pm_put(dev_priv); |
| 2776 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2777 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2778 | |
| 2779 | return 0; |
| 2780 | } |
| 2781 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2782 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2783 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2784 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2785 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2786 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2787 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2788 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2789 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2790 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2791 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2792 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2793 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2794 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2795 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2796 | #else |
| 2797 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2798 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2799 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2800 | pci_power_name(pdev->current_state), |
| 2801 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2802 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2803 | return 0; |
| 2804 | } |
| 2805 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2806 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2807 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2808 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2809 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2810 | int i; |
| 2811 | |
| 2812 | mutex_lock(&power_domains->lock); |
| 2813 | |
| 2814 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2815 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2816 | struct i915_power_well *power_well; |
| 2817 | enum intel_display_power_domain power_domain; |
| 2818 | |
| 2819 | power_well = &power_domains->power_wells[i]; |
| 2820 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2821 | power_well->count); |
| 2822 | |
Joonas Lahtinen | 8385c2e | 2017-02-08 15:12:10 +0200 | [diff] [blame] | 2823 | for_each_power_domain(power_domain, power_well->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2824 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2825 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2826 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2827 | } |
| 2828 | |
| 2829 | mutex_unlock(&power_domains->lock); |
| 2830 | |
| 2831 | return 0; |
| 2832 | } |
| 2833 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2834 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2835 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2836 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2837 | struct intel_csr *csr; |
| 2838 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2839 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2840 | seq_puts(m, "not supported\n"); |
| 2841 | return 0; |
| 2842 | } |
| 2843 | |
| 2844 | csr = &dev_priv->csr; |
| 2845 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2846 | intel_runtime_pm_get(dev_priv); |
| 2847 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2848 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2849 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2850 | |
| 2851 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2852 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2853 | |
| 2854 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2855 | CSR_VERSION_MINOR(csr->version)); |
| 2856 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2857 | if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2858 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2859 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2860 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2861 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2862 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2863 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2864 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2865 | } |
| 2866 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2867 | out: |
| 2868 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2869 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2870 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2871 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2872 | intel_runtime_pm_put(dev_priv); |
| 2873 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2874 | return 0; |
| 2875 | } |
| 2876 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2877 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2878 | struct drm_display_mode *mode) |
| 2879 | { |
| 2880 | int i; |
| 2881 | |
| 2882 | for (i = 0; i < tabs; i++) |
| 2883 | seq_putc(m, '\t'); |
| 2884 | |
| 2885 | 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", |
| 2886 | mode->base.id, mode->name, |
| 2887 | mode->vrefresh, mode->clock, |
| 2888 | mode->hdisplay, mode->hsync_start, |
| 2889 | mode->hsync_end, mode->htotal, |
| 2890 | mode->vdisplay, mode->vsync_start, |
| 2891 | mode->vsync_end, mode->vtotal, |
| 2892 | mode->type, mode->flags); |
| 2893 | } |
| 2894 | |
| 2895 | static void intel_encoder_info(struct seq_file *m, |
| 2896 | struct intel_crtc *intel_crtc, |
| 2897 | struct intel_encoder *intel_encoder) |
| 2898 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2899 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2900 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2901 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2902 | struct intel_connector *intel_connector; |
| 2903 | struct drm_encoder *encoder; |
| 2904 | |
| 2905 | encoder = &intel_encoder->base; |
| 2906 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2907 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2908 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2909 | struct drm_connector *connector = &intel_connector->base; |
| 2910 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2911 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2912 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2913 | drm_get_connector_status_name(connector->status)); |
| 2914 | if (connector->status == connector_status_connected) { |
| 2915 | struct drm_display_mode *mode = &crtc->mode; |
| 2916 | seq_printf(m, ", mode:\n"); |
| 2917 | intel_seq_print_mode(m, 2, mode); |
| 2918 | } else { |
| 2919 | seq_putc(m, '\n'); |
| 2920 | } |
| 2921 | } |
| 2922 | } |
| 2923 | |
| 2924 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2925 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2926 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2927 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2928 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2929 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2930 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2931 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2932 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2933 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2934 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2935 | fb->base.id, plane_state->src_x >> 16, |
| 2936 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2937 | else |
| 2938 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2939 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2940 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2941 | } |
| 2942 | |
| 2943 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2944 | { |
| 2945 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2946 | |
| 2947 | seq_printf(m, "\tfixed mode:\n"); |
| 2948 | intel_seq_print_mode(m, 2, mode); |
| 2949 | } |
| 2950 | |
| 2951 | static void intel_dp_info(struct seq_file *m, |
| 2952 | struct intel_connector *intel_connector) |
| 2953 | { |
| 2954 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2955 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2956 | |
| 2957 | 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] | 2958 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2959 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2960 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2961 | |
| 2962 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2963 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2964 | } |
| 2965 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2966 | static void intel_dp_mst_info(struct seq_file *m, |
| 2967 | struct intel_connector *intel_connector) |
| 2968 | { |
| 2969 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2970 | struct intel_dp_mst_encoder *intel_mst = |
| 2971 | enc_to_mst(&intel_encoder->base); |
| 2972 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2973 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2974 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2975 | intel_connector->port); |
| 2976 | |
| 2977 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2978 | } |
| 2979 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2980 | static void intel_hdmi_info(struct seq_file *m, |
| 2981 | struct intel_connector *intel_connector) |
| 2982 | { |
| 2983 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2984 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2985 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2986 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2987 | } |
| 2988 | |
| 2989 | static void intel_lvds_info(struct seq_file *m, |
| 2990 | struct intel_connector *intel_connector) |
| 2991 | { |
| 2992 | intel_panel_info(m, &intel_connector->panel); |
| 2993 | } |
| 2994 | |
| 2995 | static void intel_connector_info(struct seq_file *m, |
| 2996 | struct drm_connector *connector) |
| 2997 | { |
| 2998 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2999 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3000 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3001 | |
| 3002 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 3003 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3004 | drm_get_connector_status_name(connector->status)); |
| 3005 | if (connector->status == connector_status_connected) { |
| 3006 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 3007 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 3008 | connector->display_info.width_mm, |
| 3009 | connector->display_info.height_mm); |
| 3010 | seq_printf(m, "\tsubpixel order: %s\n", |
| 3011 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 3012 | seq_printf(m, "\tCEA rev: %d\n", |
| 3013 | connector->display_info.cea_rev); |
| 3014 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3015 | |
| 3016 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3017 | return; |
| 3018 | |
| 3019 | switch (connector->connector_type) { |
| 3020 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 3021 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3022 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3023 | intel_dp_mst_info(m, intel_connector); |
| 3024 | else |
| 3025 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3026 | break; |
| 3027 | case DRM_MODE_CONNECTOR_LVDS: |
| 3028 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3029 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3030 | break; |
| 3031 | case DRM_MODE_CONNECTOR_HDMIA: |
| 3032 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 3033 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 3034 | intel_hdmi_info(m, intel_connector); |
| 3035 | break; |
| 3036 | default: |
| 3037 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3038 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3039 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3040 | seq_printf(m, "\tmodes:\n"); |
| 3041 | list_for_each_entry(mode, &connector->modes, head) |
| 3042 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3043 | } |
| 3044 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3045 | static bool cursor_active(struct drm_i915_private *dev_priv, int pipe) |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3046 | { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3047 | u32 state; |
| 3048 | |
Jani Nikula | 2a307c2 | 2016-11-30 17:43:04 +0200 | [diff] [blame] | 3049 | if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 3050 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3051 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 3052 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3053 | |
| 3054 | return state; |
| 3055 | } |
| 3056 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3057 | static bool cursor_position(struct drm_i915_private *dev_priv, |
| 3058 | int pipe, int *x, int *y) |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3059 | { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3060 | u32 pos; |
| 3061 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 3062 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3063 | |
| 3064 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 3065 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 3066 | *x = -*x; |
| 3067 | |
| 3068 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 3069 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 3070 | *y = -*y; |
| 3071 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3072 | return cursor_active(dev_priv, pipe); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3073 | } |
| 3074 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3075 | static const char *plane_type(enum drm_plane_type type) |
| 3076 | { |
| 3077 | switch (type) { |
| 3078 | case DRM_PLANE_TYPE_OVERLAY: |
| 3079 | return "OVL"; |
| 3080 | case DRM_PLANE_TYPE_PRIMARY: |
| 3081 | return "PRI"; |
| 3082 | case DRM_PLANE_TYPE_CURSOR: |
| 3083 | return "CUR"; |
| 3084 | /* |
| 3085 | * Deliberately omitting default: to generate compiler warnings |
| 3086 | * when a new drm_plane_type gets added. |
| 3087 | */ |
| 3088 | } |
| 3089 | |
| 3090 | return "unknown"; |
| 3091 | } |
| 3092 | |
| 3093 | static const char *plane_rotation(unsigned int rotation) |
| 3094 | { |
| 3095 | static char buf[48]; |
| 3096 | /* |
| 3097 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3098 | * will print them all to visualize if the values are misused |
| 3099 | */ |
| 3100 | snprintf(buf, sizeof(buf), |
| 3101 | "%s%s%s%s%s%s(0x%08x)", |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 3102 | (rotation & DRM_ROTATE_0) ? "0 " : "", |
| 3103 | (rotation & DRM_ROTATE_90) ? "90 " : "", |
| 3104 | (rotation & DRM_ROTATE_180) ? "180 " : "", |
| 3105 | (rotation & DRM_ROTATE_270) ? "270 " : "", |
| 3106 | (rotation & DRM_REFLECT_X) ? "FLIPX " : "", |
| 3107 | (rotation & DRM_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3108 | rotation); |
| 3109 | |
| 3110 | return buf; |
| 3111 | } |
| 3112 | |
| 3113 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3114 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3115 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3116 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3117 | struct intel_plane *intel_plane; |
| 3118 | |
| 3119 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3120 | struct drm_plane_state *state; |
| 3121 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3122 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3123 | |
| 3124 | if (!plane->state) { |
| 3125 | seq_puts(m, "plane->state is NULL!\n"); |
| 3126 | continue; |
| 3127 | } |
| 3128 | |
| 3129 | state = plane->state; |
| 3130 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3131 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3132 | drm_get_format_name(state->fb->format->format, |
| 3133 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3134 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3135 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3136 | } |
| 3137 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3138 | 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", |
| 3139 | plane->base.id, |
| 3140 | plane_type(intel_plane->base.type), |
| 3141 | state->crtc_x, state->crtc_y, |
| 3142 | state->crtc_w, state->crtc_h, |
| 3143 | (state->src_x >> 16), |
| 3144 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3145 | (state->src_y >> 16), |
| 3146 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3147 | (state->src_w >> 16), |
| 3148 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3149 | (state->src_h >> 16), |
| 3150 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3151 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3152 | plane_rotation(state->rotation)); |
| 3153 | } |
| 3154 | } |
| 3155 | |
| 3156 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3157 | { |
| 3158 | struct intel_crtc_state *pipe_config; |
| 3159 | int num_scalers = intel_crtc->num_scalers; |
| 3160 | int i; |
| 3161 | |
| 3162 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3163 | |
| 3164 | /* Not all platformas have a scaler */ |
| 3165 | if (num_scalers) { |
| 3166 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3167 | num_scalers, |
| 3168 | pipe_config->scaler_state.scaler_users, |
| 3169 | pipe_config->scaler_state.scaler_id); |
| 3170 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3171 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3172 | struct intel_scaler *sc = |
| 3173 | &pipe_config->scaler_state.scalers[i]; |
| 3174 | |
| 3175 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3176 | i, yesno(sc->in_use), sc->mode); |
| 3177 | } |
| 3178 | seq_puts(m, "\n"); |
| 3179 | } else { |
| 3180 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3181 | } |
| 3182 | } |
| 3183 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3184 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3185 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3186 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3187 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3188 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3189 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3190 | struct drm_connector_list_iter conn_iter; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3191 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3192 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3193 | seq_printf(m, "CRTC info\n"); |
| 3194 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3195 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3196 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3197 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3198 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3199 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3200 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3201 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3202 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3203 | 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] | 3204 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3205 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3206 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3207 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3208 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3209 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3210 | intel_crtc_info(m, crtc); |
| 3211 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3212 | active = cursor_position(dev_priv, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3213 | 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] | 3214 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3215 | x, y, crtc->base.cursor->state->crtc_w, |
| 3216 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3217 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3218 | intel_scaler_info(m, crtc); |
| 3219 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3220 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3221 | |
| 3222 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3223 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3224 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3225 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3226 | } |
| 3227 | |
| 3228 | seq_printf(m, "\n"); |
| 3229 | seq_printf(m, "Connector info\n"); |
| 3230 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3231 | mutex_lock(&dev->mode_config.mutex); |
| 3232 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3233 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3234 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3235 | drm_connector_list_iter_end(&conn_iter); |
| 3236 | mutex_unlock(&dev->mode_config.mutex); |
| 3237 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3238 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3239 | |
| 3240 | return 0; |
| 3241 | } |
| 3242 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3243 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3244 | { |
| 3245 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3246 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3247 | enum intel_engine_id id; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3248 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3249 | intel_runtime_pm_get(dev_priv); |
| 3250 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3251 | seq_printf(m, "GT awake? %s\n", |
| 3252 | yesno(dev_priv->gt.awake)); |
| 3253 | seq_printf(m, "Global active requests: %d\n", |
| 3254 | dev_priv->gt.active_requests); |
| 3255 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3256 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3257 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 3258 | struct drm_i915_gem_request *rq; |
| 3259 | struct rb_node *rb; |
| 3260 | u64 addr; |
| 3261 | |
| 3262 | seq_printf(m, "%s\n", engine->name); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3263 | seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms], inflight %d\n", |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3264 | intel_engine_get_seqno(engine), |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 3265 | intel_engine_last_submit(engine), |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3266 | engine->hangcheck.seqno, |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3267 | jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp), |
| 3268 | engine->timeline->inflight_seqnos); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3269 | |
| 3270 | rcu_read_lock(); |
| 3271 | |
| 3272 | seq_printf(m, "\tRequests:\n"); |
| 3273 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3274 | rq = list_first_entry(&engine->timeline->requests, |
| 3275 | struct drm_i915_gem_request, link); |
| 3276 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3277 | print_request(m, rq, "\t\tfirst "); |
| 3278 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3279 | rq = list_last_entry(&engine->timeline->requests, |
| 3280 | struct drm_i915_gem_request, link); |
| 3281 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3282 | print_request(m, rq, "\t\tlast "); |
| 3283 | |
| 3284 | rq = i915_gem_find_active_request(engine); |
| 3285 | if (rq) { |
| 3286 | print_request(m, rq, "\t\tactive "); |
| 3287 | seq_printf(m, |
| 3288 | "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n", |
| 3289 | rq->head, rq->postfix, rq->tail, |
| 3290 | rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, |
| 3291 | rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); |
| 3292 | } |
| 3293 | |
| 3294 | seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n", |
| 3295 | I915_READ(RING_START(engine->mmio_base)), |
| 3296 | rq ? i915_ggtt_offset(rq->ring->vma) : 0); |
| 3297 | seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n", |
| 3298 | I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR, |
| 3299 | rq ? rq->ring->head : 0); |
| 3300 | seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n", |
| 3301 | I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR, |
| 3302 | rq ? rq->ring->tail : 0); |
| 3303 | seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n", |
| 3304 | I915_READ(RING_CTL(engine->mmio_base)), |
| 3305 | I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : ""); |
| 3306 | |
| 3307 | rcu_read_unlock(); |
| 3308 | |
| 3309 | addr = intel_engine_get_active_head(engine); |
| 3310 | seq_printf(m, "\tACTHD: 0x%08x_%08x\n", |
| 3311 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3312 | addr = intel_engine_get_last_batch_head(engine); |
| 3313 | seq_printf(m, "\tBBADDR: 0x%08x_%08x\n", |
| 3314 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3315 | |
| 3316 | if (i915.enable_execlists) { |
| 3317 | u32 ptr, read, write; |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3318 | struct rb_node *rb; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3319 | |
| 3320 | seq_printf(m, "\tExeclist status: 0x%08x %08x\n", |
| 3321 | I915_READ(RING_EXECLIST_STATUS_LO(engine)), |
| 3322 | I915_READ(RING_EXECLIST_STATUS_HI(engine))); |
| 3323 | |
| 3324 | ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
| 3325 | read = GEN8_CSB_READ_PTR(ptr); |
| 3326 | write = GEN8_CSB_WRITE_PTR(ptr); |
| 3327 | seq_printf(m, "\tExeclist CSB read %d, write %d\n", |
| 3328 | read, write); |
| 3329 | if (read >= GEN8_CSB_ENTRIES) |
| 3330 | read = 0; |
| 3331 | if (write >= GEN8_CSB_ENTRIES) |
| 3332 | write = 0; |
| 3333 | if (read > write) |
| 3334 | write += GEN8_CSB_ENTRIES; |
| 3335 | while (read < write) { |
| 3336 | unsigned int idx = ++read % GEN8_CSB_ENTRIES; |
| 3337 | |
| 3338 | seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n", |
| 3339 | idx, |
| 3340 | I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)), |
| 3341 | I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx))); |
| 3342 | } |
| 3343 | |
| 3344 | rcu_read_lock(); |
| 3345 | rq = READ_ONCE(engine->execlist_port[0].request); |
Chris Wilson | 816ee79 | 2017-01-24 11:00:03 +0000 | [diff] [blame] | 3346 | if (rq) { |
| 3347 | seq_printf(m, "\t\tELSP[0] count=%d, ", |
| 3348 | engine->execlist_port[0].count); |
| 3349 | print_request(m, rq, "rq: "); |
| 3350 | } else { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3351 | seq_printf(m, "\t\tELSP[0] idle\n"); |
Chris Wilson | 816ee79 | 2017-01-24 11:00:03 +0000 | [diff] [blame] | 3352 | } |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3353 | rq = READ_ONCE(engine->execlist_port[1].request); |
Chris Wilson | 816ee79 | 2017-01-24 11:00:03 +0000 | [diff] [blame] | 3354 | if (rq) { |
| 3355 | seq_printf(m, "\t\tELSP[1] count=%d, ", |
| 3356 | engine->execlist_port[1].count); |
| 3357 | print_request(m, rq, "rq: "); |
| 3358 | } else { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3359 | seq_printf(m, "\t\tELSP[1] idle\n"); |
Chris Wilson | 816ee79 | 2017-01-24 11:00:03 +0000 | [diff] [blame] | 3360 | } |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3361 | rcu_read_unlock(); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3362 | |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3363 | spin_lock_irq(&engine->timeline->lock); |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3364 | for (rb = engine->execlist_first; rb; rb = rb_next(rb)) { |
| 3365 | rq = rb_entry(rb, typeof(*rq), priotree.node); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3366 | print_request(m, rq, "\t\tQ "); |
| 3367 | } |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3368 | spin_unlock_irq(&engine->timeline->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3369 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 3370 | seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n", |
| 3371 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 3372 | seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n", |
| 3373 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 3374 | seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n", |
| 3375 | I915_READ(RING_PP_DIR_DCLV(engine))); |
| 3376 | } |
| 3377 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 3378 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3379 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 3380 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3381 | |
| 3382 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 3383 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 3384 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 3385 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3386 | |
| 3387 | seq_puts(m, "\n"); |
| 3388 | } |
| 3389 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3390 | intel_runtime_pm_put(dev_priv); |
| 3391 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3392 | return 0; |
| 3393 | } |
| 3394 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3395 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3396 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3397 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3398 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3399 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3400 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3401 | enum intel_engine_id id; |
| 3402 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3403 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3404 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3405 | seq_puts(m, "Semaphores are disabled\n"); |
| 3406 | return 0; |
| 3407 | } |
| 3408 | |
| 3409 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3410 | if (ret) |
| 3411 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3412 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3413 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3414 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3415 | struct page *page; |
| 3416 | uint64_t *seqno; |
| 3417 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3418 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3419 | |
| 3420 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3421 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3422 | uint64_t offset; |
| 3423 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3424 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3425 | |
| 3426 | seq_puts(m, " Last signal:"); |
| 3427 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3428 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3429 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3430 | seqno[offset], offset * 8); |
| 3431 | } |
| 3432 | seq_putc(m, '\n'); |
| 3433 | |
| 3434 | seq_puts(m, " Last wait: "); |
| 3435 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3436 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3437 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3438 | seqno[offset], offset * 8); |
| 3439 | } |
| 3440 | seq_putc(m, '\n'); |
| 3441 | |
| 3442 | } |
| 3443 | kunmap_atomic(seqno); |
| 3444 | } else { |
| 3445 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3446 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3447 | for (j = 0; j < num_rings; j++) |
| 3448 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3449 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3450 | seq_putc(m, '\n'); |
| 3451 | } |
| 3452 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3453 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3454 | mutex_unlock(&dev->struct_mutex); |
| 3455 | return 0; |
| 3456 | } |
| 3457 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3458 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3459 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3460 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3461 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3462 | int i; |
| 3463 | |
| 3464 | drm_modeset_lock_all(dev); |
| 3465 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3466 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3467 | |
| 3468 | 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] | 3469 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3470 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3471 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3472 | seq_printf(m, " dpll: 0x%08x\n", pll->state.hw_state.dpll); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3473 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3474 | pll->state.hw_state.dpll_md); |
| 3475 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3476 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3477 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3478 | } |
| 3479 | drm_modeset_unlock_all(dev); |
| 3480 | |
| 3481 | return 0; |
| 3482 | } |
| 3483 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3484 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3485 | { |
| 3486 | int i; |
| 3487 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3488 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3489 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3490 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3491 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3492 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3493 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3494 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3495 | if (ret) |
| 3496 | return ret; |
| 3497 | |
| 3498 | intel_runtime_pm_get(dev_priv); |
| 3499 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3500 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3501 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3502 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3503 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3504 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3505 | i915_reg_t addr; |
| 3506 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3507 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3508 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3509 | addr = workarounds->reg[i].addr; |
| 3510 | mask = workarounds->reg[i].mask; |
| 3511 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3512 | read = I915_READ(addr); |
| 3513 | ok = (value & mask) == (read & mask); |
| 3514 | 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] | 3515 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3516 | } |
| 3517 | |
| 3518 | intel_runtime_pm_put(dev_priv); |
| 3519 | mutex_unlock(&dev->struct_mutex); |
| 3520 | |
| 3521 | return 0; |
| 3522 | } |
| 3523 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3524 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3525 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3526 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3527 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3528 | struct skl_ddb_allocation *ddb; |
| 3529 | struct skl_ddb_entry *entry; |
| 3530 | enum pipe pipe; |
| 3531 | int plane; |
| 3532 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3533 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3534 | return 0; |
| 3535 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3536 | drm_modeset_lock_all(dev); |
| 3537 | |
| 3538 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3539 | |
| 3540 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3541 | |
| 3542 | for_each_pipe(dev_priv, pipe) { |
| 3543 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3544 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3545 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3546 | entry = &ddb->plane[pipe][plane]; |
| 3547 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3548 | entry->start, entry->end, |
| 3549 | skl_ddb_entry_size(entry)); |
| 3550 | } |
| 3551 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3552 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3553 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3554 | entry->end, skl_ddb_entry_size(entry)); |
| 3555 | } |
| 3556 | |
| 3557 | drm_modeset_unlock_all(dev); |
| 3558 | |
| 3559 | return 0; |
| 3560 | } |
| 3561 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3562 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3563 | struct drm_device *dev, |
| 3564 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3565 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3566 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3567 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3568 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3569 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3570 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3571 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3572 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3573 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3574 | if (connector->state->crtc != &intel_crtc->base) |
| 3575 | continue; |
| 3576 | |
| 3577 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3578 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3579 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3580 | |
| 3581 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3582 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3583 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3584 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3585 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3586 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3587 | else |
| 3588 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3589 | |
| 3590 | seq_puts(m, "\n\n"); |
| 3591 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3592 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3593 | struct intel_panel *panel; |
| 3594 | |
| 3595 | mutex_lock(&drrs->mutex); |
| 3596 | /* DRRS Supported */ |
| 3597 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3598 | |
| 3599 | /* disable_drrs() will make drrs->dp NULL */ |
| 3600 | if (!drrs->dp) { |
| 3601 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3602 | mutex_unlock(&drrs->mutex); |
| 3603 | return; |
| 3604 | } |
| 3605 | |
| 3606 | panel = &drrs->dp->attached_connector->panel; |
| 3607 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3608 | drrs->busy_frontbuffer_bits); |
| 3609 | |
| 3610 | seq_puts(m, "\n\t\t"); |
| 3611 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3612 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3613 | vrefresh = panel->fixed_mode->vrefresh; |
| 3614 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3615 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3616 | vrefresh = panel->downclock_mode->vrefresh; |
| 3617 | } else { |
| 3618 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3619 | drrs->refresh_rate_type); |
| 3620 | mutex_unlock(&drrs->mutex); |
| 3621 | return; |
| 3622 | } |
| 3623 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3624 | |
| 3625 | seq_puts(m, "\n\t\t"); |
| 3626 | mutex_unlock(&drrs->mutex); |
| 3627 | } else { |
| 3628 | /* DRRS not supported. Print the VBT parameter*/ |
| 3629 | seq_puts(m, "\tDRRS Supported : No"); |
| 3630 | } |
| 3631 | seq_puts(m, "\n"); |
| 3632 | } |
| 3633 | |
| 3634 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3635 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3636 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3637 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3638 | struct intel_crtc *intel_crtc; |
| 3639 | int active_crtc_cnt = 0; |
| 3640 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3641 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3642 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3643 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3644 | active_crtc_cnt++; |
| 3645 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3646 | |
| 3647 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3648 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3649 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3650 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3651 | |
| 3652 | if (!active_crtc_cnt) |
| 3653 | seq_puts(m, "No active crtc found\n"); |
| 3654 | |
| 3655 | return 0; |
| 3656 | } |
| 3657 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3658 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3659 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3660 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3661 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3662 | struct intel_encoder *intel_encoder; |
| 3663 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3664 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3665 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3666 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3667 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3668 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3669 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3670 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3671 | |
| 3672 | intel_encoder = intel_attached_encoder(connector); |
| 3673 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3674 | continue; |
| 3675 | |
| 3676 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3677 | if (!intel_dig_port->dp.can_mst) |
| 3678 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3679 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3680 | seq_printf(m, "MST Source Port %c\n", |
| 3681 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3682 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3683 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3684 | drm_connector_list_iter_end(&conn_iter); |
| 3685 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3686 | return 0; |
| 3687 | } |
| 3688 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3689 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3690 | const char __user *ubuf, |
| 3691 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3692 | { |
| 3693 | char *input_buffer; |
| 3694 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3695 | struct drm_device *dev; |
| 3696 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3697 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3698 | struct intel_dp *intel_dp; |
| 3699 | int val = 0; |
| 3700 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3701 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3702 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3703 | if (len == 0) |
| 3704 | return 0; |
| 3705 | |
| 3706 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 3707 | if (!input_buffer) |
| 3708 | return -ENOMEM; |
| 3709 | |
| 3710 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 3711 | status = -EFAULT; |
| 3712 | goto out; |
| 3713 | } |
| 3714 | |
| 3715 | input_buffer[len] = '\0'; |
| 3716 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3717 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3718 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3719 | drm_for_each_connector_iter(connector, &conn_iter) { |
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 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 3724 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3725 | connector->encoder != NULL) { |
| 3726 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3727 | status = kstrtoint(input_buffer, 10, &val); |
| 3728 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3729 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3730 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3731 | /* To prevent erroneous activation of the compliance |
| 3732 | * testing code, only accept an actual value of 1 here |
| 3733 | */ |
| 3734 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3735 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3736 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3737 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3738 | } |
| 3739 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3740 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3741 | out: |
| 3742 | kfree(input_buffer); |
| 3743 | if (status < 0) |
| 3744 | return status; |
| 3745 | |
| 3746 | *offp += len; |
| 3747 | return len; |
| 3748 | } |
| 3749 | |
| 3750 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3751 | { |
| 3752 | struct drm_device *dev = m->private; |
| 3753 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3754 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3755 | struct intel_dp *intel_dp; |
| 3756 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3757 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3758 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3759 | if (connector->connector_type != |
| 3760 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3761 | continue; |
| 3762 | |
| 3763 | if (connector->status == connector_status_connected && |
| 3764 | connector->encoder != NULL) { |
| 3765 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3766 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3767 | seq_puts(m, "1"); |
| 3768 | else |
| 3769 | seq_puts(m, "0"); |
| 3770 | } else |
| 3771 | seq_puts(m, "0"); |
| 3772 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3773 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3774 | |
| 3775 | return 0; |
| 3776 | } |
| 3777 | |
| 3778 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3779 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3780 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3781 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3782 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3783 | return single_open(file, i915_displayport_test_active_show, |
| 3784 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3785 | } |
| 3786 | |
| 3787 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3788 | .owner = THIS_MODULE, |
| 3789 | .open = i915_displayport_test_active_open, |
| 3790 | .read = seq_read, |
| 3791 | .llseek = seq_lseek, |
| 3792 | .release = single_release, |
| 3793 | .write = i915_displayport_test_active_write |
| 3794 | }; |
| 3795 | |
| 3796 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3797 | { |
| 3798 | struct drm_device *dev = m->private; |
| 3799 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3800 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3801 | struct intel_dp *intel_dp; |
| 3802 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3803 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3804 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3805 | if (connector->connector_type != |
| 3806 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3807 | continue; |
| 3808 | |
| 3809 | if (connector->status == connector_status_connected && |
| 3810 | connector->encoder != NULL) { |
| 3811 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3812 | if (intel_dp->compliance.test_type == |
| 3813 | DP_TEST_LINK_EDID_READ) |
| 3814 | seq_printf(m, "%lx", |
| 3815 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3816 | else if (intel_dp->compliance.test_type == |
| 3817 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3818 | seq_printf(m, "hdisplay: %d\n", |
| 3819 | intel_dp->compliance.test_data.hdisplay); |
| 3820 | seq_printf(m, "vdisplay: %d\n", |
| 3821 | intel_dp->compliance.test_data.vdisplay); |
| 3822 | seq_printf(m, "bpc: %u\n", |
| 3823 | intel_dp->compliance.test_data.bpc); |
| 3824 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3825 | } else |
| 3826 | seq_puts(m, "0"); |
| 3827 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3828 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3829 | |
| 3830 | return 0; |
| 3831 | } |
| 3832 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3833 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3834 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3835 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3836 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3837 | return single_open(file, i915_displayport_test_data_show, |
| 3838 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3839 | } |
| 3840 | |
| 3841 | static const struct file_operations i915_displayport_test_data_fops = { |
| 3842 | .owner = THIS_MODULE, |
| 3843 | .open = i915_displayport_test_data_open, |
| 3844 | .read = seq_read, |
| 3845 | .llseek = seq_lseek, |
| 3846 | .release = single_release |
| 3847 | }; |
| 3848 | |
| 3849 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3850 | { |
| 3851 | struct drm_device *dev = m->private; |
| 3852 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3853 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3854 | struct intel_dp *intel_dp; |
| 3855 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3856 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3857 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3858 | if (connector->connector_type != |
| 3859 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3860 | continue; |
| 3861 | |
| 3862 | if (connector->status == connector_status_connected && |
| 3863 | connector->encoder != NULL) { |
| 3864 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3865 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3866 | } else |
| 3867 | seq_puts(m, "0"); |
| 3868 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3869 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3870 | |
| 3871 | return 0; |
| 3872 | } |
| 3873 | |
| 3874 | static int i915_displayport_test_type_open(struct inode *inode, |
| 3875 | struct file *file) |
| 3876 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3877 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3878 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3879 | return single_open(file, i915_displayport_test_type_show, |
| 3880 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3881 | } |
| 3882 | |
| 3883 | static const struct file_operations i915_displayport_test_type_fops = { |
| 3884 | .owner = THIS_MODULE, |
| 3885 | .open = i915_displayport_test_type_open, |
| 3886 | .read = seq_read, |
| 3887 | .llseek = seq_lseek, |
| 3888 | .release = single_release |
| 3889 | }; |
| 3890 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3891 | 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] | 3892 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3893 | struct drm_i915_private *dev_priv = m->private; |
| 3894 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3895 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3896 | int num_levels; |
| 3897 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3898 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3899 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3900 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3901 | num_levels = 1; |
| 3902 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3903 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3904 | |
| 3905 | drm_modeset_lock_all(dev); |
| 3906 | |
| 3907 | for (level = 0; level < num_levels; level++) { |
| 3908 | unsigned int latency = wm[level]; |
| 3909 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3910 | /* |
| 3911 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3912 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3913 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3914 | if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) || |
| 3915 | IS_CHERRYVIEW(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3916 | latency *= 10; |
| 3917 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3918 | latency *= 5; |
| 3919 | |
| 3920 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3921 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | drm_modeset_unlock_all(dev); |
| 3925 | } |
| 3926 | |
| 3927 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3928 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3929 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3930 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3931 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3932 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3933 | latencies = dev_priv->wm.skl_latency; |
| 3934 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3935 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3936 | |
| 3937 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3938 | |
| 3939 | return 0; |
| 3940 | } |
| 3941 | |
| 3942 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3943 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3944 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3945 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3946 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3947 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3948 | latencies = dev_priv->wm.skl_latency; |
| 3949 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3950 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3951 | |
| 3952 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3953 | |
| 3954 | return 0; |
| 3955 | } |
| 3956 | |
| 3957 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3958 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3959 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3960 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3961 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3962 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3963 | latencies = dev_priv->wm.skl_latency; |
| 3964 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3965 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3966 | |
| 3967 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3968 | |
| 3969 | return 0; |
| 3970 | } |
| 3971 | |
| 3972 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3973 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3974 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3975 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3976 | if (INTEL_GEN(dev_priv) < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3977 | return -ENODEV; |
| 3978 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3979 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3980 | } |
| 3981 | |
| 3982 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3983 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3984 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3985 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3986 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3987 | return -ENODEV; |
| 3988 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3989 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3990 | } |
| 3991 | |
| 3992 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3993 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3994 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3995 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3996 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3997 | return -ENODEV; |
| 3998 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3999 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4000 | } |
| 4001 | |
| 4002 | 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] | 4003 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4004 | { |
| 4005 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4006 | struct drm_i915_private *dev_priv = m->private; |
| 4007 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4008 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4009 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4010 | int level; |
| 4011 | int ret; |
| 4012 | char tmp[32]; |
| 4013 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4014 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4015 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4016 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4017 | num_levels = 1; |
| 4018 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 4019 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4020 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4021 | if (len >= sizeof(tmp)) |
| 4022 | return -EINVAL; |
| 4023 | |
| 4024 | if (copy_from_user(tmp, ubuf, len)) |
| 4025 | return -EFAULT; |
| 4026 | |
| 4027 | tmp[len] = '\0'; |
| 4028 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4029 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4030 | &new[0], &new[1], &new[2], &new[3], |
| 4031 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4032 | if (ret != num_levels) |
| 4033 | return -EINVAL; |
| 4034 | |
| 4035 | drm_modeset_lock_all(dev); |
| 4036 | |
| 4037 | for (level = 0; level < num_levels; level++) |
| 4038 | wm[level] = new[level]; |
| 4039 | |
| 4040 | drm_modeset_unlock_all(dev); |
| 4041 | |
| 4042 | return len; |
| 4043 | } |
| 4044 | |
| 4045 | |
| 4046 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4047 | size_t len, loff_t *offp) |
| 4048 | { |
| 4049 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4050 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4051 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4052 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4053 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4054 | latencies = dev_priv->wm.skl_latency; |
| 4055 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4056 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4057 | |
| 4058 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4059 | } |
| 4060 | |
| 4061 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4062 | size_t len, loff_t *offp) |
| 4063 | { |
| 4064 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4065 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4066 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4067 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4068 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4069 | latencies = dev_priv->wm.skl_latency; |
| 4070 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4071 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4072 | |
| 4073 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4074 | } |
| 4075 | |
| 4076 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4077 | size_t len, loff_t *offp) |
| 4078 | { |
| 4079 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4080 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4081 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4082 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4083 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4084 | latencies = dev_priv->wm.skl_latency; |
| 4085 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4086 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4087 | |
| 4088 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4089 | } |
| 4090 | |
| 4091 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4092 | .owner = THIS_MODULE, |
| 4093 | .open = pri_wm_latency_open, |
| 4094 | .read = seq_read, |
| 4095 | .llseek = seq_lseek, |
| 4096 | .release = single_release, |
| 4097 | .write = pri_wm_latency_write |
| 4098 | }; |
| 4099 | |
| 4100 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4101 | .owner = THIS_MODULE, |
| 4102 | .open = spr_wm_latency_open, |
| 4103 | .read = seq_read, |
| 4104 | .llseek = seq_lseek, |
| 4105 | .release = single_release, |
| 4106 | .write = spr_wm_latency_write |
| 4107 | }; |
| 4108 | |
| 4109 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4110 | .owner = THIS_MODULE, |
| 4111 | .open = cur_wm_latency_open, |
| 4112 | .read = seq_read, |
| 4113 | .llseek = seq_lseek, |
| 4114 | .release = single_release, |
| 4115 | .write = cur_wm_latency_write |
| 4116 | }; |
| 4117 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4118 | static int |
| 4119 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4120 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4121 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4122 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4123 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4124 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4125 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4126 | } |
| 4127 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4128 | static int |
| 4129 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4130 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4131 | struct drm_i915_private *dev_priv = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4132 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4133 | /* |
| 4134 | * There is no safeguard against this debugfs entry colliding |
| 4135 | * with the hangcheck calling same i915_handle_error() in |
| 4136 | * parallel, causing an explosion. For now we assume that the |
| 4137 | * test harness is responsible enough not to inject gpu hangs |
| 4138 | * while it is writing to 'i915_wedged' |
| 4139 | */ |
| 4140 | |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 4141 | if (i915_reset_backoff(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4142 | return -EAGAIN; |
| 4143 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4144 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4145 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4146 | |
Chris Wilson | d3df42b | 2017-03-16 17:13:05 +0000 | [diff] [blame] | 4147 | wait_on_bit(&dev_priv->gpu_error.flags, |
| 4148 | I915_RESET_HANDOFF, |
| 4149 | TASK_UNINTERRUPTIBLE); |
| 4150 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4151 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4152 | } |
| 4153 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4154 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4155 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4156 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4157 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4158 | static int |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4159 | fault_irq_set(struct drm_i915_private *i915, |
| 4160 | unsigned long *irq, |
| 4161 | unsigned long val) |
| 4162 | { |
| 4163 | int err; |
| 4164 | |
| 4165 | err = mutex_lock_interruptible(&i915->drm.struct_mutex); |
| 4166 | if (err) |
| 4167 | return err; |
| 4168 | |
| 4169 | err = i915_gem_wait_for_idle(i915, |
| 4170 | I915_WAIT_LOCKED | |
| 4171 | I915_WAIT_INTERRUPTIBLE); |
| 4172 | if (err) |
| 4173 | goto err_unlock; |
| 4174 | |
| 4175 | /* Retire to kick idle work */ |
| 4176 | i915_gem_retire_requests(i915); |
| 4177 | GEM_BUG_ON(i915->gt.active_requests); |
| 4178 | |
| 4179 | *irq = val; |
| 4180 | mutex_unlock(&i915->drm.struct_mutex); |
| 4181 | |
| 4182 | /* Flush idle worker to disarm irq */ |
| 4183 | while (flush_delayed_work(&i915->gt.idle_work)) |
| 4184 | ; |
| 4185 | |
| 4186 | return 0; |
| 4187 | |
| 4188 | err_unlock: |
| 4189 | mutex_unlock(&i915->drm.struct_mutex); |
| 4190 | return err; |
| 4191 | } |
| 4192 | |
| 4193 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4194 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4195 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4196 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4197 | |
| 4198 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4199 | return 0; |
| 4200 | } |
| 4201 | |
| 4202 | static int |
| 4203 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4204 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4205 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4206 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4207 | return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4208 | } |
| 4209 | |
| 4210 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4211 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4212 | "0x%08llx\n"); |
| 4213 | |
| 4214 | static int |
| 4215 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4216 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4217 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4218 | |
| 4219 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4220 | |
| 4221 | return 0; |
| 4222 | } |
| 4223 | |
| 4224 | static int |
| 4225 | i915_ring_test_irq_set(void *data, u64 val) |
| 4226 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4227 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4228 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4229 | val &= INTEL_INFO(i915)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4230 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4231 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4232 | return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4233 | } |
| 4234 | |
| 4235 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4236 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4237 | "0x%08llx\n"); |
| 4238 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4239 | #define DROP_UNBOUND 0x1 |
| 4240 | #define DROP_BOUND 0x2 |
| 4241 | #define DROP_RETIRE 0x4 |
| 4242 | #define DROP_ACTIVE 0x8 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4243 | #define DROP_FREED 0x10 |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4244 | #define DROP_SHRINK_ALL 0x20 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4245 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4246 | DROP_BOUND | \ |
| 4247 | DROP_RETIRE | \ |
| 4248 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4249 | DROP_FREED | \ |
| 4250 | DROP_SHRINK_ALL) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4251 | static int |
| 4252 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4253 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4254 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4255 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4256 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4257 | } |
| 4258 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4259 | static int |
| 4260 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4261 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4262 | struct drm_i915_private *dev_priv = data; |
| 4263 | struct drm_device *dev = &dev_priv->drm; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4264 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4265 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4266 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4267 | |
| 4268 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4269 | * on ioctls on -EAGAIN. */ |
| 4270 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4271 | if (ret) |
| 4272 | return ret; |
| 4273 | |
| 4274 | if (val & DROP_ACTIVE) { |
Chris Wilson | 22dd3bb | 2016-09-09 14:11:50 +0100 | [diff] [blame] | 4275 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4276 | I915_WAIT_INTERRUPTIBLE | |
| 4277 | I915_WAIT_LOCKED); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4278 | if (ret) |
| 4279 | goto unlock; |
| 4280 | } |
| 4281 | |
| 4282 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4283 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4284 | |
Daniel Vetter | 05df49e | 2017-03-12 21:53:40 +0100 | [diff] [blame] | 4285 | lockdep_set_current_reclaim_state(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4286 | if (val & DROP_BOUND) |
| 4287 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4288 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4289 | if (val & DROP_UNBOUND) |
| 4290 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4291 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4292 | if (val & DROP_SHRINK_ALL) |
| 4293 | i915_gem_shrink_all(dev_priv); |
Daniel Vetter | 05df49e | 2017-03-12 21:53:40 +0100 | [diff] [blame] | 4294 | lockdep_clear_current_reclaim_state(); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4295 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4296 | unlock: |
| 4297 | mutex_unlock(&dev->struct_mutex); |
| 4298 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4299 | if (val & DROP_FREED) { |
| 4300 | synchronize_rcu(); |
Chris Wilson | bdeb978 | 2016-12-23 14:57:56 +0000 | [diff] [blame] | 4301 | i915_gem_drain_freed_objects(dev_priv); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4302 | } |
| 4303 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4304 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4305 | } |
| 4306 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4307 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4308 | i915_drop_caches_get, i915_drop_caches_set, |
| 4309 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4310 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4311 | static int |
| 4312 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4313 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4314 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4315 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4316 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4317 | return -ENODEV; |
| 4318 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4319 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4320 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4321 | } |
| 4322 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4323 | static int |
| 4324 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4325 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4326 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4327 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4328 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4329 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4330 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4331 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4332 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4333 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4334 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4335 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4336 | if (ret) |
| 4337 | return ret; |
| 4338 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4339 | /* |
| 4340 | * Turbo will still be enabled, but won't go above the set value. |
| 4341 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4342 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4343 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4344 | hw_max = dev_priv->rps.max_freq; |
| 4345 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4346 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4347 | 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] | 4348 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4349 | return -EINVAL; |
| 4350 | } |
| 4351 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4352 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4353 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 4354 | if (intel_set_rps(dev_priv, val)) |
| 4355 | DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n"); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4356 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4357 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4358 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4359 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4360 | } |
| 4361 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4362 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4363 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4364 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4365 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4366 | static int |
| 4367 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4368 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4369 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4370 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4371 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4372 | return -ENODEV; |
| 4373 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4374 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4375 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4376 | } |
| 4377 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4378 | static int |
| 4379 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4380 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4381 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4382 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4383 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4384 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4385 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4386 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4387 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4388 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4389 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4390 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4391 | if (ret) |
| 4392 | return ret; |
| 4393 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4394 | /* |
| 4395 | * Turbo will still be enabled, but won't go below the set value. |
| 4396 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4397 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4398 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4399 | hw_max = dev_priv->rps.max_freq; |
| 4400 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4401 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4402 | if (val < hw_min || |
| 4403 | val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4404 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4405 | return -EINVAL; |
| 4406 | } |
| 4407 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4408 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4409 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 4410 | if (intel_set_rps(dev_priv, val)) |
| 4411 | DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n"); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4412 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4413 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4414 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4415 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4416 | } |
| 4417 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4418 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4419 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4420 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4421 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4422 | static int |
| 4423 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4424 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4425 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4426 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4427 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4428 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4429 | return -ENODEV; |
| 4430 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4431 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4432 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4433 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4434 | |
| 4435 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4436 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4437 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4438 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4439 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4440 | } |
| 4441 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4442 | static int |
| 4443 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4444 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4445 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4446 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4447 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4448 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4449 | return -ENODEV; |
| 4450 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4451 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4452 | return -EINVAL; |
| 4453 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4454 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4455 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4456 | |
| 4457 | /* Update the cache sharing policy here as well */ |
| 4458 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4459 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4460 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4461 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4462 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4463 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4464 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4465 | } |
| 4466 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4467 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4468 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4469 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4470 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4471 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4472 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4473 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 4474 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4475 | int ss; |
| 4476 | u32 sig1[ss_max], sig2[ss_max]; |
| 4477 | |
| 4478 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4479 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4480 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4481 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4482 | |
| 4483 | for (ss = 0; ss < ss_max; ss++) { |
| 4484 | unsigned int eu_cnt; |
| 4485 | |
| 4486 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4487 | /* skip disabled subslice */ |
| 4488 | continue; |
| 4489 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4490 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4491 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4492 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4493 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4494 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4495 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4496 | sseu->eu_total += eu_cnt; |
| 4497 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4498 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4499 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4500 | } |
| 4501 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4502 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4503 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4504 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4505 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4506 | int s, ss; |
| 4507 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4508 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4509 | /* BXT has a single slice and at most 3 subslices. */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4510 | if (IS_GEN9_LP(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4511 | s_max = 1; |
| 4512 | ss_max = 3; |
| 4513 | } |
| 4514 | |
| 4515 | for (s = 0; s < s_max; s++) { |
| 4516 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4517 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4518 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4519 | } |
| 4520 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4521 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4522 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4523 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4524 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4525 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4526 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4527 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4528 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4529 | |
| 4530 | for (s = 0; s < s_max; s++) { |
| 4531 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4532 | /* skip disabled slice */ |
| 4533 | continue; |
| 4534 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4535 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4536 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 4537 | if (IS_GEN9_BC(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4538 | sseu->subslice_mask = |
| 4539 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4540 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4541 | for (ss = 0; ss < ss_max; ss++) { |
| 4542 | unsigned int eu_cnt; |
| 4543 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4544 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4545 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4546 | /* skip disabled subslice */ |
| 4547 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4548 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4549 | sseu->subslice_mask |= BIT(ss); |
| 4550 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4551 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4552 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4553 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4554 | sseu->eu_total += eu_cnt; |
| 4555 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4556 | sseu->eu_per_subslice, |
| 4557 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4558 | } |
| 4559 | } |
| 4560 | } |
| 4561 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4562 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4563 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4564 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4565 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4566 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4567 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4568 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4569 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4570 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4571 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4572 | sseu->eu_per_subslice = |
| 4573 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4574 | sseu->eu_total = sseu->eu_per_subslice * |
| 4575 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4576 | |
| 4577 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4578 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4579 | u8 subslice_7eu = |
| 4580 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4581 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4582 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4583 | } |
| 4584 | } |
| 4585 | } |
| 4586 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4587 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4588 | const struct sseu_dev_info *sseu) |
| 4589 | { |
| 4590 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4591 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 4592 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4593 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4594 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4595 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4596 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4597 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4598 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4599 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 4600 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4601 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4602 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4603 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4604 | sseu->eu_total); |
| 4605 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4606 | sseu->eu_per_subslice); |
| 4607 | |
| 4608 | if (!is_available_info) |
| 4609 | return; |
| 4610 | |
| 4611 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4612 | if (HAS_POOLED_EU(dev_priv)) |
| 4613 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4614 | |
| 4615 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4616 | yesno(sseu->has_slice_pg)); |
| 4617 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4618 | yesno(sseu->has_subslice_pg)); |
| 4619 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4620 | yesno(sseu->has_eu_pg)); |
| 4621 | } |
| 4622 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4623 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4624 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4625 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4626 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4627 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4628 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4629 | return -ENODEV; |
| 4630 | |
| 4631 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4632 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4633 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4634 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4635 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4636 | |
| 4637 | intel_runtime_pm_get(dev_priv); |
| 4638 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4639 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4640 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4641 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4642 | broadwell_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4643 | } else if (INTEL_GEN(dev_priv) >= 9) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4644 | gen9_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4645 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4646 | |
| 4647 | intel_runtime_pm_put(dev_priv); |
| 4648 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4649 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4650 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4651 | return 0; |
| 4652 | } |
| 4653 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4654 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4655 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4656 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4657 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4658 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4659 | return 0; |
| 4660 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4661 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4662 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4663 | |
| 4664 | return 0; |
| 4665 | } |
| 4666 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4667 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4668 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4669 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4670 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4671 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4672 | return 0; |
| 4673 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4674 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4675 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4676 | |
| 4677 | return 0; |
| 4678 | } |
| 4679 | |
| 4680 | static const struct file_operations i915_forcewake_fops = { |
| 4681 | .owner = THIS_MODULE, |
| 4682 | .open = i915_forcewake_open, |
| 4683 | .release = i915_forcewake_release, |
| 4684 | }; |
| 4685 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4686 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4687 | { |
| 4688 | struct drm_i915_private *dev_priv = m->private; |
| 4689 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4690 | |
| 4691 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4692 | seq_printf(m, "Detected: %s\n", |
| 4693 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4694 | |
| 4695 | return 0; |
| 4696 | } |
| 4697 | |
| 4698 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4699 | const char __user *ubuf, size_t len, |
| 4700 | loff_t *offp) |
| 4701 | { |
| 4702 | struct seq_file *m = file->private_data; |
| 4703 | struct drm_i915_private *dev_priv = m->private; |
| 4704 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4705 | unsigned int new_threshold; |
| 4706 | int i; |
| 4707 | char *newline; |
| 4708 | char tmp[16]; |
| 4709 | |
| 4710 | if (len >= sizeof(tmp)) |
| 4711 | return -EINVAL; |
| 4712 | |
| 4713 | if (copy_from_user(tmp, ubuf, len)) |
| 4714 | return -EFAULT; |
| 4715 | |
| 4716 | tmp[len] = '\0'; |
| 4717 | |
| 4718 | /* Strip newline, if any */ |
| 4719 | newline = strchr(tmp, '\n'); |
| 4720 | if (newline) |
| 4721 | *newline = '\0'; |
| 4722 | |
| 4723 | if (strcmp(tmp, "reset") == 0) |
| 4724 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4725 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4726 | return -EINVAL; |
| 4727 | |
| 4728 | if (new_threshold > 0) |
| 4729 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4730 | new_threshold); |
| 4731 | else |
| 4732 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4733 | |
| 4734 | spin_lock_irq(&dev_priv->irq_lock); |
| 4735 | hotplug->hpd_storm_threshold = new_threshold; |
| 4736 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4737 | for_each_hpd_pin(i) |
| 4738 | hotplug->stats[i].count = 0; |
| 4739 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4740 | |
| 4741 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4742 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4743 | |
| 4744 | return len; |
| 4745 | } |
| 4746 | |
| 4747 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4748 | { |
| 4749 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4750 | } |
| 4751 | |
| 4752 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4753 | .owner = THIS_MODULE, |
| 4754 | .open = i915_hpd_storm_ctl_open, |
| 4755 | .read = seq_read, |
| 4756 | .llseek = seq_lseek, |
| 4757 | .release = single_release, |
| 4758 | .write = i915_hpd_storm_ctl_write |
| 4759 | }; |
| 4760 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4761 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4762 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4763 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4764 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 4765 | {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4766 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4767 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4768 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4769 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4770 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4771 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4772 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4773 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4774 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4775 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4776 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4777 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4778 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4779 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4780 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4781 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4782 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4783 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4784 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4785 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4786 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4787 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4788 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4789 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4790 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4791 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4792 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4793 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4794 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4795 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4796 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4797 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4798 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4799 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4800 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4801 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4802 | {"i915_engine_info", i915_engine_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4803 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4804 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4805 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4806 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4807 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4808 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4809 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4810 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4811 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4812 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4813 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4814 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4815 | const char *name; |
| 4816 | const struct file_operations *fops; |
| 4817 | } i915_debugfs_files[] = { |
| 4818 | {"i915_wedged", &i915_wedged_fops}, |
| 4819 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4820 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4821 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4822 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4823 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4824 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4825 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4826 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4827 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4828 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4829 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4830 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4831 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4832 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4833 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 4834 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4835 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4836 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4837 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4838 | {"i915_guc_log_control", &i915_guc_log_control_fops}, |
| 4839 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4840 | }; |
| 4841 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4842 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4843 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4844 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4845 | struct dentry *ent; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4846 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4847 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4848 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4849 | minor->debugfs_root, to_i915(minor->dev), |
| 4850 | &i915_forcewake_fops); |
| 4851 | if (!ent) |
| 4852 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4853 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame] | 4854 | ret = intel_pipe_crc_create(minor); |
| 4855 | if (ret) |
| 4856 | return ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4857 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4858 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4859 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4860 | S_IRUGO | S_IWUSR, |
| 4861 | minor->debugfs_root, |
| 4862 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4863 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4864 | if (!ent) |
| 4865 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4866 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4867 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4868 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4869 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4870 | minor->debugfs_root, minor); |
| 4871 | } |
| 4872 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4873 | struct dpcd_block { |
| 4874 | /* DPCD dump start address. */ |
| 4875 | unsigned int offset; |
| 4876 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4877 | unsigned int end; |
| 4878 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4879 | size_t size; |
| 4880 | /* Only valid for eDP. */ |
| 4881 | bool edp; |
| 4882 | }; |
| 4883 | |
| 4884 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4885 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4886 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4887 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4888 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4889 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4890 | { .offset = DP_SET_POWER }, |
| 4891 | { .offset = DP_EDP_DPCD_REV }, |
| 4892 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4893 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4894 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4895 | }; |
| 4896 | |
| 4897 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4898 | { |
| 4899 | struct drm_connector *connector = m->private; |
| 4900 | struct intel_dp *intel_dp = |
| 4901 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4902 | uint8_t buf[16]; |
| 4903 | ssize_t err; |
| 4904 | int i; |
| 4905 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4906 | if (connector->status != connector_status_connected) |
| 4907 | return -ENODEV; |
| 4908 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4909 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4910 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4911 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4912 | |
| 4913 | if (b->edp && |
| 4914 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4915 | continue; |
| 4916 | |
| 4917 | /* low tech for now */ |
| 4918 | if (WARN_ON(size > sizeof(buf))) |
| 4919 | continue; |
| 4920 | |
| 4921 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 4922 | if (err <= 0) { |
| 4923 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 4924 | size, b->offset, err); |
| 4925 | continue; |
| 4926 | } |
| 4927 | |
| 4928 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4929 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4930 | |
| 4931 | return 0; |
| 4932 | } |
| 4933 | |
| 4934 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 4935 | { |
| 4936 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 4937 | } |
| 4938 | |
| 4939 | static const struct file_operations i915_dpcd_fops = { |
| 4940 | .owner = THIS_MODULE, |
| 4941 | .open = i915_dpcd_open, |
| 4942 | .read = seq_read, |
| 4943 | .llseek = seq_lseek, |
| 4944 | .release = single_release, |
| 4945 | }; |
| 4946 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4947 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4948 | { |
| 4949 | struct drm_connector *connector = m->private; |
| 4950 | struct intel_dp *intel_dp = |
| 4951 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4952 | |
| 4953 | if (connector->status != connector_status_connected) |
| 4954 | return -ENODEV; |
| 4955 | |
| 4956 | seq_printf(m, "Panel power up delay: %d\n", |
| 4957 | intel_dp->panel_power_up_delay); |
| 4958 | seq_printf(m, "Panel power down delay: %d\n", |
| 4959 | intel_dp->panel_power_down_delay); |
| 4960 | seq_printf(m, "Backlight on delay: %d\n", |
| 4961 | intel_dp->backlight_on_delay); |
| 4962 | seq_printf(m, "Backlight off delay: %d\n", |
| 4963 | intel_dp->backlight_off_delay); |
| 4964 | |
| 4965 | return 0; |
| 4966 | } |
| 4967 | |
| 4968 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 4969 | { |
| 4970 | return single_open(file, i915_panel_show, inode->i_private); |
| 4971 | } |
| 4972 | |
| 4973 | static const struct file_operations i915_panel_fops = { |
| 4974 | .owner = THIS_MODULE, |
| 4975 | .open = i915_panel_open, |
| 4976 | .read = seq_read, |
| 4977 | .llseek = seq_lseek, |
| 4978 | .release = single_release, |
| 4979 | }; |
| 4980 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4981 | /** |
| 4982 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4983 | * @connector: pointer to a registered drm_connector |
| 4984 | * |
| 4985 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4986 | * drm_debugfs_connector_remove(). |
| 4987 | * |
| 4988 | * Returns 0 on success, negative error codes on error. |
| 4989 | */ |
| 4990 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 4991 | { |
| 4992 | struct dentry *root = connector->debugfs_entry; |
| 4993 | |
| 4994 | /* The connector must have been registered beforehands. */ |
| 4995 | if (!root) |
| 4996 | return -ENODEV; |
| 4997 | |
| 4998 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4999 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5000 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5001 | connector, &i915_dpcd_fops); |
| 5002 | |
| 5003 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5004 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5005 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5006 | |
| 5007 | return 0; |
| 5008 | } |