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); |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 232 | objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 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: |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 277 | kvfree(objects); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 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 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 1015 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1016 | struct i915_gpu_state *gpu; |
| 1017 | |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 1018 | intel_runtime_pm_get(i915); |
| 1019 | gpu = i915_capture_gpu_state(i915); |
| 1020 | intel_runtime_pm_put(i915); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1021 | if (!gpu) |
| 1022 | return -ENOMEM; |
| 1023 | |
| 1024 | file->private_data = gpu; |
| 1025 | return 0; |
| 1026 | } |
| 1027 | |
| 1028 | static const struct file_operations i915_gpu_info_fops = { |
| 1029 | .owner = THIS_MODULE, |
| 1030 | .open = i915_gpu_info_open, |
| 1031 | .read = gpu_state_read, |
| 1032 | .llseek = default_llseek, |
| 1033 | .release = gpu_state_release, |
| 1034 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1035 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1036 | static ssize_t |
| 1037 | i915_error_state_write(struct file *filp, |
| 1038 | const char __user *ubuf, |
| 1039 | size_t cnt, |
| 1040 | loff_t *ppos) |
| 1041 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1042 | struct i915_gpu_state *error = filp->private_data; |
| 1043 | |
| 1044 | if (!error) |
| 1045 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1046 | |
| 1047 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1048 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1049 | |
| 1050 | return cnt; |
| 1051 | } |
| 1052 | |
| 1053 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1054 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1055 | file->private_data = i915_first_error_state(inode->i_private); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1056 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1057 | } |
| 1058 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1059 | static const struct file_operations i915_error_state_fops = { |
| 1060 | .owner = THIS_MODULE, |
| 1061 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1062 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1063 | .write = i915_error_state_write, |
| 1064 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1065 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1066 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1067 | #endif |
| 1068 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1069 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1070 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1071 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1072 | struct drm_i915_private *dev_priv = data; |
| 1073 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1074 | int ret; |
| 1075 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1076 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1077 | if (ret) |
| 1078 | return ret; |
| 1079 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1080 | ret = i915_gem_set_global_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1081 | mutex_unlock(&dev->struct_mutex); |
| 1082 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1083 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1084 | } |
| 1085 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1086 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
Chris Wilson | 9b6586a | 2017-02-23 07:44:08 +0000 | [diff] [blame] | 1087 | NULL, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1088 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1089 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1090 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1091 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1092 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1093 | int ret = 0; |
| 1094 | |
| 1095 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1096 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1097 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1098 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1099 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1100 | |
| 1101 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1102 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1103 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1104 | MEMSTAT_VID_SHIFT); |
| 1105 | seq_printf(m, "Current P-state: %d\n", |
| 1106 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1107 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1108 | u32 freq_sts; |
| 1109 | |
| 1110 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1111 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1112 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1113 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1114 | |
| 1115 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1116 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1117 | |
| 1118 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1119 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1120 | |
| 1121 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1122 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1123 | |
| 1124 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1125 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1126 | |
| 1127 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1128 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1129 | |
| 1130 | seq_printf(m, |
| 1131 | "efficient (RPe) frequency: %d MHz\n", |
| 1132 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1133 | mutex_unlock(&dev_priv->rps.hw_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1134 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1135 | u32 rp_state_limits; |
| 1136 | u32 gt_perf_status; |
| 1137 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1138 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1139 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1140 | u32 rpupei, rpcurup, rpprevup; |
| 1141 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1142 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1143 | int max_freq; |
| 1144 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1145 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1146 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1147 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1148 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1149 | } else { |
| 1150 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1151 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1152 | } |
| 1153 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1154 | /* RPSTAT1 is in the GT power well */ |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1155 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1156 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1157 | reqf = I915_READ(GEN6_RPNSWREQ); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1158 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1159 | reqf >>= 23; |
| 1160 | else { |
| 1161 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1162 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1163 | reqf >>= 24; |
| 1164 | else |
| 1165 | reqf >>= 25; |
| 1166 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1167 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1168 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1169 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1170 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1171 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1172 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1173 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1174 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1175 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1176 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1177 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1178 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1179 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1180 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1181 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1182 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1183 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1184 | else |
| 1185 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1186 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1187 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1188 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1189 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1190 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1191 | pm_ier = I915_READ(GEN6_PMIER); |
| 1192 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1193 | pm_isr = I915_READ(GEN6_PMISR); |
| 1194 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1195 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1196 | } else { |
| 1197 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1198 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1199 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1200 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1201 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1202 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1203 | 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] | 1204 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1205 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
| 1206 | dev_priv->rps.pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1207 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1208 | seq_printf(m, "Render p-state ratio: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1209 | (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1210 | seq_printf(m, "Render p-state VID: %d\n", |
| 1211 | gt_perf_status & 0xff); |
| 1212 | seq_printf(m, "Render p-state limit: %d\n", |
| 1213 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1214 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1215 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1216 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1217 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1218 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1219 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1220 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1221 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1222 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1223 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1224 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1225 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1226 | seq_printf(m, "Up threshold: %d%%\n", |
| 1227 | dev_priv->rps.up_threshold); |
| 1228 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1229 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1230 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1231 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1232 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1233 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1234 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1235 | seq_printf(m, "Down threshold: %d%%\n", |
| 1236 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1237 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1238 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1239 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1240 | max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1241 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1242 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1243 | |
| 1244 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1245 | max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1246 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1247 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1248 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1249 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1250 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1251 | max_freq *= (IS_GEN9_BC(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1252 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1253 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1254 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1255 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1256 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1257 | seq_printf(m, "Current freq: %d MHz\n", |
| 1258 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1259 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1260 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1261 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1262 | seq_printf(m, "Min freq: %d MHz\n", |
| 1263 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1264 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1265 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1266 | seq_printf(m, "Max freq: %d MHz\n", |
| 1267 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1268 | seq_printf(m, |
| 1269 | "efficient (RPe) frequency: %d MHz\n", |
| 1270 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1271 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1272 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1273 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1274 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1275 | 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] | 1276 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1277 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1278 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1279 | intel_runtime_pm_put(dev_priv); |
| 1280 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1281 | } |
| 1282 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1283 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1284 | struct seq_file *m, |
| 1285 | struct intel_instdone *instdone) |
| 1286 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1287 | int slice; |
| 1288 | int subslice; |
| 1289 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1290 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1291 | instdone->instdone); |
| 1292 | |
| 1293 | if (INTEL_GEN(dev_priv) <= 3) |
| 1294 | return; |
| 1295 | |
| 1296 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1297 | instdone->slice_common); |
| 1298 | |
| 1299 | if (INTEL_GEN(dev_priv) <= 6) |
| 1300 | return; |
| 1301 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1302 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1303 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1304 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1305 | |
| 1306 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1307 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1308 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1309 | } |
| 1310 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1311 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1312 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1313 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1314 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1315 | u64 acthd[I915_NUM_ENGINES]; |
| 1316 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1317 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1318 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1319 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1320 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1321 | seq_puts(m, "Wedged\n"); |
| 1322 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
| 1323 | seq_puts(m, "Reset in progress: struct_mutex backoff\n"); |
| 1324 | if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags)) |
| 1325 | seq_puts(m, "Reset in progress: reset handoff to waiter\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1326 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1327 | seq_puts(m, "Waiter holding struct mutex\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1328 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1329 | seq_puts(m, "struct_mutex blocked for reset\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1330 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1331 | if (!i915.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1332 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1333 | return 0; |
| 1334 | } |
| 1335 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1336 | intel_runtime_pm_get(dev_priv); |
| 1337 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1338 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1339 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1340 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1341 | } |
| 1342 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1343 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1344 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1345 | intel_runtime_pm_put(dev_priv); |
| 1346 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1347 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1348 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1349 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1350 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1351 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1352 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1353 | else |
| 1354 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1355 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1356 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1357 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1358 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1359 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1360 | struct rb_node *rb; |
| 1361 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1362 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1363 | seq_printf(m, "\tseqno = %x [current %x, last %x], inflight %d\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1364 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1365 | intel_engine_last_submit(engine), |
| 1366 | engine->timeline->inflight_seqnos); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1367 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1368 | yesno(intel_engine_has_waiter(engine)), |
| 1369 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1370 | &dev_priv->gpu_error.missed_irq_rings)), |
| 1371 | yesno(engine->hangcheck.stalled)); |
| 1372 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1373 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1374 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 1375 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1376 | |
| 1377 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1378 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1379 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1380 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1381 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1382 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1383 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1384 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1385 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1386 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1387 | engine->hangcheck.action, |
| 1388 | jiffies_to_msecs(jiffies - |
| 1389 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1390 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1391 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1392 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1393 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1394 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1395 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1396 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1397 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1398 | i915_instdone_info(dev_priv, m, |
| 1399 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1400 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | return 0; |
| 1404 | } |
| 1405 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame^] | 1406 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1407 | { |
| 1408 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1409 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1410 | struct intel_engine_cs *engine; |
| 1411 | enum intel_engine_id id; |
| 1412 | |
| 1413 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1414 | |
| 1415 | for_each_engine(engine, dev_priv, id) { |
| 1416 | seq_printf(m, "%s = %u\n", engine->name, |
| 1417 | i915_reset_engine_count(error, engine)); |
| 1418 | } |
| 1419 | |
| 1420 | return 0; |
| 1421 | } |
| 1422 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1423 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1424 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1425 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1426 | u32 rgvmodectl, rstdbyctl; |
| 1427 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1428 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1429 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1430 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1431 | crstandvid = I915_READ16(CRSTANDVID); |
| 1432 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1433 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1434 | seq_printf(m, "Boost freq: %d\n", |
| 1435 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1436 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1437 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1438 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1439 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1440 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1441 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1442 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1443 | seq_printf(m, "Starting frequency: P%d\n", |
| 1444 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1445 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1446 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1447 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1448 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1449 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1450 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1451 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1452 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1453 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1454 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1455 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1456 | break; |
| 1457 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1458 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1459 | break; |
| 1460 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1461 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1462 | break; |
| 1463 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1464 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1465 | break; |
| 1466 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1467 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1468 | break; |
| 1469 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1470 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1471 | break; |
| 1472 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1473 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1474 | break; |
| 1475 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1476 | |
| 1477 | return 0; |
| 1478 | } |
| 1479 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1480 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1481 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1482 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1483 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1484 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1485 | |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1486 | for_each_fw_domain(fw_domain, i915, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1487 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1488 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1489 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1490 | |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1494 | static void print_rc6_res(struct seq_file *m, |
| 1495 | const char *title, |
| 1496 | const i915_reg_t reg) |
| 1497 | { |
| 1498 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1499 | |
| 1500 | seq_printf(m, "%s %u (%llu us)\n", |
| 1501 | title, I915_READ(reg), |
| 1502 | intel_rc6_residency_us(dev_priv, reg)); |
| 1503 | } |
| 1504 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1505 | static int vlv_drpc_info(struct seq_file *m) |
| 1506 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1507 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1508 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1509 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1510 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1511 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1512 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1513 | |
| 1514 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1515 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1516 | seq_printf(m, "Turbo enabled: %s\n", |
| 1517 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1518 | seq_printf(m, "HW control enabled: %s\n", |
| 1519 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1520 | seq_printf(m, "SW control enabled: %s\n", |
| 1521 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1522 | GEN6_RP_MEDIA_SW_MODE)); |
| 1523 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1524 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1525 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1526 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1527 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1528 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1529 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1530 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1531 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1532 | 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] | 1533 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1534 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1535 | } |
| 1536 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1537 | static int gen6_drpc_info(struct seq_file *m) |
| 1538 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1539 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1540 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1541 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1542 | unsigned forcewake_count; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1543 | int count = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1544 | |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1545 | 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] | 1546 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1547 | seq_puts(m, "RC information inaccurate because somebody " |
| 1548 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1549 | } else { |
| 1550 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1551 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1552 | udelay(10); |
| 1553 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1554 | } |
| 1555 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1556 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1557 | 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] | 1558 | |
| 1559 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1560 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1561 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1562 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1563 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1564 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1565 | |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1566 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1567 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1568 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1569 | |
| 1570 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1571 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1572 | seq_printf(m, "HW control enabled: %s\n", |
| 1573 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1574 | seq_printf(m, "SW control enabled: %s\n", |
| 1575 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1576 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1577 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1578 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1579 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1580 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1581 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1582 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1583 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1584 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1585 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1586 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1587 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1588 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1589 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1590 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1591 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1592 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1593 | case GEN6_RC0: |
| 1594 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1595 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1596 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1597 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1598 | break; |
| 1599 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1600 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1601 | break; |
| 1602 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1603 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1604 | break; |
| 1605 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1606 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1607 | break; |
| 1608 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1609 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1610 | break; |
| 1611 | } |
| 1612 | |
| 1613 | seq_printf(m, "Core Power Down: %s\n", |
| 1614 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1615 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1616 | seq_printf(m, "Render Power Well: %s\n", |
| 1617 | (gen9_powergate_status & |
| 1618 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1619 | seq_printf(m, "Media Power Well: %s\n", |
| 1620 | (gen9_powergate_status & |
| 1621 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1622 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1623 | |
| 1624 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1625 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1626 | GEN6_GT_GFX_RC6_LOCKED); |
| 1627 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1628 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1629 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1630 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1631 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1632 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1633 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1634 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1635 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1636 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1637 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1641 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1642 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1643 | int err; |
| 1644 | |
| 1645 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1646 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1647 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1648 | err = vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1649 | else if (INTEL_GEN(dev_priv) >= 6) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1650 | err = gen6_drpc_info(m); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1651 | else |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1652 | err = ironlake_drpc_info(m); |
| 1653 | |
| 1654 | intel_runtime_pm_put(dev_priv); |
| 1655 | |
| 1656 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1657 | } |
| 1658 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1659 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1660 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1661 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1662 | |
| 1663 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1664 | dev_priv->fb_tracking.busy_bits); |
| 1665 | |
| 1666 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1667 | dev_priv->fb_tracking.flip_bits); |
| 1668 | |
| 1669 | return 0; |
| 1670 | } |
| 1671 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1672 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1673 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1674 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1675 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1676 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1677 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1678 | return 0; |
| 1679 | } |
| 1680 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1681 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1682 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1683 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1684 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1685 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1686 | else |
| 1687 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1688 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1689 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1690 | if (intel_fbc_is_active(dev_priv)) { |
| 1691 | u32 mask; |
| 1692 | |
| 1693 | if (INTEL_GEN(dev_priv) >= 8) |
| 1694 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1695 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1696 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1697 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1698 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1699 | else if (IS_G4X(dev_priv)) |
| 1700 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1701 | else |
| 1702 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1703 | FBC_STAT_COMPRESSED); |
| 1704 | |
| 1705 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1706 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1707 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1708 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1709 | intel_runtime_pm_put(dev_priv); |
| 1710 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1711 | return 0; |
| 1712 | } |
| 1713 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1714 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1715 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1716 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1717 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1718 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1719 | return -ENODEV; |
| 1720 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1721 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1722 | |
| 1723 | return 0; |
| 1724 | } |
| 1725 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1726 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1727 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1728 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1729 | u32 reg; |
| 1730 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1731 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1732 | return -ENODEV; |
| 1733 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1734 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1735 | |
| 1736 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1737 | dev_priv->fbc.false_color = val; |
| 1738 | |
| 1739 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1740 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1741 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1742 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1743 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1744 | return 0; |
| 1745 | } |
| 1746 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1747 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1748 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1749 | "%llu\n"); |
| 1750 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1751 | static int i915_ips_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); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1754 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1755 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1756 | seq_puts(m, "not supported\n"); |
| 1757 | return 0; |
| 1758 | } |
| 1759 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1760 | intel_runtime_pm_get(dev_priv); |
| 1761 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1762 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1763 | yesno(i915.enable_ips)); |
| 1764 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1765 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1766 | seq_puts(m, "Currently: unknown\n"); |
| 1767 | } else { |
| 1768 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1769 | seq_puts(m, "Currently: enabled\n"); |
| 1770 | else |
| 1771 | seq_puts(m, "Currently: disabled\n"); |
| 1772 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1773 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1774 | intel_runtime_pm_put(dev_priv); |
| 1775 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1776 | return 0; |
| 1777 | } |
| 1778 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1779 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1780 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1781 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1782 | bool sr_enabled = false; |
| 1783 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1784 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1785 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1786 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1787 | if (INTEL_GEN(dev_priv) >= 9) |
| 1788 | /* no global SR status; inspect per-plane WM */; |
| 1789 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1790 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1791 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1792 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1793 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1794 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1795 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1796 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1797 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1798 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1799 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1800 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1801 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1802 | intel_runtime_pm_put(dev_priv); |
| 1803 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1804 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1805 | |
| 1806 | return 0; |
| 1807 | } |
| 1808 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1809 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1810 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1811 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1812 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1813 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1814 | int ret; |
| 1815 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1816 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1817 | return -ENODEV; |
| 1818 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1819 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1820 | if (ret) |
| 1821 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1822 | |
| 1823 | temp = i915_mch_val(dev_priv); |
| 1824 | chipset = i915_chipset_val(dev_priv); |
| 1825 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1826 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1827 | |
| 1828 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1829 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1830 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1831 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1832 | |
| 1833 | return 0; |
| 1834 | } |
| 1835 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1836 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1837 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1838 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1839 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1840 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1841 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1842 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1843 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1844 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1845 | return 0; |
| 1846 | } |
| 1847 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1848 | intel_runtime_pm_get(dev_priv); |
| 1849 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1850 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1851 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1852 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1853 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1854 | if (IS_GEN9_BC(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1855 | /* Convert GT frequency to 50 HZ units */ |
| 1856 | min_gpu_freq = |
| 1857 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1858 | max_gpu_freq = |
| 1859 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1860 | } else { |
| 1861 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1862 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1863 | } |
| 1864 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1865 | 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] | 1866 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1867 | 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] | 1868 | ia_freq = gpu_freq; |
| 1869 | sandybridge_pcode_read(dev_priv, |
| 1870 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1871 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1872 | 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] | 1873 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1874 | (IS_GEN9_BC(dev_priv) ? |
| 1875 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1876 | ((ia_freq >> 0) & 0xff) * 100, |
| 1877 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1878 | } |
| 1879 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1880 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1881 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1882 | out: |
| 1883 | intel_runtime_pm_put(dev_priv); |
| 1884 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1885 | } |
| 1886 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1887 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1888 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1889 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1890 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1891 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1892 | int ret; |
| 1893 | |
| 1894 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1895 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1896 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1897 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1898 | if (opregion->header) |
| 1899 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1900 | |
| 1901 | mutex_unlock(&dev->struct_mutex); |
| 1902 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1903 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1904 | return 0; |
| 1905 | } |
| 1906 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1907 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1908 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1909 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1910 | |
| 1911 | if (opregion->vbt) |
| 1912 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1913 | |
| 1914 | return 0; |
| 1915 | } |
| 1916 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1917 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1918 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1919 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1920 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1921 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1922 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1923 | int ret; |
| 1924 | |
| 1925 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1926 | if (ret) |
| 1927 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1928 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1929 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1930 | if (dev_priv->fbdev) { |
| 1931 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1932 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1933 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1934 | fbdev_fb->base.width, |
| 1935 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1936 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1937 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1938 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1939 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1940 | describe_obj(m, fbdev_fb->obj); |
| 1941 | seq_putc(m, '\n'); |
| 1942 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1943 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1944 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1945 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1946 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1947 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1948 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1949 | continue; |
| 1950 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1951 | 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] | 1952 | fb->base.width, |
| 1953 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1954 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1955 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1956 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1957 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1958 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1959 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1960 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1961 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1962 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1963 | |
| 1964 | return 0; |
| 1965 | } |
| 1966 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1967 | 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] | 1968 | { |
Chris Wilson | fe085f1 | 2017-03-21 10:25:52 +0000 | [diff] [blame] | 1969 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)", |
| 1970 | ring->space, ring->head, ring->tail); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1971 | } |
| 1972 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1973 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1974 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1975 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1976 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1977 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1978 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1979 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1980 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1981 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1982 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1983 | if (ret) |
| 1984 | return ret; |
| 1985 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1986 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1987 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1988 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1989 | struct task_struct *task; |
| 1990 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1991 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1992 | if (task) { |
| 1993 | seq_printf(m, "(%s [%d]) ", |
| 1994 | task->comm, task->pid); |
| 1995 | put_task_struct(task); |
| 1996 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1997 | } else if (IS_ERR(ctx->file_priv)) { |
| 1998 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1999 | } else { |
| 2000 | seq_puts(m, "(kernel) "); |
| 2001 | } |
| 2002 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 2003 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 2004 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2005 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2006 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 2007 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 2008 | |
| 2009 | seq_printf(m, "%s: ", engine->name); |
| 2010 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 2011 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2012 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 2013 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 2014 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2015 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2016 | } |
| 2017 | |
Chris Wilson | 4ff4b44 | 2017-06-16 15:05:16 +0100 | [diff] [blame] | 2018 | seq_printf(m, |
| 2019 | "\tvma hashtable size=%u (actual %lu), count=%u\n", |
| 2020 | ctx->vma_lut.ht_size, |
| 2021 | BIT(ctx->vma_lut.ht_bits), |
| 2022 | ctx->vma_lut.ht_count); |
| 2023 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2024 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 2025 | } |
| 2026 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 2027 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2028 | |
| 2029 | return 0; |
| 2030 | } |
| 2031 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2032 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2033 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2034 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2035 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2036 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2037 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2038 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2039 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2040 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2041 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2042 | if (!vma) { |
| 2043 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2044 | return; |
| 2045 | } |
| 2046 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2047 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 2048 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 2049 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2050 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2051 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2052 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2053 | return; |
| 2054 | } |
| 2055 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2056 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 2057 | if (page) { |
| 2058 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2059 | |
| 2060 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2061 | seq_printf(m, |
| 2062 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2063 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2064 | reg_state[j], reg_state[j + 1], |
| 2065 | reg_state[j + 2], reg_state[j + 3]); |
| 2066 | } |
| 2067 | kunmap_atomic(reg_state); |
| 2068 | } |
| 2069 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2070 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2071 | seq_putc(m, '\n'); |
| 2072 | } |
| 2073 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2074 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2075 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2076 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2077 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2078 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2079 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2080 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2081 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2082 | |
| 2083 | if (!i915.enable_execlists) { |
| 2084 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2085 | return 0; |
| 2086 | } |
| 2087 | |
| 2088 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2089 | if (ret) |
| 2090 | return ret; |
| 2091 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 2092 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2093 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2094 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2095 | |
| 2096 | mutex_unlock(&dev->struct_mutex); |
| 2097 | |
| 2098 | return 0; |
| 2099 | } |
| 2100 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2101 | static const char *swizzle_string(unsigned swizzle) |
| 2102 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2103 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2104 | case I915_BIT_6_SWIZZLE_NONE: |
| 2105 | return "none"; |
| 2106 | case I915_BIT_6_SWIZZLE_9: |
| 2107 | return "bit9"; |
| 2108 | case I915_BIT_6_SWIZZLE_9_10: |
| 2109 | return "bit9/bit10"; |
| 2110 | case I915_BIT_6_SWIZZLE_9_11: |
| 2111 | return "bit9/bit11"; |
| 2112 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2113 | return "bit9/bit10/bit11"; |
| 2114 | case I915_BIT_6_SWIZZLE_9_17: |
| 2115 | return "bit9/bit17"; |
| 2116 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2117 | return "bit9/bit10/bit17"; |
| 2118 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2119 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2120 | } |
| 2121 | |
| 2122 | return "bug"; |
| 2123 | } |
| 2124 | |
| 2125 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2126 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2127 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2128 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2129 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2130 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2131 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2132 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2133 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2134 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2135 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2136 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2137 | seq_printf(m, "DDC = 0x%08x\n", |
| 2138 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2139 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2140 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2141 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2142 | I915_READ16(C0DRB3)); |
| 2143 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2144 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2145 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2146 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2147 | I915_READ(MAD_DIMM_C0)); |
| 2148 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2149 | I915_READ(MAD_DIMM_C1)); |
| 2150 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2151 | I915_READ(MAD_DIMM_C2)); |
| 2152 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2153 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2154 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2155 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2156 | I915_READ(GAMTARBMODE)); |
| 2157 | else |
| 2158 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2159 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2160 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2161 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2162 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2163 | |
| 2164 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2165 | seq_puts(m, "L-shaped memory detected\n"); |
| 2166 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2167 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2168 | |
| 2169 | return 0; |
| 2170 | } |
| 2171 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2172 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2173 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2174 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2175 | struct seq_file *m = data; |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2176 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2177 | |
| 2178 | if (!ppgtt) { |
| 2179 | seq_printf(m, " no ppgtt for context %d\n", |
| 2180 | ctx->user_handle); |
| 2181 | return 0; |
| 2182 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2183 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2184 | if (i915_gem_context_is_default(ctx)) |
| 2185 | seq_puts(m, " default context:\n"); |
| 2186 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2187 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2188 | ppgtt->debug_dump(ppgtt, m); |
| 2189 | |
| 2190 | return 0; |
| 2191 | } |
| 2192 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2193 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2194 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2195 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2196 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2197 | struct intel_engine_cs *engine; |
| 2198 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2199 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2200 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2201 | if (!ppgtt) |
| 2202 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2203 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2204 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2205 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2206 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2207 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2208 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2209 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2210 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2211 | } |
| 2212 | } |
| 2213 | } |
| 2214 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2215 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2216 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2217 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2218 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2219 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2220 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2221 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2222 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2223 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2224 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2225 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2226 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2227 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2228 | I915_READ(RING_MODE_GEN7(engine))); |
| 2229 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2230 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2231 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2232 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2233 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2234 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2235 | } |
| 2236 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2237 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2238 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2239 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2240 | 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] | 2241 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2242 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2243 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2244 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2245 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2246 | } |
| 2247 | |
| 2248 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2249 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2250 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2251 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2252 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2253 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2254 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2255 | mutex_lock(&dev->filelist_mutex); |
| 2256 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2257 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2258 | goto out_unlock; |
| 2259 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2260 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2261 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2262 | if (INTEL_GEN(dev_priv) >= 8) |
| 2263 | gen8_ppgtt_info(m, dev_priv); |
| 2264 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2265 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2266 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2267 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2268 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2269 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2270 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2271 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2272 | if (!task) { |
| 2273 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2274 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2275 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2276 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2277 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2278 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2279 | (void *)(unsigned long)m); |
| 2280 | } |
| 2281 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2282 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2283 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2284 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2285 | out_unlock: |
| 2286 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2287 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2288 | } |
| 2289 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2290 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2291 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2292 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2293 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2294 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2295 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2296 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2297 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2298 | |
| 2299 | return count; |
| 2300 | } |
| 2301 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2302 | static const char *rps_power_to_str(unsigned int power) |
| 2303 | { |
| 2304 | static const char * const strings[] = { |
| 2305 | [LOW_POWER] = "low power", |
| 2306 | [BETWEEN] = "mixed", |
| 2307 | [HIGH_POWER] = "high power", |
| 2308 | }; |
| 2309 | |
| 2310 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2311 | return "unknown"; |
| 2312 | |
| 2313 | return strings[power]; |
| 2314 | } |
| 2315 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2316 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2317 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2318 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2319 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2320 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2321 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2322 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2323 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2324 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2325 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2326 | seq_printf(m, "Frequency requested %d\n", |
| 2327 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 2328 | 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] | 2329 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2330 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2331 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2332 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2333 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
| 2334 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq), |
| 2335 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
| 2336 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2337 | |
| 2338 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2339 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2340 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2341 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2342 | struct task_struct *task; |
| 2343 | |
| 2344 | rcu_read_lock(); |
| 2345 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2346 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2347 | task ? task->comm : "<unknown>", |
| 2348 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2349 | file_priv->rps.boosts, |
| 2350 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2351 | rcu_read_unlock(); |
| 2352 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2353 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2354 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2355 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2356 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2357 | if (INTEL_GEN(dev_priv) >= 6 && |
| 2358 | dev_priv->rps.enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2359 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2360 | u32 rpup, rpupei; |
| 2361 | u32 rpdown, rpdownei; |
| 2362 | |
| 2363 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2364 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2365 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2366 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2367 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2368 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2369 | |
| 2370 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
| 2371 | rps_power_to_str(dev_priv->rps.power)); |
| 2372 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2373 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2374 | dev_priv->rps.up_threshold); |
| 2375 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2376 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2377 | dev_priv->rps.down_threshold); |
| 2378 | } else { |
| 2379 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2380 | } |
| 2381 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2382 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2383 | } |
| 2384 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2385 | static int i915_llc(struct seq_file *m, void *data) |
| 2386 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2387 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2388 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2389 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2390 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2391 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2392 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2393 | |
| 2394 | return 0; |
| 2395 | } |
| 2396 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2397 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2398 | { |
| 2399 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2400 | struct intel_uc_fw *huc_fw = &dev_priv->huc.fw; |
| 2401 | |
| 2402 | if (!HAS_HUC_UCODE(dev_priv)) |
| 2403 | return 0; |
| 2404 | |
| 2405 | seq_puts(m, "HuC firmware status:\n"); |
| 2406 | seq_printf(m, "\tpath: %s\n", huc_fw->path); |
| 2407 | seq_printf(m, "\tfetch: %s\n", |
| 2408 | intel_uc_fw_status_repr(huc_fw->fetch_status)); |
| 2409 | seq_printf(m, "\tload: %s\n", |
| 2410 | intel_uc_fw_status_repr(huc_fw->load_status)); |
| 2411 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2412 | huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted); |
| 2413 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2414 | huc_fw->major_ver_found, huc_fw->minor_ver_found); |
| 2415 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2416 | huc_fw->header_offset, huc_fw->header_size); |
| 2417 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2418 | huc_fw->ucode_offset, huc_fw->ucode_size); |
| 2419 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2420 | huc_fw->rsa_offset, huc_fw->rsa_size); |
| 2421 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2422 | intel_runtime_pm_get(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2423 | 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] | 2424 | intel_runtime_pm_put(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2425 | |
| 2426 | return 0; |
| 2427 | } |
| 2428 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2429 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2430 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2431 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2432 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2433 | u32 tmp, i; |
| 2434 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2435 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2436 | return 0; |
| 2437 | |
| 2438 | seq_printf(m, "GuC firmware status:\n"); |
| 2439 | seq_printf(m, "\tpath: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2440 | guc_fw->path); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2441 | seq_printf(m, "\tfetch: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2442 | intel_uc_fw_status_repr(guc_fw->fetch_status)); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2443 | seq_printf(m, "\tload: %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2444 | intel_uc_fw_status_repr(guc_fw->load_status)); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2445 | seq_printf(m, "\tversion wanted: %d.%d\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2446 | guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2447 | seq_printf(m, "\tversion found: %d.%d\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 2448 | guc_fw->major_ver_found, guc_fw->minor_ver_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2449 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2450 | guc_fw->header_offset, guc_fw->header_size); |
| 2451 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2452 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2453 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2454 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2455 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2456 | intel_runtime_pm_get(dev_priv); |
| 2457 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2458 | tmp = I915_READ(GUC_STATUS); |
| 2459 | |
| 2460 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2461 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2462 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2463 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2464 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2465 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2466 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2467 | seq_puts(m, "\nScratch registers:\n"); |
| 2468 | for (i = 0; i < 16; i++) |
| 2469 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2470 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2471 | intel_runtime_pm_put(dev_priv); |
| 2472 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2473 | return 0; |
| 2474 | } |
| 2475 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2476 | static void i915_guc_log_info(struct seq_file *m, |
| 2477 | struct drm_i915_private *dev_priv) |
| 2478 | { |
| 2479 | struct intel_guc *guc = &dev_priv->guc; |
| 2480 | |
| 2481 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2482 | |
| 2483 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2484 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2485 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2486 | |
| 2487 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2488 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2489 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2490 | |
| 2491 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2492 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2493 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2494 | |
| 2495 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2496 | guc->log.flush_interrupt_count); |
| 2497 | |
| 2498 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2499 | guc->log.capture_miss_count); |
| 2500 | } |
| 2501 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2502 | static void i915_guc_client_info(struct seq_file *m, |
| 2503 | struct drm_i915_private *dev_priv, |
| 2504 | struct i915_guc_client *client) |
| 2505 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2506 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2507 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2508 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2509 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2510 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2511 | client->priority, client->stage_id, client->proc_desc_offset); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2512 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx, cookie 0x%x\n", |
Chris Wilson | 357248b | 2016-11-29 12:10:21 +0000 | [diff] [blame] | 2513 | client->doorbell_id, client->doorbell_offset, client->doorbell_cookie); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2514 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2515 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2516 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2517 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2518 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2519 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2520 | u64 submissions = client->submissions[id]; |
| 2521 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2522 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2523 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2524 | } |
| 2525 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2526 | } |
| 2527 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2528 | static bool check_guc_submission(struct seq_file *m) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2529 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2530 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2531 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2532 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2533 | if (!guc->execbuf_client) { |
| 2534 | seq_printf(m, "GuC submission %s\n", |
| 2535 | HAS_GUC_SCHED(dev_priv) ? |
| 2536 | "disabled" : |
| 2537 | "not supported"); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2538 | return false; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2539 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2540 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2541 | return true; |
| 2542 | } |
| 2543 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2544 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2545 | { |
| 2546 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2547 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2548 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2549 | if (!check_guc_submission(m)) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2550 | return 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2551 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2552 | seq_printf(m, "Doorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2553 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2554 | 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] | 2555 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2556 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2557 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2558 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2559 | i915_guc_log_info(m, dev_priv); |
| 2560 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2561 | /* Add more as required ... */ |
| 2562 | |
| 2563 | return 0; |
| 2564 | } |
| 2565 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2566 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2567 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2568 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2569 | const struct intel_guc *guc = &dev_priv->guc; |
| 2570 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
| 2571 | struct i915_guc_client *client = guc->execbuf_client; |
| 2572 | unsigned int tmp; |
| 2573 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2574 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2575 | if (!check_guc_submission(m)) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2576 | return 0; |
| 2577 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2578 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2579 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2580 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2581 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2582 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2583 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2584 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2585 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2586 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2587 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2588 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2589 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2590 | desc->engines_used); |
| 2591 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2592 | desc->db_trigger_phy, |
| 2593 | desc->db_trigger_cpu, |
| 2594 | desc->db_trigger_uk); |
| 2595 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2596 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2597 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2598 | desc->wq_addr, desc->wq_size); |
| 2599 | seq_putc(m, '\n'); |
| 2600 | |
| 2601 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2602 | u32 guc_engine_id = engine->guc_id; |
| 2603 | struct guc_execlist_context *lrc = |
| 2604 | &desc->lrc[guc_engine_id]; |
| 2605 | |
| 2606 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2607 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2608 | lrc->context_desc); |
| 2609 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2610 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2611 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2612 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2613 | seq_putc(m, '\n'); |
| 2614 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2615 | } |
| 2616 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2617 | return 0; |
| 2618 | } |
| 2619 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2620 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2621 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2622 | struct drm_info_node *node = m->private; |
| 2623 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2624 | bool dump_load_err = !!node->info_ent->data; |
| 2625 | struct drm_i915_gem_object *obj = NULL; |
| 2626 | u32 *log; |
| 2627 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2628 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2629 | if (dump_load_err) |
| 2630 | obj = dev_priv->guc.load_err_log; |
| 2631 | else if (dev_priv->guc.log.vma) |
| 2632 | obj = dev_priv->guc.log.vma->obj; |
| 2633 | |
| 2634 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2635 | return 0; |
| 2636 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2637 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2638 | if (IS_ERR(log)) { |
| 2639 | DRM_DEBUG("Failed to pin object\n"); |
| 2640 | seq_puts(m, "(log data unaccessible)\n"); |
| 2641 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2642 | } |
| 2643 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2644 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2645 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2646 | *(log + i), *(log + i + 1), |
| 2647 | *(log + i + 2), *(log + i + 3)); |
| 2648 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2649 | seq_putc(m, '\n'); |
| 2650 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2651 | i915_gem_object_unpin_map(obj); |
| 2652 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2653 | return 0; |
| 2654 | } |
| 2655 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2656 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2657 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2658 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2659 | |
| 2660 | if (!dev_priv->guc.log.vma) |
| 2661 | return -EINVAL; |
| 2662 | |
| 2663 | *val = i915.guc_log_level; |
| 2664 | |
| 2665 | return 0; |
| 2666 | } |
| 2667 | |
| 2668 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2669 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2670 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2671 | int ret; |
| 2672 | |
| 2673 | if (!dev_priv->guc.log.vma) |
| 2674 | return -EINVAL; |
| 2675 | |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2676 | ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2677 | if (ret) |
| 2678 | return ret; |
| 2679 | |
| 2680 | intel_runtime_pm_get(dev_priv); |
| 2681 | ret = i915_guc_log_control(dev_priv, val); |
| 2682 | intel_runtime_pm_put(dev_priv); |
| 2683 | |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2684 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2685 | return ret; |
| 2686 | } |
| 2687 | |
| 2688 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2689 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2690 | "%lld\n"); |
| 2691 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2692 | static const char *psr2_live_status(u32 val) |
| 2693 | { |
| 2694 | static const char * const live_status[] = { |
| 2695 | "IDLE", |
| 2696 | "CAPTURE", |
| 2697 | "CAPTURE_FS", |
| 2698 | "SLEEP", |
| 2699 | "BUFON_FW", |
| 2700 | "ML_UP", |
| 2701 | "SU_STANDBY", |
| 2702 | "FAST_SLEEP", |
| 2703 | "DEEP_SLEEP", |
| 2704 | "BUF_ON", |
| 2705 | "TG_ON" |
| 2706 | }; |
| 2707 | |
| 2708 | val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT; |
| 2709 | if (val < ARRAY_SIZE(live_status)) |
| 2710 | return live_status[val]; |
| 2711 | |
| 2712 | return "unknown"; |
| 2713 | } |
| 2714 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2715 | static int i915_edp_psr_status(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); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2718 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2719 | u32 stat[3]; |
| 2720 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2721 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2722 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2723 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2724 | seq_puts(m, "PSR not supported\n"); |
| 2725 | return 0; |
| 2726 | } |
| 2727 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2728 | intel_runtime_pm_get(dev_priv); |
| 2729 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2730 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2731 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2732 | 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] | 2733 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2734 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2735 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2736 | dev_priv->psr.busy_frontbuffer_bits); |
| 2737 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2738 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2739 | |
Nagaraju, Vathsala | 7e3eb59 | 2016-12-09 23:42:09 +0530 | [diff] [blame] | 2740 | if (HAS_DDI(dev_priv)) { |
| 2741 | if (dev_priv->psr.psr2_support) |
| 2742 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2743 | else |
| 2744 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
| 2745 | } else { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2746 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2747 | enum transcoder cpu_transcoder = |
| 2748 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2749 | enum intel_display_power_domain power_domain; |
| 2750 | |
| 2751 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2752 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2753 | power_domain)) |
| 2754 | continue; |
| 2755 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2756 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2757 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2758 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2759 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2760 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2761 | |
| 2762 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2763 | } |
| 2764 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2765 | |
| 2766 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2767 | yesno(dev_priv->psr.link_standby)); |
| 2768 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2769 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2770 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2771 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2772 | for_each_pipe(dev_priv, pipe) { |
| 2773 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2774 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2775 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2776 | } |
| 2777 | seq_puts(m, "\n"); |
| 2778 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2779 | /* |
| 2780 | * VLV/CHV PSR has no kind of performance counter |
| 2781 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2782 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2783 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2784 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2785 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2786 | |
| 2787 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2788 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2789 | if (dev_priv->psr.psr2_support) { |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2790 | u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2791 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2792 | seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n", |
| 2793 | psr2, psr2_live_status(psr2)); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2794 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2795 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2796 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2797 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2798 | return 0; |
| 2799 | } |
| 2800 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2801 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2802 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2803 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2804 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2805 | struct intel_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2806 | struct drm_connector_list_iter conn_iter; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2807 | struct intel_dp *intel_dp = NULL; |
| 2808 | int ret; |
| 2809 | u8 crc[6]; |
| 2810 | |
| 2811 | drm_modeset_lock_all(dev); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2812 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 2813 | for_each_intel_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2814 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2815 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2816 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2817 | continue; |
| 2818 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2819 | crtc = connector->base.state->crtc; |
| 2820 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2821 | continue; |
| 2822 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2823 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2824 | continue; |
| 2825 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2826 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2827 | |
| 2828 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2829 | if (ret) |
| 2830 | goto out; |
| 2831 | |
| 2832 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2833 | crc[0], crc[1], crc[2], |
| 2834 | crc[3], crc[4], crc[5]); |
| 2835 | goto out; |
| 2836 | } |
| 2837 | ret = -ENODEV; |
| 2838 | out: |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2839 | drm_connector_list_iter_end(&conn_iter); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2840 | drm_modeset_unlock_all(dev); |
| 2841 | return ret; |
| 2842 | } |
| 2843 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2844 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2845 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2846 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2847 | u64 power; |
| 2848 | u32 units; |
| 2849 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2850 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2851 | return -ENODEV; |
| 2852 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2853 | intel_runtime_pm_get(dev_priv); |
| 2854 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2855 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2856 | power = (power & 0x1f00) >> 8; |
| 2857 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2858 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2859 | power *= units; |
| 2860 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2861 | intel_runtime_pm_put(dev_priv); |
| 2862 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2863 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2864 | |
| 2865 | return 0; |
| 2866 | } |
| 2867 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2868 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2869 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2870 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2871 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2872 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2873 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2874 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2875 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2876 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2877 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2878 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2879 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2880 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2881 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2882 | #else |
| 2883 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2884 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2885 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2886 | pci_power_name(pdev->current_state), |
| 2887 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2888 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2889 | return 0; |
| 2890 | } |
| 2891 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2892 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2893 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2894 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2895 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2896 | int i; |
| 2897 | |
| 2898 | mutex_lock(&power_domains->lock); |
| 2899 | |
| 2900 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2901 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2902 | struct i915_power_well *power_well; |
| 2903 | enum intel_display_power_domain power_domain; |
| 2904 | |
| 2905 | power_well = &power_domains->power_wells[i]; |
| 2906 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2907 | power_well->count); |
| 2908 | |
Joonas Lahtinen | 8385c2e | 2017-02-08 15:12:10 +0200 | [diff] [blame] | 2909 | for_each_power_domain(power_domain, power_well->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2910 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2911 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2912 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2913 | } |
| 2914 | |
| 2915 | mutex_unlock(&power_domains->lock); |
| 2916 | |
| 2917 | return 0; |
| 2918 | } |
| 2919 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2920 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2921 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2922 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2923 | struct intel_csr *csr; |
| 2924 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2925 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2926 | seq_puts(m, "not supported\n"); |
| 2927 | return 0; |
| 2928 | } |
| 2929 | |
| 2930 | csr = &dev_priv->csr; |
| 2931 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2932 | intel_runtime_pm_get(dev_priv); |
| 2933 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2934 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2935 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2936 | |
| 2937 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2938 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2939 | |
| 2940 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2941 | CSR_VERSION_MINOR(csr->version)); |
| 2942 | |
Mika Kuoppala | 48de568 | 2017-05-09 13:05:22 +0300 | [diff] [blame] | 2943 | if (IS_KABYLAKE(dev_priv) || |
| 2944 | (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6))) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2945 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2946 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2947 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2948 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2949 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2950 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2951 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2952 | } |
| 2953 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2954 | out: |
| 2955 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2956 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2957 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2958 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2959 | intel_runtime_pm_put(dev_priv); |
| 2960 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2961 | return 0; |
| 2962 | } |
| 2963 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2964 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2965 | struct drm_display_mode *mode) |
| 2966 | { |
| 2967 | int i; |
| 2968 | |
| 2969 | for (i = 0; i < tabs; i++) |
| 2970 | seq_putc(m, '\t'); |
| 2971 | |
| 2972 | 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", |
| 2973 | mode->base.id, mode->name, |
| 2974 | mode->vrefresh, mode->clock, |
| 2975 | mode->hdisplay, mode->hsync_start, |
| 2976 | mode->hsync_end, mode->htotal, |
| 2977 | mode->vdisplay, mode->vsync_start, |
| 2978 | mode->vsync_end, mode->vtotal, |
| 2979 | mode->type, mode->flags); |
| 2980 | } |
| 2981 | |
| 2982 | static void intel_encoder_info(struct seq_file *m, |
| 2983 | struct intel_crtc *intel_crtc, |
| 2984 | struct intel_encoder *intel_encoder) |
| 2985 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2986 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2987 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2988 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2989 | struct intel_connector *intel_connector; |
| 2990 | struct drm_encoder *encoder; |
| 2991 | |
| 2992 | encoder = &intel_encoder->base; |
| 2993 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2994 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2995 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2996 | struct drm_connector *connector = &intel_connector->base; |
| 2997 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2998 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2999 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3000 | drm_get_connector_status_name(connector->status)); |
| 3001 | if (connector->status == connector_status_connected) { |
| 3002 | struct drm_display_mode *mode = &crtc->mode; |
| 3003 | seq_printf(m, ", mode:\n"); |
| 3004 | intel_seq_print_mode(m, 2, mode); |
| 3005 | } else { |
| 3006 | seq_putc(m, '\n'); |
| 3007 | } |
| 3008 | } |
| 3009 | } |
| 3010 | |
| 3011 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3012 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3013 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3014 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3015 | struct drm_crtc *crtc = &intel_crtc->base; |
| 3016 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 3017 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 3018 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3019 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 3020 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 3021 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 3022 | fb->base.id, plane_state->src_x >> 16, |
| 3023 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 3024 | else |
| 3025 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3026 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 3027 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 3028 | } |
| 3029 | |
| 3030 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 3031 | { |
| 3032 | struct drm_display_mode *mode = panel->fixed_mode; |
| 3033 | |
| 3034 | seq_printf(m, "\tfixed mode:\n"); |
| 3035 | intel_seq_print_mode(m, 2, mode); |
| 3036 | } |
| 3037 | |
| 3038 | static void intel_dp_info(struct seq_file *m, |
| 3039 | struct intel_connector *intel_connector) |
| 3040 | { |
| 3041 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3042 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 3043 | |
| 3044 | 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] | 3045 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3046 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3047 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 3048 | |
| 3049 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 3050 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3051 | } |
| 3052 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3053 | static void intel_dp_mst_info(struct seq_file *m, |
| 3054 | struct intel_connector *intel_connector) |
| 3055 | { |
| 3056 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3057 | struct intel_dp_mst_encoder *intel_mst = |
| 3058 | enc_to_mst(&intel_encoder->base); |
| 3059 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 3060 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 3061 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 3062 | intel_connector->port); |
| 3063 | |
| 3064 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 3065 | } |
| 3066 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3067 | static void intel_hdmi_info(struct seq_file *m, |
| 3068 | struct intel_connector *intel_connector) |
| 3069 | { |
| 3070 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3071 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 3072 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 3073 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3074 | } |
| 3075 | |
| 3076 | static void intel_lvds_info(struct seq_file *m, |
| 3077 | struct intel_connector *intel_connector) |
| 3078 | { |
| 3079 | intel_panel_info(m, &intel_connector->panel); |
| 3080 | } |
| 3081 | |
| 3082 | static void intel_connector_info(struct seq_file *m, |
| 3083 | struct drm_connector *connector) |
| 3084 | { |
| 3085 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 3086 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3087 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3088 | |
| 3089 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 3090 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3091 | drm_get_connector_status_name(connector->status)); |
| 3092 | if (connector->status == connector_status_connected) { |
| 3093 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 3094 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 3095 | connector->display_info.width_mm, |
| 3096 | connector->display_info.height_mm); |
| 3097 | seq_printf(m, "\tsubpixel order: %s\n", |
| 3098 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 3099 | seq_printf(m, "\tCEA rev: %d\n", |
| 3100 | connector->display_info.cea_rev); |
| 3101 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3102 | |
| 3103 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3104 | return; |
| 3105 | |
| 3106 | switch (connector->connector_type) { |
| 3107 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 3108 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3109 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3110 | intel_dp_mst_info(m, intel_connector); |
| 3111 | else |
| 3112 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3113 | break; |
| 3114 | case DRM_MODE_CONNECTOR_LVDS: |
| 3115 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3116 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3117 | break; |
| 3118 | case DRM_MODE_CONNECTOR_HDMIA: |
| 3119 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 3120 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 3121 | intel_hdmi_info(m, intel_connector); |
| 3122 | break; |
| 3123 | default: |
| 3124 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3125 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3126 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3127 | seq_printf(m, "\tmodes:\n"); |
| 3128 | list_for_each_entry(mode, &connector->modes, head) |
| 3129 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3130 | } |
| 3131 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3132 | static const char *plane_type(enum drm_plane_type type) |
| 3133 | { |
| 3134 | switch (type) { |
| 3135 | case DRM_PLANE_TYPE_OVERLAY: |
| 3136 | return "OVL"; |
| 3137 | case DRM_PLANE_TYPE_PRIMARY: |
| 3138 | return "PRI"; |
| 3139 | case DRM_PLANE_TYPE_CURSOR: |
| 3140 | return "CUR"; |
| 3141 | /* |
| 3142 | * Deliberately omitting default: to generate compiler warnings |
| 3143 | * when a new drm_plane_type gets added. |
| 3144 | */ |
| 3145 | } |
| 3146 | |
| 3147 | return "unknown"; |
| 3148 | } |
| 3149 | |
| 3150 | static const char *plane_rotation(unsigned int rotation) |
| 3151 | { |
| 3152 | static char buf[48]; |
| 3153 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 3154 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3155 | * will print them all to visualize if the values are misused |
| 3156 | */ |
| 3157 | snprintf(buf, sizeof(buf), |
| 3158 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 3159 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 3160 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 3161 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 3162 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 3163 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 3164 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3165 | rotation); |
| 3166 | |
| 3167 | return buf; |
| 3168 | } |
| 3169 | |
| 3170 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3171 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3172 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3173 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3174 | struct intel_plane *intel_plane; |
| 3175 | |
| 3176 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3177 | struct drm_plane_state *state; |
| 3178 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3179 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3180 | |
| 3181 | if (!plane->state) { |
| 3182 | seq_puts(m, "plane->state is NULL!\n"); |
| 3183 | continue; |
| 3184 | } |
| 3185 | |
| 3186 | state = plane->state; |
| 3187 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3188 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3189 | drm_get_format_name(state->fb->format->format, |
| 3190 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3191 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3192 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3193 | } |
| 3194 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3195 | 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", |
| 3196 | plane->base.id, |
| 3197 | plane_type(intel_plane->base.type), |
| 3198 | state->crtc_x, state->crtc_y, |
| 3199 | state->crtc_w, state->crtc_h, |
| 3200 | (state->src_x >> 16), |
| 3201 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3202 | (state->src_y >> 16), |
| 3203 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3204 | (state->src_w >> 16), |
| 3205 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3206 | (state->src_h >> 16), |
| 3207 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3208 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3209 | plane_rotation(state->rotation)); |
| 3210 | } |
| 3211 | } |
| 3212 | |
| 3213 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3214 | { |
| 3215 | struct intel_crtc_state *pipe_config; |
| 3216 | int num_scalers = intel_crtc->num_scalers; |
| 3217 | int i; |
| 3218 | |
| 3219 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3220 | |
| 3221 | /* Not all platformas have a scaler */ |
| 3222 | if (num_scalers) { |
| 3223 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3224 | num_scalers, |
| 3225 | pipe_config->scaler_state.scaler_users, |
| 3226 | pipe_config->scaler_state.scaler_id); |
| 3227 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3228 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3229 | struct intel_scaler *sc = |
| 3230 | &pipe_config->scaler_state.scalers[i]; |
| 3231 | |
| 3232 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3233 | i, yesno(sc->in_use), sc->mode); |
| 3234 | } |
| 3235 | seq_puts(m, "\n"); |
| 3236 | } else { |
| 3237 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3238 | } |
| 3239 | } |
| 3240 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3241 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3242 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3243 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3244 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3245 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3246 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3247 | struct drm_connector_list_iter conn_iter; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3248 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3249 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3250 | seq_printf(m, "CRTC info\n"); |
| 3251 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3252 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3253 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3254 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3255 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3256 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3257 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3258 | seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n", |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3259 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3260 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3261 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3262 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3263 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3264 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3265 | struct intel_plane *cursor = |
| 3266 | to_intel_plane(crtc->base.cursor); |
| 3267 | |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3268 | intel_crtc_info(m, crtc); |
| 3269 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3270 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3271 | yesno(cursor->base.state->visible), |
| 3272 | cursor->base.state->crtc_x, |
| 3273 | cursor->base.state->crtc_y, |
| 3274 | cursor->base.state->crtc_w, |
| 3275 | cursor->base.state->crtc_h, |
| 3276 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3277 | intel_scaler_info(m, crtc); |
| 3278 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3279 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3280 | |
| 3281 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3282 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3283 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3284 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3285 | } |
| 3286 | |
| 3287 | seq_printf(m, "\n"); |
| 3288 | seq_printf(m, "Connector info\n"); |
| 3289 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3290 | mutex_lock(&dev->mode_config.mutex); |
| 3291 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3292 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3293 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3294 | drm_connector_list_iter_end(&conn_iter); |
| 3295 | mutex_unlock(&dev->mode_config.mutex); |
| 3296 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3297 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3298 | |
| 3299 | return 0; |
| 3300 | } |
| 3301 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3302 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3303 | { |
| 3304 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame^] | 3305 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3306 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3307 | enum intel_engine_id id; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3308 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3309 | intel_runtime_pm_get(dev_priv); |
| 3310 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3311 | seq_printf(m, "GT awake? %s\n", |
| 3312 | yesno(dev_priv->gt.awake)); |
| 3313 | seq_printf(m, "Global active requests: %d\n", |
| 3314 | dev_priv->gt.active_requests); |
| 3315 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3316 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3317 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 3318 | struct drm_i915_gem_request *rq; |
| 3319 | struct rb_node *rb; |
| 3320 | u64 addr; |
| 3321 | |
| 3322 | seq_printf(m, "%s\n", engine->name); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3323 | 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] | 3324 | intel_engine_get_seqno(engine), |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 3325 | intel_engine_last_submit(engine), |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3326 | engine->hangcheck.seqno, |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3327 | jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp), |
| 3328 | engine->timeline->inflight_seqnos); |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame^] | 3329 | seq_printf(m, "\tReset count: %d\n", |
| 3330 | i915_reset_engine_count(error, engine)); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3331 | |
| 3332 | rcu_read_lock(); |
| 3333 | |
| 3334 | seq_printf(m, "\tRequests:\n"); |
| 3335 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3336 | rq = list_first_entry(&engine->timeline->requests, |
| 3337 | struct drm_i915_gem_request, link); |
| 3338 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3339 | print_request(m, rq, "\t\tfirst "); |
| 3340 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3341 | rq = list_last_entry(&engine->timeline->requests, |
| 3342 | struct drm_i915_gem_request, link); |
| 3343 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3344 | print_request(m, rq, "\t\tlast "); |
| 3345 | |
| 3346 | rq = i915_gem_find_active_request(engine); |
| 3347 | if (rq) { |
| 3348 | print_request(m, rq, "\t\tactive "); |
| 3349 | seq_printf(m, |
| 3350 | "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n", |
| 3351 | rq->head, rq->postfix, rq->tail, |
| 3352 | rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, |
| 3353 | rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); |
| 3354 | } |
| 3355 | |
| 3356 | seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n", |
| 3357 | I915_READ(RING_START(engine->mmio_base)), |
| 3358 | rq ? i915_ggtt_offset(rq->ring->vma) : 0); |
| 3359 | seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n", |
| 3360 | I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR, |
| 3361 | rq ? rq->ring->head : 0); |
| 3362 | seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n", |
| 3363 | I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR, |
| 3364 | rq ? rq->ring->tail : 0); |
| 3365 | seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n", |
| 3366 | I915_READ(RING_CTL(engine->mmio_base)), |
| 3367 | I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : ""); |
| 3368 | |
| 3369 | rcu_read_unlock(); |
| 3370 | |
| 3371 | addr = intel_engine_get_active_head(engine); |
| 3372 | seq_printf(m, "\tACTHD: 0x%08x_%08x\n", |
| 3373 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3374 | addr = intel_engine_get_last_batch_head(engine); |
| 3375 | seq_printf(m, "\tBBADDR: 0x%08x_%08x\n", |
| 3376 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3377 | |
| 3378 | if (i915.enable_execlists) { |
| 3379 | u32 ptr, read, write; |
Chris Wilson | 77f0d0e | 2017-05-17 13:10:00 +0100 | [diff] [blame] | 3380 | unsigned int idx; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3381 | |
| 3382 | seq_printf(m, "\tExeclist status: 0x%08x %08x\n", |
| 3383 | I915_READ(RING_EXECLIST_STATUS_LO(engine)), |
| 3384 | I915_READ(RING_EXECLIST_STATUS_HI(engine))); |
| 3385 | |
| 3386 | ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
| 3387 | read = GEN8_CSB_READ_PTR(ptr); |
| 3388 | write = GEN8_CSB_WRITE_PTR(ptr); |
| 3389 | seq_printf(m, "\tExeclist CSB read %d, write %d\n", |
| 3390 | read, write); |
| 3391 | if (read >= GEN8_CSB_ENTRIES) |
| 3392 | read = 0; |
| 3393 | if (write >= GEN8_CSB_ENTRIES) |
| 3394 | write = 0; |
| 3395 | if (read > write) |
| 3396 | write += GEN8_CSB_ENTRIES; |
| 3397 | while (read < write) { |
Chris Wilson | 77f0d0e | 2017-05-17 13:10:00 +0100 | [diff] [blame] | 3398 | idx = ++read % GEN8_CSB_ENTRIES; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3399 | seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n", |
| 3400 | idx, |
| 3401 | I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)), |
| 3402 | I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx))); |
| 3403 | } |
| 3404 | |
| 3405 | rcu_read_lock(); |
Chris Wilson | 77f0d0e | 2017-05-17 13:10:00 +0100 | [diff] [blame] | 3406 | for (idx = 0; idx < ARRAY_SIZE(engine->execlist_port); idx++) { |
| 3407 | unsigned int count; |
| 3408 | |
| 3409 | rq = port_unpack(&engine->execlist_port[idx], |
| 3410 | &count); |
| 3411 | if (rq) { |
| 3412 | seq_printf(m, "\t\tELSP[%d] count=%d, ", |
| 3413 | idx, count); |
| 3414 | print_request(m, rq, "rq: "); |
| 3415 | } else { |
| 3416 | seq_printf(m, "\t\tELSP[%d] idle\n", |
| 3417 | idx); |
| 3418 | } |
Chris Wilson | 816ee79 | 2017-01-24 11:00:03 +0000 | [diff] [blame] | 3419 | } |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3420 | rcu_read_unlock(); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3421 | |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3422 | spin_lock_irq(&engine->timeline->lock); |
Chris Wilson | 6c06757 | 2017-05-17 13:10:03 +0100 | [diff] [blame] | 3423 | for (rb = engine->execlist_first; rb; rb = rb_next(rb)){ |
| 3424 | struct i915_priolist *p = |
| 3425 | rb_entry(rb, typeof(*p), node); |
| 3426 | |
| 3427 | list_for_each_entry(rq, &p->requests, |
| 3428 | priotree.link) |
| 3429 | print_request(m, rq, "\t\tQ "); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3430 | } |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3431 | spin_unlock_irq(&engine->timeline->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3432 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 3433 | seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n", |
| 3434 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 3435 | seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n", |
| 3436 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 3437 | seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n", |
| 3438 | I915_READ(RING_PP_DIR_DCLV(engine))); |
| 3439 | } |
| 3440 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 3441 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3442 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 3443 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3444 | |
| 3445 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 3446 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 3447 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 3448 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3449 | |
| 3450 | seq_puts(m, "\n"); |
| 3451 | } |
| 3452 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3453 | intel_runtime_pm_put(dev_priv); |
| 3454 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3455 | return 0; |
| 3456 | } |
| 3457 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3458 | static int i915_semaphore_status(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; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3462 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3463 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3464 | enum intel_engine_id id; |
| 3465 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3466 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3467 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3468 | seq_puts(m, "Semaphores are disabled\n"); |
| 3469 | return 0; |
| 3470 | } |
| 3471 | |
| 3472 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3473 | if (ret) |
| 3474 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3475 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3476 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3477 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3478 | struct page *page; |
| 3479 | uint64_t *seqno; |
| 3480 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3481 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3482 | |
| 3483 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3484 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3485 | uint64_t offset; |
| 3486 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3487 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3488 | |
| 3489 | seq_puts(m, " Last signal:"); |
| 3490 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3491 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3492 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3493 | seqno[offset], offset * 8); |
| 3494 | } |
| 3495 | seq_putc(m, '\n'); |
| 3496 | |
| 3497 | seq_puts(m, " Last wait: "); |
| 3498 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3499 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3500 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3501 | seqno[offset], offset * 8); |
| 3502 | } |
| 3503 | seq_putc(m, '\n'); |
| 3504 | |
| 3505 | } |
| 3506 | kunmap_atomic(seqno); |
| 3507 | } else { |
| 3508 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3509 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3510 | for (j = 0; j < num_rings; j++) |
| 3511 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3512 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3513 | seq_putc(m, '\n'); |
| 3514 | } |
| 3515 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3516 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3517 | mutex_unlock(&dev->struct_mutex); |
| 3518 | return 0; |
| 3519 | } |
| 3520 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3521 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3522 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3523 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3524 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3525 | int i; |
| 3526 | |
| 3527 | drm_modeset_lock_all(dev); |
| 3528 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3529 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3530 | |
| 3531 | 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] | 3532 | 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] | 3533 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3534 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3535 | 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] | 3536 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3537 | pll->state.hw_state.dpll_md); |
| 3538 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3539 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3540 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3541 | } |
| 3542 | drm_modeset_unlock_all(dev); |
| 3543 | |
| 3544 | return 0; |
| 3545 | } |
| 3546 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3547 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3548 | { |
| 3549 | int i; |
| 3550 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3551 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3552 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3553 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3554 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3555 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3556 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3557 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3558 | if (ret) |
| 3559 | return ret; |
| 3560 | |
| 3561 | intel_runtime_pm_get(dev_priv); |
| 3562 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3563 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3564 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3565 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3566 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3567 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3568 | i915_reg_t addr; |
| 3569 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3570 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3571 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3572 | addr = workarounds->reg[i].addr; |
| 3573 | mask = workarounds->reg[i].mask; |
| 3574 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3575 | read = I915_READ(addr); |
| 3576 | ok = (value & mask) == (read & mask); |
| 3577 | 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] | 3578 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3579 | } |
| 3580 | |
| 3581 | intel_runtime_pm_put(dev_priv); |
| 3582 | mutex_unlock(&dev->struct_mutex); |
| 3583 | |
| 3584 | return 0; |
| 3585 | } |
| 3586 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3587 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3588 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3589 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3590 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3591 | struct skl_ddb_allocation *ddb; |
| 3592 | struct skl_ddb_entry *entry; |
| 3593 | enum pipe pipe; |
| 3594 | int plane; |
| 3595 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3596 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3597 | return 0; |
| 3598 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3599 | drm_modeset_lock_all(dev); |
| 3600 | |
| 3601 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3602 | |
| 3603 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3604 | |
| 3605 | for_each_pipe(dev_priv, pipe) { |
| 3606 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3607 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3608 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3609 | entry = &ddb->plane[pipe][plane]; |
| 3610 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3611 | entry->start, entry->end, |
| 3612 | skl_ddb_entry_size(entry)); |
| 3613 | } |
| 3614 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3615 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3616 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3617 | entry->end, skl_ddb_entry_size(entry)); |
| 3618 | } |
| 3619 | |
| 3620 | drm_modeset_unlock_all(dev); |
| 3621 | |
| 3622 | return 0; |
| 3623 | } |
| 3624 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3625 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3626 | struct drm_device *dev, |
| 3627 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3628 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3629 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3630 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3631 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3632 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3633 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3634 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3635 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3636 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3637 | if (connector->state->crtc != &intel_crtc->base) |
| 3638 | continue; |
| 3639 | |
| 3640 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3641 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3642 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3643 | |
| 3644 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3645 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3646 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3647 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3648 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3649 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3650 | else |
| 3651 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3652 | |
| 3653 | seq_puts(m, "\n\n"); |
| 3654 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3655 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3656 | struct intel_panel *panel; |
| 3657 | |
| 3658 | mutex_lock(&drrs->mutex); |
| 3659 | /* DRRS Supported */ |
| 3660 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3661 | |
| 3662 | /* disable_drrs() will make drrs->dp NULL */ |
| 3663 | if (!drrs->dp) { |
| 3664 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3665 | mutex_unlock(&drrs->mutex); |
| 3666 | return; |
| 3667 | } |
| 3668 | |
| 3669 | panel = &drrs->dp->attached_connector->panel; |
| 3670 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3671 | drrs->busy_frontbuffer_bits); |
| 3672 | |
| 3673 | seq_puts(m, "\n\t\t"); |
| 3674 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3675 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3676 | vrefresh = panel->fixed_mode->vrefresh; |
| 3677 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3678 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3679 | vrefresh = panel->downclock_mode->vrefresh; |
| 3680 | } else { |
| 3681 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3682 | drrs->refresh_rate_type); |
| 3683 | mutex_unlock(&drrs->mutex); |
| 3684 | return; |
| 3685 | } |
| 3686 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3687 | |
| 3688 | seq_puts(m, "\n\t\t"); |
| 3689 | mutex_unlock(&drrs->mutex); |
| 3690 | } else { |
| 3691 | /* DRRS not supported. Print the VBT parameter*/ |
| 3692 | seq_puts(m, "\tDRRS Supported : No"); |
| 3693 | } |
| 3694 | seq_puts(m, "\n"); |
| 3695 | } |
| 3696 | |
| 3697 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3698 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3699 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3700 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3701 | struct intel_crtc *intel_crtc; |
| 3702 | int active_crtc_cnt = 0; |
| 3703 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3704 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3705 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3706 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3707 | active_crtc_cnt++; |
| 3708 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3709 | |
| 3710 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3711 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3712 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3713 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3714 | |
| 3715 | if (!active_crtc_cnt) |
| 3716 | seq_puts(m, "No active crtc found\n"); |
| 3717 | |
| 3718 | return 0; |
| 3719 | } |
| 3720 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3721 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3722 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3723 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3724 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3725 | struct intel_encoder *intel_encoder; |
| 3726 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3727 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3728 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3729 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3730 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3731 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3732 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3733 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3734 | |
| 3735 | intel_encoder = intel_attached_encoder(connector); |
| 3736 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3737 | continue; |
| 3738 | |
| 3739 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3740 | if (!intel_dig_port->dp.can_mst) |
| 3741 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3742 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3743 | seq_printf(m, "MST Source Port %c\n", |
| 3744 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3745 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3746 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3747 | drm_connector_list_iter_end(&conn_iter); |
| 3748 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3749 | return 0; |
| 3750 | } |
| 3751 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3752 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3753 | const char __user *ubuf, |
| 3754 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3755 | { |
| 3756 | char *input_buffer; |
| 3757 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3758 | struct drm_device *dev; |
| 3759 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3760 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3761 | struct intel_dp *intel_dp; |
| 3762 | int val = 0; |
| 3763 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3764 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3765 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3766 | if (len == 0) |
| 3767 | return 0; |
| 3768 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3769 | input_buffer = memdup_user_nul(ubuf, len); |
| 3770 | if (IS_ERR(input_buffer)) |
| 3771 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3772 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3773 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3774 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3775 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3776 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3777 | if (connector->connector_type != |
| 3778 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3779 | continue; |
| 3780 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 3781 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3782 | connector->encoder != NULL) { |
| 3783 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 3784 | status = kstrtoint(input_buffer, 10, &val); |
| 3785 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3786 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3787 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3788 | /* To prevent erroneous activation of the compliance |
| 3789 | * testing code, only accept an actual value of 1 here |
| 3790 | */ |
| 3791 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3792 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3793 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3794 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3795 | } |
| 3796 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3797 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3798 | kfree(input_buffer); |
| 3799 | if (status < 0) |
| 3800 | return status; |
| 3801 | |
| 3802 | *offp += len; |
| 3803 | return len; |
| 3804 | } |
| 3805 | |
| 3806 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3807 | { |
| 3808 | struct drm_device *dev = m->private; |
| 3809 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3810 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3811 | struct intel_dp *intel_dp; |
| 3812 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3813 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3814 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3815 | if (connector->connector_type != |
| 3816 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3817 | continue; |
| 3818 | |
| 3819 | if (connector->status == connector_status_connected && |
| 3820 | connector->encoder != NULL) { |
| 3821 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3822 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3823 | seq_puts(m, "1"); |
| 3824 | else |
| 3825 | seq_puts(m, "0"); |
| 3826 | } else |
| 3827 | seq_puts(m, "0"); |
| 3828 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3829 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3830 | |
| 3831 | return 0; |
| 3832 | } |
| 3833 | |
| 3834 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3835 | struct file *file) |
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 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3838 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3839 | return single_open(file, i915_displayport_test_active_show, |
| 3840 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3841 | } |
| 3842 | |
| 3843 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3844 | .owner = THIS_MODULE, |
| 3845 | .open = i915_displayport_test_active_open, |
| 3846 | .read = seq_read, |
| 3847 | .llseek = seq_lseek, |
| 3848 | .release = single_release, |
| 3849 | .write = i915_displayport_test_active_write |
| 3850 | }; |
| 3851 | |
| 3852 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3853 | { |
| 3854 | struct drm_device *dev = m->private; |
| 3855 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3856 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3857 | struct intel_dp *intel_dp; |
| 3858 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3859 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3860 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3861 | if (connector->connector_type != |
| 3862 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3863 | continue; |
| 3864 | |
| 3865 | if (connector->status == connector_status_connected && |
| 3866 | connector->encoder != NULL) { |
| 3867 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3868 | if (intel_dp->compliance.test_type == |
| 3869 | DP_TEST_LINK_EDID_READ) |
| 3870 | seq_printf(m, "%lx", |
| 3871 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3872 | else if (intel_dp->compliance.test_type == |
| 3873 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3874 | seq_printf(m, "hdisplay: %d\n", |
| 3875 | intel_dp->compliance.test_data.hdisplay); |
| 3876 | seq_printf(m, "vdisplay: %d\n", |
| 3877 | intel_dp->compliance.test_data.vdisplay); |
| 3878 | seq_printf(m, "bpc: %u\n", |
| 3879 | intel_dp->compliance.test_data.bpc); |
| 3880 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3881 | } else |
| 3882 | seq_puts(m, "0"); |
| 3883 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3884 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3885 | |
| 3886 | return 0; |
| 3887 | } |
| 3888 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3889 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3890 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3891 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3892 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3893 | return single_open(file, i915_displayport_test_data_show, |
| 3894 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3895 | } |
| 3896 | |
| 3897 | static const struct file_operations i915_displayport_test_data_fops = { |
| 3898 | .owner = THIS_MODULE, |
| 3899 | .open = i915_displayport_test_data_open, |
| 3900 | .read = seq_read, |
| 3901 | .llseek = seq_lseek, |
| 3902 | .release = single_release |
| 3903 | }; |
| 3904 | |
| 3905 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3906 | { |
| 3907 | struct drm_device *dev = m->private; |
| 3908 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3909 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3910 | struct intel_dp *intel_dp; |
| 3911 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3912 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3913 | drm_for_each_connector_iter(connector, &conn_iter) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3914 | if (connector->connector_type != |
| 3915 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3916 | continue; |
| 3917 | |
| 3918 | if (connector->status == connector_status_connected && |
| 3919 | connector->encoder != NULL) { |
| 3920 | intel_dp = enc_to_intel_dp(connector->encoder); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3921 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3922 | } else |
| 3923 | seq_puts(m, "0"); |
| 3924 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3925 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3926 | |
| 3927 | return 0; |
| 3928 | } |
| 3929 | |
| 3930 | static int i915_displayport_test_type_open(struct inode *inode, |
| 3931 | struct file *file) |
| 3932 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3933 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3934 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3935 | return single_open(file, i915_displayport_test_type_show, |
| 3936 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3937 | } |
| 3938 | |
| 3939 | static const struct file_operations i915_displayport_test_type_fops = { |
| 3940 | .owner = THIS_MODULE, |
| 3941 | .open = i915_displayport_test_type_open, |
| 3942 | .read = seq_read, |
| 3943 | .llseek = seq_lseek, |
| 3944 | .release = single_release |
| 3945 | }; |
| 3946 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3947 | 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] | 3948 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3949 | struct drm_i915_private *dev_priv = m->private; |
| 3950 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3951 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3952 | int num_levels; |
| 3953 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3954 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3955 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3956 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3957 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3958 | else if (IS_G4X(dev_priv)) |
| 3959 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3960 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3961 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3962 | |
| 3963 | drm_modeset_lock_all(dev); |
| 3964 | |
| 3965 | for (level = 0; level < num_levels; level++) { |
| 3966 | unsigned int latency = wm[level]; |
| 3967 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3968 | /* |
| 3969 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3970 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3971 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3972 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3973 | IS_VALLEYVIEW(dev_priv) || |
| 3974 | IS_CHERRYVIEW(dev_priv) || |
| 3975 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3976 | latency *= 10; |
| 3977 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3978 | latency *= 5; |
| 3979 | |
| 3980 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3981 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3982 | } |
| 3983 | |
| 3984 | drm_modeset_unlock_all(dev); |
| 3985 | } |
| 3986 | |
| 3987 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3988 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3989 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3990 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3991 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3992 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3993 | latencies = dev_priv->wm.skl_latency; |
| 3994 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3995 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3996 | |
| 3997 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3998 | |
| 3999 | return 0; |
| 4000 | } |
| 4001 | |
| 4002 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4003 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4004 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4005 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4006 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4007 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4008 | latencies = dev_priv->wm.skl_latency; |
| 4009 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4010 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4011 | |
| 4012 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4013 | |
| 4014 | return 0; |
| 4015 | } |
| 4016 | |
| 4017 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4018 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4019 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4020 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4021 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4022 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4023 | latencies = dev_priv->wm.skl_latency; |
| 4024 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4025 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4026 | |
| 4027 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4028 | |
| 4029 | return 0; |
| 4030 | } |
| 4031 | |
| 4032 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4033 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4034 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4035 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 4036 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4037 | return -ENODEV; |
| 4038 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4039 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4040 | } |
| 4041 | |
| 4042 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4043 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4044 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4045 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4046 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4047 | return -ENODEV; |
| 4048 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4049 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4053 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4054 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4055 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4056 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4057 | return -ENODEV; |
| 4058 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4059 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4060 | } |
| 4061 | |
| 4062 | 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] | 4063 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4064 | { |
| 4065 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4066 | struct drm_i915_private *dev_priv = m->private; |
| 4067 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4068 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4069 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4070 | int level; |
| 4071 | int ret; |
| 4072 | char tmp[32]; |
| 4073 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4074 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4075 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4076 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4077 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 4078 | else if (IS_G4X(dev_priv)) |
| 4079 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4080 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 4081 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4082 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4083 | if (len >= sizeof(tmp)) |
| 4084 | return -EINVAL; |
| 4085 | |
| 4086 | if (copy_from_user(tmp, ubuf, len)) |
| 4087 | return -EFAULT; |
| 4088 | |
| 4089 | tmp[len] = '\0'; |
| 4090 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4091 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4092 | &new[0], &new[1], &new[2], &new[3], |
| 4093 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4094 | if (ret != num_levels) |
| 4095 | return -EINVAL; |
| 4096 | |
| 4097 | drm_modeset_lock_all(dev); |
| 4098 | |
| 4099 | for (level = 0; level < num_levels; level++) |
| 4100 | wm[level] = new[level]; |
| 4101 | |
| 4102 | drm_modeset_unlock_all(dev); |
| 4103 | |
| 4104 | return len; |
| 4105 | } |
| 4106 | |
| 4107 | |
| 4108 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4109 | size_t len, loff_t *offp) |
| 4110 | { |
| 4111 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4112 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4113 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4114 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4115 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4116 | latencies = dev_priv->wm.skl_latency; |
| 4117 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4118 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4119 | |
| 4120 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4121 | } |
| 4122 | |
| 4123 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4124 | size_t len, loff_t *offp) |
| 4125 | { |
| 4126 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4127 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4128 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4129 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4130 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4131 | latencies = dev_priv->wm.skl_latency; |
| 4132 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4133 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4134 | |
| 4135 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4136 | } |
| 4137 | |
| 4138 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4139 | size_t len, loff_t *offp) |
| 4140 | { |
| 4141 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4142 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4143 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4144 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4145 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4146 | latencies = dev_priv->wm.skl_latency; |
| 4147 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4148 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4149 | |
| 4150 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4151 | } |
| 4152 | |
| 4153 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4154 | .owner = THIS_MODULE, |
| 4155 | .open = pri_wm_latency_open, |
| 4156 | .read = seq_read, |
| 4157 | .llseek = seq_lseek, |
| 4158 | .release = single_release, |
| 4159 | .write = pri_wm_latency_write |
| 4160 | }; |
| 4161 | |
| 4162 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4163 | .owner = THIS_MODULE, |
| 4164 | .open = spr_wm_latency_open, |
| 4165 | .read = seq_read, |
| 4166 | .llseek = seq_lseek, |
| 4167 | .release = single_release, |
| 4168 | .write = spr_wm_latency_write |
| 4169 | }; |
| 4170 | |
| 4171 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4172 | .owner = THIS_MODULE, |
| 4173 | .open = cur_wm_latency_open, |
| 4174 | .read = seq_read, |
| 4175 | .llseek = seq_lseek, |
| 4176 | .release = single_release, |
| 4177 | .write = cur_wm_latency_write |
| 4178 | }; |
| 4179 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4180 | static int |
| 4181 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4182 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4183 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4184 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4185 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4186 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4187 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4188 | } |
| 4189 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4190 | static int |
| 4191 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4192 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4193 | struct drm_i915_private *i915 = data; |
| 4194 | struct intel_engine_cs *engine; |
| 4195 | unsigned int tmp; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4196 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4197 | /* |
| 4198 | * There is no safeguard against this debugfs entry colliding |
| 4199 | * with the hangcheck calling same i915_handle_error() in |
| 4200 | * parallel, causing an explosion. For now we assume that the |
| 4201 | * test harness is responsible enough not to inject gpu hangs |
| 4202 | * while it is writing to 'i915_wedged' |
| 4203 | */ |
| 4204 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4205 | if (i915_reset_backoff(&i915->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4206 | return -EAGAIN; |
| 4207 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4208 | for_each_engine_masked(engine, i915, val, tmp) { |
| 4209 | engine->hangcheck.seqno = intel_engine_get_seqno(engine); |
| 4210 | engine->hangcheck.stalled = true; |
| 4211 | } |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4212 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4213 | i915_handle_error(i915, val, "Manually setting wedged to %llu", val); |
| 4214 | |
| 4215 | wait_on_bit(&i915->gpu_error.flags, |
Chris Wilson | d3df42b | 2017-03-16 17:13:05 +0000 | [diff] [blame] | 4216 | I915_RESET_HANDOFF, |
| 4217 | TASK_UNINTERRUPTIBLE); |
| 4218 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4219 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4220 | } |
| 4221 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4222 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4223 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4224 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4225 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4226 | static int |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4227 | fault_irq_set(struct drm_i915_private *i915, |
| 4228 | unsigned long *irq, |
| 4229 | unsigned long val) |
| 4230 | { |
| 4231 | int err; |
| 4232 | |
| 4233 | err = mutex_lock_interruptible(&i915->drm.struct_mutex); |
| 4234 | if (err) |
| 4235 | return err; |
| 4236 | |
| 4237 | err = i915_gem_wait_for_idle(i915, |
| 4238 | I915_WAIT_LOCKED | |
| 4239 | I915_WAIT_INTERRUPTIBLE); |
| 4240 | if (err) |
| 4241 | goto err_unlock; |
| 4242 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4243 | *irq = val; |
| 4244 | mutex_unlock(&i915->drm.struct_mutex); |
| 4245 | |
| 4246 | /* Flush idle worker to disarm irq */ |
| 4247 | while (flush_delayed_work(&i915->gt.idle_work)) |
| 4248 | ; |
| 4249 | |
| 4250 | return 0; |
| 4251 | |
| 4252 | err_unlock: |
| 4253 | mutex_unlock(&i915->drm.struct_mutex); |
| 4254 | return err; |
| 4255 | } |
| 4256 | |
| 4257 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4258 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4259 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4260 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4261 | |
| 4262 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4263 | return 0; |
| 4264 | } |
| 4265 | |
| 4266 | static int |
| 4267 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4268 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4269 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4270 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4271 | return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4272 | } |
| 4273 | |
| 4274 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4275 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4276 | "0x%08llx\n"); |
| 4277 | |
| 4278 | static int |
| 4279 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4280 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4281 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4282 | |
| 4283 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4284 | |
| 4285 | return 0; |
| 4286 | } |
| 4287 | |
| 4288 | static int |
| 4289 | i915_ring_test_irq_set(void *data, u64 val) |
| 4290 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4291 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4292 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4293 | val &= INTEL_INFO(i915)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4294 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4295 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4296 | return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4300 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4301 | "0x%08llx\n"); |
| 4302 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4303 | #define DROP_UNBOUND 0x1 |
| 4304 | #define DROP_BOUND 0x2 |
| 4305 | #define DROP_RETIRE 0x4 |
| 4306 | #define DROP_ACTIVE 0x8 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4307 | #define DROP_FREED 0x10 |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4308 | #define DROP_SHRINK_ALL 0x20 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4309 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4310 | DROP_BOUND | \ |
| 4311 | DROP_RETIRE | \ |
| 4312 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4313 | DROP_FREED | \ |
| 4314 | DROP_SHRINK_ALL) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4315 | static int |
| 4316 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4317 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4318 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4319 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4320 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4321 | } |
| 4322 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4323 | static int |
| 4324 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4325 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4326 | struct drm_i915_private *dev_priv = data; |
| 4327 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4328 | int ret = 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4329 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4330 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4331 | |
| 4332 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4333 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4334 | if (val & (DROP_ACTIVE | DROP_RETIRE)) { |
| 4335 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4336 | if (ret) |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4337 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4338 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4339 | if (val & DROP_ACTIVE) |
| 4340 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4341 | I915_WAIT_INTERRUPTIBLE | |
| 4342 | I915_WAIT_LOCKED); |
| 4343 | |
| 4344 | if (val & DROP_RETIRE) |
| 4345 | i915_gem_retire_requests(dev_priv); |
| 4346 | |
| 4347 | mutex_unlock(&dev->struct_mutex); |
| 4348 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4349 | |
Daniel Vetter | 05df49e | 2017-03-12 21:53:40 +0100 | [diff] [blame] | 4350 | lockdep_set_current_reclaim_state(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4351 | if (val & DROP_BOUND) |
| 4352 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4353 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4354 | if (val & DROP_UNBOUND) |
| 4355 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4356 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4357 | if (val & DROP_SHRINK_ALL) |
| 4358 | i915_gem_shrink_all(dev_priv); |
Daniel Vetter | 05df49e | 2017-03-12 21:53:40 +0100 | [diff] [blame] | 4359 | lockdep_clear_current_reclaim_state(); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4360 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4361 | if (val & DROP_FREED) { |
| 4362 | synchronize_rcu(); |
Chris Wilson | bdeb978 | 2016-12-23 14:57:56 +0000 | [diff] [blame] | 4363 | i915_gem_drain_freed_objects(dev_priv); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4364 | } |
| 4365 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4366 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4367 | } |
| 4368 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4369 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4370 | i915_drop_caches_get, i915_drop_caches_set, |
| 4371 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4372 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4373 | static int |
| 4374 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4375 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4376 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4377 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4378 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4379 | return -ENODEV; |
| 4380 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4381 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4382 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4383 | } |
| 4384 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4385 | static int |
| 4386 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4387 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4388 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4389 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4390 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4391 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4392 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4393 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4394 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4395 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4396 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4397 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4398 | if (ret) |
| 4399 | return ret; |
| 4400 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4401 | /* |
| 4402 | * Turbo will still be enabled, but won't go above the set value. |
| 4403 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4404 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4405 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4406 | hw_max = dev_priv->rps.max_freq; |
| 4407 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4408 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4409 | 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] | 4410 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4411 | return -EINVAL; |
| 4412 | } |
| 4413 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4414 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4415 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 4416 | if (intel_set_rps(dev_priv, val)) |
| 4417 | DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n"); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4418 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4419 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4420 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4421 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4422 | } |
| 4423 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4424 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4425 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4426 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4427 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4428 | static int |
| 4429 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4430 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4431 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4432 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4433 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4434 | return -ENODEV; |
| 4435 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4436 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4437 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4438 | } |
| 4439 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4440 | static int |
| 4441 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4442 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4443 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4444 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4445 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4446 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4447 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4448 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4449 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4450 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4451 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4452 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4453 | if (ret) |
| 4454 | return ret; |
| 4455 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4456 | /* |
| 4457 | * Turbo will still be enabled, but won't go below the set value. |
| 4458 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4459 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4460 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4461 | hw_max = dev_priv->rps.max_freq; |
| 4462 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4463 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4464 | if (val < hw_min || |
| 4465 | val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4466 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4467 | return -EINVAL; |
| 4468 | } |
| 4469 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4470 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4471 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 4472 | if (intel_set_rps(dev_priv, val)) |
| 4473 | DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n"); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4474 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4475 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4476 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4477 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4478 | } |
| 4479 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4480 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4481 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4482 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4483 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4484 | static int |
| 4485 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4486 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4487 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4488 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4489 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4490 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4491 | return -ENODEV; |
| 4492 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4493 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4494 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4495 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4496 | |
| 4497 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4498 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4499 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4500 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4501 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4502 | } |
| 4503 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4504 | static int |
| 4505 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4506 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4507 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4508 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4509 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4510 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4511 | return -ENODEV; |
| 4512 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4513 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4514 | return -EINVAL; |
| 4515 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4516 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4517 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4518 | |
| 4519 | /* Update the cache sharing policy here as well */ |
| 4520 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4521 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4522 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4523 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4524 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4525 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4526 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4527 | } |
| 4528 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4529 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4530 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4531 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4532 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4533 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4534 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4535 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 4536 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4537 | int ss; |
| 4538 | u32 sig1[ss_max], sig2[ss_max]; |
| 4539 | |
| 4540 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4541 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4542 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4543 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4544 | |
| 4545 | for (ss = 0; ss < ss_max; ss++) { |
| 4546 | unsigned int eu_cnt; |
| 4547 | |
| 4548 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4549 | /* skip disabled subslice */ |
| 4550 | continue; |
| 4551 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4552 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4553 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4554 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4555 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4556 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4557 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4558 | sseu->eu_total += eu_cnt; |
| 4559 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4560 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4561 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4562 | } |
| 4563 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4564 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4565 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4566 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4567 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4568 | int s, ss; |
| 4569 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4570 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4571 | /* BXT has a single slice and at most 3 subslices. */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4572 | if (IS_GEN9_LP(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4573 | s_max = 1; |
| 4574 | ss_max = 3; |
| 4575 | } |
| 4576 | |
| 4577 | for (s = 0; s < s_max; s++) { |
| 4578 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4579 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4580 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4581 | } |
| 4582 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4583 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4584 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4585 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4586 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4587 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4588 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4589 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4590 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4591 | |
| 4592 | for (s = 0; s < s_max; s++) { |
| 4593 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4594 | /* skip disabled slice */ |
| 4595 | continue; |
| 4596 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4597 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4598 | |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 4599 | if (IS_GEN9_BC(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4600 | sseu->subslice_mask = |
| 4601 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4602 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4603 | for (ss = 0; ss < ss_max; ss++) { |
| 4604 | unsigned int eu_cnt; |
| 4605 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4606 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4607 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4608 | /* skip disabled subslice */ |
| 4609 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4610 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4611 | sseu->subslice_mask |= BIT(ss); |
| 4612 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4613 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4614 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4615 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4616 | sseu->eu_total += eu_cnt; |
| 4617 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4618 | sseu->eu_per_subslice, |
| 4619 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4620 | } |
| 4621 | } |
| 4622 | } |
| 4623 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4624 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4625 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4626 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4627 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4628 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4629 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4630 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4631 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4632 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4633 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4634 | sseu->eu_per_subslice = |
| 4635 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4636 | sseu->eu_total = sseu->eu_per_subslice * |
| 4637 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4638 | |
| 4639 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4640 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4641 | u8 subslice_7eu = |
| 4642 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4643 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4644 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4645 | } |
| 4646 | } |
| 4647 | } |
| 4648 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4649 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4650 | const struct sseu_dev_info *sseu) |
| 4651 | { |
| 4652 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4653 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 4654 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4655 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4656 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4657 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4658 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4659 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4660 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4661 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 4662 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4663 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4664 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4665 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4666 | sseu->eu_total); |
| 4667 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4668 | sseu->eu_per_subslice); |
| 4669 | |
| 4670 | if (!is_available_info) |
| 4671 | return; |
| 4672 | |
| 4673 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4674 | if (HAS_POOLED_EU(dev_priv)) |
| 4675 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4676 | |
| 4677 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4678 | yesno(sseu->has_slice_pg)); |
| 4679 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4680 | yesno(sseu->has_subslice_pg)); |
| 4681 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4682 | yesno(sseu->has_eu_pg)); |
| 4683 | } |
| 4684 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4685 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4686 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4687 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4688 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4689 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4690 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4691 | return -ENODEV; |
| 4692 | |
| 4693 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4694 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4695 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4696 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4697 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4698 | |
| 4699 | intel_runtime_pm_get(dev_priv); |
| 4700 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4701 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4702 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4703 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4704 | broadwell_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4705 | } else if (INTEL_GEN(dev_priv) >= 9) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4706 | gen9_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4707 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4708 | |
| 4709 | intel_runtime_pm_put(dev_priv); |
| 4710 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4711 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4712 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4713 | return 0; |
| 4714 | } |
| 4715 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4716 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4717 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4718 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4719 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4720 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4721 | return 0; |
| 4722 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4723 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4724 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4725 | |
| 4726 | return 0; |
| 4727 | } |
| 4728 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4729 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4730 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4731 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4732 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4733 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4734 | return 0; |
| 4735 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4736 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4737 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4738 | |
| 4739 | return 0; |
| 4740 | } |
| 4741 | |
| 4742 | static const struct file_operations i915_forcewake_fops = { |
| 4743 | .owner = THIS_MODULE, |
| 4744 | .open = i915_forcewake_open, |
| 4745 | .release = i915_forcewake_release, |
| 4746 | }; |
| 4747 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4748 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4749 | { |
| 4750 | struct drm_i915_private *dev_priv = m->private; |
| 4751 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4752 | |
| 4753 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4754 | seq_printf(m, "Detected: %s\n", |
| 4755 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4756 | |
| 4757 | return 0; |
| 4758 | } |
| 4759 | |
| 4760 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4761 | const char __user *ubuf, size_t len, |
| 4762 | loff_t *offp) |
| 4763 | { |
| 4764 | struct seq_file *m = file->private_data; |
| 4765 | struct drm_i915_private *dev_priv = m->private; |
| 4766 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4767 | unsigned int new_threshold; |
| 4768 | int i; |
| 4769 | char *newline; |
| 4770 | char tmp[16]; |
| 4771 | |
| 4772 | if (len >= sizeof(tmp)) |
| 4773 | return -EINVAL; |
| 4774 | |
| 4775 | if (copy_from_user(tmp, ubuf, len)) |
| 4776 | return -EFAULT; |
| 4777 | |
| 4778 | tmp[len] = '\0'; |
| 4779 | |
| 4780 | /* Strip newline, if any */ |
| 4781 | newline = strchr(tmp, '\n'); |
| 4782 | if (newline) |
| 4783 | *newline = '\0'; |
| 4784 | |
| 4785 | if (strcmp(tmp, "reset") == 0) |
| 4786 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4787 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4788 | return -EINVAL; |
| 4789 | |
| 4790 | if (new_threshold > 0) |
| 4791 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4792 | new_threshold); |
| 4793 | else |
| 4794 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4795 | |
| 4796 | spin_lock_irq(&dev_priv->irq_lock); |
| 4797 | hotplug->hpd_storm_threshold = new_threshold; |
| 4798 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4799 | for_each_hpd_pin(i) |
| 4800 | hotplug->stats[i].count = 0; |
| 4801 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4802 | |
| 4803 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4804 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4805 | |
| 4806 | return len; |
| 4807 | } |
| 4808 | |
| 4809 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4810 | { |
| 4811 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4812 | } |
| 4813 | |
| 4814 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4815 | .owner = THIS_MODULE, |
| 4816 | .open = i915_hpd_storm_ctl_open, |
| 4817 | .read = seq_read, |
| 4818 | .llseek = seq_lseek, |
| 4819 | .release = single_release, |
| 4820 | .write = i915_hpd_storm_ctl_write |
| 4821 | }; |
| 4822 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4823 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4824 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4825 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4826 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 4827 | {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4828 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4829 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4830 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4831 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4832 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4833 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4834 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4835 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4836 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4837 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4838 | {"i915_guc_load_err_log_dump", i915_guc_log_dump, 0, (void *)1}, |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 4839 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4840 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4841 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4842 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame^] | 4843 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4844 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4845 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4846 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4847 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4848 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4849 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4850 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4851 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4852 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4853 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4854 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4855 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4856 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4857 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4858 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4859 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4860 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4861 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4862 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4863 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4864 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4865 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4866 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4867 | {"i915_engine_info", i915_engine_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4868 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4869 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4870 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4871 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4872 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4873 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4874 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4875 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4876 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4877 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4878 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4879 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4880 | const char *name; |
| 4881 | const struct file_operations *fops; |
| 4882 | } i915_debugfs_files[] = { |
| 4883 | {"i915_wedged", &i915_wedged_fops}, |
| 4884 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4885 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4886 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4887 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4888 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4889 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4890 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4891 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4892 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4893 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4894 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4895 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4896 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4897 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4898 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4899 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4900 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4901 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4902 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4903 | {"i915_guc_log_control", &i915_guc_log_control_fops}, |
| 4904 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4905 | }; |
| 4906 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4907 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4908 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4909 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4910 | struct dentry *ent; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4911 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4912 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4913 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4914 | minor->debugfs_root, to_i915(minor->dev), |
| 4915 | &i915_forcewake_fops); |
| 4916 | if (!ent) |
| 4917 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4918 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame] | 4919 | ret = intel_pipe_crc_create(minor); |
| 4920 | if (ret) |
| 4921 | return ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4922 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4923 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4924 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4925 | S_IRUGO | S_IWUSR, |
| 4926 | minor->debugfs_root, |
| 4927 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4928 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4929 | if (!ent) |
| 4930 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4931 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4932 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4933 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4934 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4935 | minor->debugfs_root, minor); |
| 4936 | } |
| 4937 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4938 | struct dpcd_block { |
| 4939 | /* DPCD dump start address. */ |
| 4940 | unsigned int offset; |
| 4941 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4942 | unsigned int end; |
| 4943 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4944 | size_t size; |
| 4945 | /* Only valid for eDP. */ |
| 4946 | bool edp; |
| 4947 | }; |
| 4948 | |
| 4949 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4950 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4951 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4952 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4953 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4954 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4955 | { .offset = DP_SET_POWER }, |
| 4956 | { .offset = DP_EDP_DPCD_REV }, |
| 4957 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4958 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4959 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4960 | }; |
| 4961 | |
| 4962 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4963 | { |
| 4964 | struct drm_connector *connector = m->private; |
| 4965 | struct intel_dp *intel_dp = |
| 4966 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4967 | uint8_t buf[16]; |
| 4968 | ssize_t err; |
| 4969 | int i; |
| 4970 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4971 | if (connector->status != connector_status_connected) |
| 4972 | return -ENODEV; |
| 4973 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4974 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4975 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4976 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4977 | |
| 4978 | if (b->edp && |
| 4979 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4980 | continue; |
| 4981 | |
| 4982 | /* low tech for now */ |
| 4983 | if (WARN_ON(size > sizeof(buf))) |
| 4984 | continue; |
| 4985 | |
| 4986 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 4987 | if (err <= 0) { |
| 4988 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 4989 | size, b->offset, err); |
| 4990 | continue; |
| 4991 | } |
| 4992 | |
| 4993 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4994 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4995 | |
| 4996 | return 0; |
| 4997 | } |
| 4998 | |
| 4999 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5000 | { |
| 5001 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5002 | } |
| 5003 | |
| 5004 | static const struct file_operations i915_dpcd_fops = { |
| 5005 | .owner = THIS_MODULE, |
| 5006 | .open = i915_dpcd_open, |
| 5007 | .read = seq_read, |
| 5008 | .llseek = seq_lseek, |
| 5009 | .release = single_release, |
| 5010 | }; |
| 5011 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5012 | static int i915_panel_show(struct seq_file *m, void *data) |
| 5013 | { |
| 5014 | struct drm_connector *connector = m->private; |
| 5015 | struct intel_dp *intel_dp = |
| 5016 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5017 | |
| 5018 | if (connector->status != connector_status_connected) |
| 5019 | return -ENODEV; |
| 5020 | |
| 5021 | seq_printf(m, "Panel power up delay: %d\n", |
| 5022 | intel_dp->panel_power_up_delay); |
| 5023 | seq_printf(m, "Panel power down delay: %d\n", |
| 5024 | intel_dp->panel_power_down_delay); |
| 5025 | seq_printf(m, "Backlight on delay: %d\n", |
| 5026 | intel_dp->backlight_on_delay); |
| 5027 | seq_printf(m, "Backlight off delay: %d\n", |
| 5028 | intel_dp->backlight_off_delay); |
| 5029 | |
| 5030 | return 0; |
| 5031 | } |
| 5032 | |
| 5033 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 5034 | { |
| 5035 | return single_open(file, i915_panel_show, inode->i_private); |
| 5036 | } |
| 5037 | |
| 5038 | static const struct file_operations i915_panel_fops = { |
| 5039 | .owner = THIS_MODULE, |
| 5040 | .open = i915_panel_open, |
| 5041 | .read = seq_read, |
| 5042 | .llseek = seq_lseek, |
| 5043 | .release = single_release, |
| 5044 | }; |
| 5045 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5046 | /** |
| 5047 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5048 | * @connector: pointer to a registered drm_connector |
| 5049 | * |
| 5050 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5051 | * drm_debugfs_connector_remove(). |
| 5052 | * |
| 5053 | * Returns 0 on success, negative error codes on error. |
| 5054 | */ |
| 5055 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5056 | { |
| 5057 | struct dentry *root = connector->debugfs_entry; |
| 5058 | |
| 5059 | /* The connector must have been registered beforehands. */ |
| 5060 | if (!root) |
| 5061 | return -ENODEV; |
| 5062 | |
| 5063 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5064 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5065 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5066 | connector, &i915_dpcd_fops); |
| 5067 | |
| 5068 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5069 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5070 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5071 | |
| 5072 | return 0; |
| 5073 | } |