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> |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 31 | #include <linux/sched/mm.h> |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 32 | #include "intel_drv.h" |
Michal Wajdeczko | 9f436c4 | 2017-10-04 18:13:40 +0000 | [diff] [blame] | 33 | #include "i915_guc_submission.h" |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 34 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 35 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 36 | { |
| 37 | return to_i915(node->minor->dev); |
| 38 | } |
| 39 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 40 | static __always_inline void seq_print_param(struct seq_file *m, |
| 41 | const char *name, |
| 42 | const char *type, |
| 43 | const void *x) |
| 44 | { |
| 45 | if (!__builtin_strcmp(type, "bool")) |
| 46 | seq_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x)); |
| 47 | else if (!__builtin_strcmp(type, "int")) |
| 48 | seq_printf(m, "i915.%s=%d\n", name, *(const int *)x); |
| 49 | else if (!__builtin_strcmp(type, "unsigned int")) |
| 50 | seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x); |
Chris Wilson | 1d6aa7a | 2017-02-21 16:26:19 +0000 | [diff] [blame] | 51 | else if (!__builtin_strcmp(type, "char *")) |
| 52 | seq_printf(m, "i915.%s=%s\n", name, *(const char **)x); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 53 | else |
| 54 | BUILD_BUG(); |
| 55 | } |
| 56 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 57 | static int i915_capabilities(struct seq_file *m, void *data) |
| 58 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 59 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 60 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 61 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 62 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 63 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 64 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 65 | |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 66 | #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] | 67 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 68 | #undef PRINT_FLAG |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 69 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 70 | kernel_param_lock(THIS_MODULE); |
Michal Wajdeczko | 7075cb85 | 2017-09-25 10:50:07 +0000 | [diff] [blame] | 71 | #define PRINT_PARAM(T, x, ...) seq_print_param(m, #x, #T, &i915_modparams.x); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 72 | I915_PARAMS_FOR_EACH(PRINT_PARAM); |
| 73 | #undef PRINT_PARAM |
| 74 | kernel_param_unlock(THIS_MODULE); |
| 75 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 76 | return 0; |
| 77 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 78 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 79 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 80 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 81 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 84 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 85 | { |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 86 | return obj->pin_global ? 'p' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 87 | } |
| 88 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 89 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 90 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 91 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 92 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 93 | case I915_TILING_NONE: return ' '; |
| 94 | case I915_TILING_X: return 'X'; |
| 95 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 96 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 99 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 100 | { |
Chris Wilson | a65adaf | 2017-10-09 09:43:57 +0100 | [diff] [blame] | 101 | return obj->userfault_count ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 102 | } |
| 103 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 104 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 105 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 106 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 109 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 110 | { |
| 111 | u64 size = 0; |
| 112 | struct i915_vma *vma; |
| 113 | |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 114 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 115 | if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 116 | size += vma->node.size; |
| 117 | } |
| 118 | |
| 119 | return size; |
| 120 | } |
| 121 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 122 | static const char * |
| 123 | stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len) |
| 124 | { |
| 125 | size_t x = 0; |
| 126 | |
| 127 | switch (page_sizes) { |
| 128 | case 0: |
| 129 | return ""; |
| 130 | case I915_GTT_PAGE_SIZE_4K: |
| 131 | return "4K"; |
| 132 | case I915_GTT_PAGE_SIZE_64K: |
| 133 | return "64K"; |
| 134 | case I915_GTT_PAGE_SIZE_2M: |
| 135 | return "2M"; |
| 136 | default: |
| 137 | if (!buf) |
| 138 | return "M"; |
| 139 | |
| 140 | if (page_sizes & I915_GTT_PAGE_SIZE_2M) |
| 141 | x += snprintf(buf + x, len - x, "2M, "); |
| 142 | if (page_sizes & I915_GTT_PAGE_SIZE_64K) |
| 143 | x += snprintf(buf + x, len - x, "64K, "); |
| 144 | if (page_sizes & I915_GTT_PAGE_SIZE_4K) |
| 145 | x += snprintf(buf + x, len - x, "4K, "); |
| 146 | buf[x-2] = '\0'; |
| 147 | |
| 148 | return buf; |
| 149 | } |
| 150 | } |
| 151 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 152 | static void |
| 153 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 154 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 155 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 156 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 157 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 158 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 159 | int pin_count = 0; |
| 160 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 161 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 162 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 163 | 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] | 164 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 165 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 166 | get_pin_flag(obj), |
| 167 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 168 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 169 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 170 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 171 | obj->base.read_domains, |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 172 | obj->base.write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 173 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 174 | obj->mm.dirty ? " dirty" : "", |
| 175 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 176 | if (obj->base.name) |
| 177 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 178 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 179 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 180 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 181 | } |
| 182 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 183 | if (obj->pin_global) |
| 184 | seq_printf(m, " (global)"); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 185 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 186 | if (!drm_mm_node_allocated(&vma->node)) |
| 187 | continue; |
| 188 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 189 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx, pages: %s", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 190 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 191 | vma->node.start, vma->node.size, |
| 192 | stringify_page_sizes(vma->page_sizes.gtt, NULL, 0)); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 193 | if (i915_vma_is_ggtt(vma)) { |
| 194 | switch (vma->ggtt_view.type) { |
| 195 | case I915_GGTT_VIEW_NORMAL: |
| 196 | seq_puts(m, ", normal"); |
| 197 | break; |
| 198 | |
| 199 | case I915_GGTT_VIEW_PARTIAL: |
| 200 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 201 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 202 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 203 | break; |
| 204 | |
| 205 | case I915_GGTT_VIEW_ROTATED: |
| 206 | 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] | 207 | vma->ggtt_view.rotated.plane[0].width, |
| 208 | vma->ggtt_view.rotated.plane[0].height, |
| 209 | vma->ggtt_view.rotated.plane[0].stride, |
| 210 | vma->ggtt_view.rotated.plane[0].offset, |
| 211 | vma->ggtt_view.rotated.plane[1].width, |
| 212 | vma->ggtt_view.rotated.plane[1].height, |
| 213 | vma->ggtt_view.rotated.plane[1].stride, |
| 214 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 215 | break; |
| 216 | |
| 217 | default: |
| 218 | MISSING_CASE(vma->ggtt_view.type); |
| 219 | break; |
| 220 | } |
| 221 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 222 | if (vma->fence) |
| 223 | seq_printf(m, " , fence: %d%s", |
| 224 | vma->fence->id, |
| 225 | i915_gem_active_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 226 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 227 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 228 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 229 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 230 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 231 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 232 | if (engine) |
| 233 | seq_printf(m, " (%s)", engine->name); |
| 234 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 235 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 236 | if (frontbuffer_bits) |
| 237 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 238 | } |
| 239 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 240 | static int obj_rank_by_stolen(const void *A, const void *B) |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 241 | { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 242 | const struct drm_i915_gem_object *a = |
| 243 | *(const struct drm_i915_gem_object **)A; |
| 244 | const struct drm_i915_gem_object *b = |
| 245 | *(const struct drm_i915_gem_object **)B; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 246 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 247 | if (a->stolen->start < b->stolen->start) |
| 248 | return -1; |
| 249 | if (a->stolen->start > b->stolen->start) |
| 250 | return 1; |
| 251 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 255 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 256 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 257 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 258 | struct drm_i915_gem_object **objects; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 259 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 260 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 261 | unsigned long total, count, n; |
| 262 | int ret; |
| 263 | |
| 264 | total = READ_ONCE(dev_priv->mm.object_count); |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 265 | objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 266 | if (!objects) |
| 267 | return -ENOMEM; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 268 | |
| 269 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 270 | if (ret) |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 271 | goto out; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 272 | |
| 273 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 274 | |
| 275 | spin_lock(&dev_priv->mm.obj_lock); |
| 276 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 277 | if (count == total) |
| 278 | break; |
| 279 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | if (obj->stolen == NULL) |
| 281 | continue; |
| 282 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 283 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 284 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 285 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 286 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 287 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 288 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 289 | if (count == total) |
| 290 | break; |
| 291 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 292 | if (obj->stolen == NULL) |
| 293 | continue; |
| 294 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 295 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 296 | total_obj_size += obj->base.size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 297 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 298 | spin_unlock(&dev_priv->mm.obj_lock); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 299 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 300 | sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL); |
| 301 | |
| 302 | seq_puts(m, "Stolen:\n"); |
| 303 | for (n = 0; n < count; n++) { |
| 304 | seq_puts(m, " "); |
| 305 | describe_obj(m, objects[n]); |
| 306 | seq_putc(m, '\n'); |
| 307 | } |
| 308 | seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 309 | count, total_obj_size, total_gtt_size); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 310 | |
| 311 | mutex_unlock(&dev->struct_mutex); |
| 312 | out: |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 313 | kvfree(objects); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 314 | return ret; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 315 | } |
| 316 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 317 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 318 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 319 | unsigned long count; |
| 320 | u64 total, unbound; |
| 321 | u64 global, shared; |
| 322 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | static int per_file_stats(int id, void *ptr, void *data) |
| 326 | { |
| 327 | struct drm_i915_gem_object *obj = ptr; |
| 328 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 329 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 330 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 331 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 332 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 333 | stats->count++; |
| 334 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 335 | if (!obj->bind_count) |
| 336 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 337 | if (obj->base.name || obj->base.dma_buf) |
| 338 | stats->shared += obj->base.size; |
| 339 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 340 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 341 | if (!drm_mm_node_allocated(&vma->node)) |
| 342 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 343 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 344 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 345 | stats->global += vma->node.size; |
| 346 | } else { |
| 347 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 348 | |
Chris Wilson | 2bfa996 | 2016-08-04 07:52:25 +0100 | [diff] [blame] | 349 | if (ppgtt->base.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 350 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 351 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 352 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 353 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 354 | stats->active += vma->node.size; |
| 355 | else |
| 356 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 362 | #define print_file_stats(m, name, stats) do { \ |
| 363 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 364 | 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] | 365 | name, \ |
| 366 | stats.count, \ |
| 367 | stats.total, \ |
| 368 | stats.active, \ |
| 369 | stats.inactive, \ |
| 370 | stats.global, \ |
| 371 | stats.shared, \ |
| 372 | stats.unbound); \ |
| 373 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 374 | |
| 375 | static void print_batch_pool_stats(struct seq_file *m, |
| 376 | struct drm_i915_private *dev_priv) |
| 377 | { |
| 378 | struct drm_i915_gem_object *obj; |
| 379 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 380 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 381 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 382 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 383 | |
| 384 | memset(&stats, 0, sizeof(stats)); |
| 385 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 386 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 387 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 388 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 389 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 390 | batch_pool_link) |
| 391 | per_file_stats(0, obj, &stats); |
| 392 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 393 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 394 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 395 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 396 | } |
| 397 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 398 | static int per_file_ctx_stats(int id, void *ptr, void *data) |
| 399 | { |
| 400 | struct i915_gem_context *ctx = ptr; |
| 401 | int n; |
| 402 | |
| 403 | for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) { |
| 404 | if (ctx->engine[n].state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 405 | per_file_stats(0, ctx->engine[n].state->obj, data); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 406 | if (ctx->engine[n].ring) |
Chris Wilson | 57e8853 | 2016-08-15 10:48:57 +0100 | [diff] [blame] | 407 | per_file_stats(0, ctx->engine[n].ring->vma->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | return 0; |
| 411 | } |
| 412 | |
| 413 | static void print_context_stats(struct seq_file *m, |
| 414 | struct drm_i915_private *dev_priv) |
| 415 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 416 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 417 | struct file_stats stats; |
| 418 | struct drm_file *file; |
| 419 | |
| 420 | memset(&stats, 0, sizeof(stats)); |
| 421 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 422 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 423 | if (dev_priv->kernel_context) |
| 424 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 425 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 426 | list_for_each_entry(file, &dev->filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 427 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 428 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 429 | } |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 430 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 431 | |
| 432 | print_file_stats(m, "[k]contexts", stats); |
| 433 | } |
| 434 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 435 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 436 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 437 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 438 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 439 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 440 | u32 count, mapped_count, purgeable_count, dpy_count, huge_count; |
| 441 | u64 size, mapped_size, purgeable_size, dpy_size, huge_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 442 | struct drm_i915_gem_object *obj; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 443 | unsigned int page_sizes = 0; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 444 | struct drm_file *file; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 445 | char buf[80]; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 446 | int ret; |
| 447 | |
| 448 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 449 | if (ret) |
| 450 | return ret; |
| 451 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 452 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 453 | dev_priv->mm.object_count, |
| 454 | dev_priv->mm.object_memory); |
| 455 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 456 | size = count = 0; |
| 457 | mapped_size = mapped_count = 0; |
| 458 | purgeable_size = purgeable_count = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 459 | huge_size = huge_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 460 | |
| 461 | spin_lock(&dev_priv->mm.obj_lock); |
| 462 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 463 | size += obj->base.size; |
| 464 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 465 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 466 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 467 | purgeable_size += obj->base.size; |
| 468 | ++purgeable_count; |
| 469 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 470 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 471 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 472 | mapped_count++; |
| 473 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 474 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 475 | |
| 476 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 477 | huge_count++; |
| 478 | huge_size += obj->base.size; |
| 479 | page_sizes |= obj->mm.page_sizes.sg; |
| 480 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 481 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 482 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 483 | |
| 484 | size = count = dpy_size = dpy_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 485 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 486 | size += obj->base.size; |
| 487 | ++count; |
| 488 | |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 489 | if (obj->pin_global) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 490 | dpy_size += obj->base.size; |
| 491 | ++dpy_count; |
| 492 | } |
| 493 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 494 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 495 | purgeable_size += obj->base.size; |
| 496 | ++purgeable_count; |
| 497 | } |
| 498 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 499 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 500 | mapped_count++; |
| 501 | mapped_size += obj->base.size; |
| 502 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 503 | |
| 504 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 505 | huge_count++; |
| 506 | huge_size += obj->base.size; |
| 507 | page_sizes |= obj->mm.page_sizes.sg; |
| 508 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 509 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 510 | spin_unlock(&dev_priv->mm.obj_lock); |
| 511 | |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 512 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 513 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 514 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 515 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 516 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 517 | mapped_count, mapped_size); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 518 | seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n", |
| 519 | huge_count, |
| 520 | stringify_page_sizes(page_sizes, buf, sizeof(buf)), |
| 521 | huge_size); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 522 | seq_printf(m, "%u display objects (globally pinned), %llu bytes\n", |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 523 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 524 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 525 | seq_printf(m, "%llu [%llu] gtt total\n", |
Chris Wilson | 381b943 | 2017-02-15 08:43:54 +0000 | [diff] [blame] | 526 | ggtt->base.total, ggtt->mappable_end); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 527 | seq_printf(m, "Supported page sizes: %s\n", |
| 528 | stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes, |
| 529 | buf, sizeof(buf))); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 530 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 531 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 532 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 533 | mutex_unlock(&dev->struct_mutex); |
| 534 | |
| 535 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 536 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 537 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 538 | struct file_stats stats; |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 539 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 540 | struct drm_i915_gem_request *request; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 541 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 542 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 543 | mutex_lock(&dev->struct_mutex); |
| 544 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 545 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 546 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 547 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 548 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 549 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 550 | /* |
| 551 | * Although we have a valid reference on file->pid, that does |
| 552 | * not guarantee that the task_struct who called get_pid() is |
| 553 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 554 | * Therefore, we need to protect this ->comm access using RCU. |
| 555 | */ |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 556 | request = list_first_entry_or_null(&file_priv->mm.request_list, |
| 557 | struct drm_i915_gem_request, |
Chris Wilson | c8659ef | 2017-03-02 12:25:25 +0000 | [diff] [blame] | 558 | client_link); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 559 | rcu_read_lock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 560 | task = pid_task(request && request->ctx->pid ? |
| 561 | request->ctx->pid : file->pid, |
| 562 | PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 563 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 564 | rcu_read_unlock(); |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 565 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 566 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 567 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 568 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 569 | |
| 570 | return 0; |
| 571 | } |
| 572 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 573 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 574 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 575 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 576 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 577 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 578 | struct drm_i915_gem_object **objects; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 579 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 580 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 581 | unsigned long nobject, n; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 582 | int count, ret; |
| 583 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 584 | nobject = READ_ONCE(dev_priv->mm.object_count); |
| 585 | objects = kvmalloc_array(nobject, sizeof(*objects), GFP_KERNEL); |
| 586 | if (!objects) |
| 587 | return -ENOMEM; |
| 588 | |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 589 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 590 | if (ret) |
| 591 | return ret; |
| 592 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 593 | count = 0; |
| 594 | spin_lock(&dev_priv->mm.obj_lock); |
| 595 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
| 596 | objects[count++] = obj; |
| 597 | if (count == nobject) |
| 598 | break; |
| 599 | } |
| 600 | spin_unlock(&dev_priv->mm.obj_lock); |
| 601 | |
| 602 | total_obj_size = total_gtt_size = 0; |
| 603 | for (n = 0; n < count; n++) { |
| 604 | obj = objects[n]; |
| 605 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 606 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 607 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 608 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 609 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 610 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | mutex_unlock(&dev->struct_mutex); |
| 614 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 615 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 616 | count, total_obj_size, total_gtt_size); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 617 | kvfree(objects); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 622 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 623 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 624 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 625 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 626 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 627 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 628 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 629 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 630 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 631 | |
| 632 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 633 | if (ret) |
| 634 | return ret; |
| 635 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 636 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 637 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 638 | int count; |
| 639 | |
| 640 | count = 0; |
| 641 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 642 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 643 | batch_pool_link) |
| 644 | count++; |
| 645 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 646 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 647 | |
| 648 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 649 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 650 | batch_pool_link) { |
| 651 | seq_puts(m, " "); |
| 652 | describe_obj(m, obj); |
| 653 | seq_putc(m, '\n'); |
| 654 | } |
| 655 | |
| 656 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 657 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 658 | } |
| 659 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 660 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 661 | |
| 662 | mutex_unlock(&dev->struct_mutex); |
| 663 | |
| 664 | return 0; |
| 665 | } |
| 666 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 667 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 668 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 669 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 670 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 671 | struct rb_node *rb; |
| 672 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 673 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 674 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 675 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 676 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 677 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 678 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 679 | |
| 680 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 681 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 682 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 683 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 684 | } |
| 685 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 686 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 687 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 688 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 689 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 690 | enum intel_engine_id id; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 691 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 692 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 693 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 694 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 695 | return 0; |
| 696 | } |
| 697 | |
| 698 | |
| 699 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 700 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 701 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 702 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 703 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 704 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 705 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 706 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 707 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 708 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 709 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 710 | I915_READ(GEN8_MASTER_IRQ)); |
| 711 | |
| 712 | seq_printf(m, "Display IER:\t%08x\n", |
| 713 | I915_READ(VLV_IER)); |
| 714 | seq_printf(m, "Display IIR:\t%08x\n", |
| 715 | I915_READ(VLV_IIR)); |
| 716 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 717 | I915_READ(VLV_IIR_RW)); |
| 718 | seq_printf(m, "Display IMR:\t%08x\n", |
| 719 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 720 | for_each_pipe(dev_priv, pipe) { |
| 721 | enum intel_display_power_domain power_domain; |
| 722 | |
| 723 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 724 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 725 | power_domain)) { |
| 726 | seq_printf(m, "Pipe %c power disabled\n", |
| 727 | pipe_name(pipe)); |
| 728 | continue; |
| 729 | } |
| 730 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 731 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 732 | pipe_name(pipe), |
| 733 | I915_READ(PIPESTAT(pipe))); |
| 734 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 735 | intel_display_power_put(dev_priv, power_domain); |
| 736 | } |
| 737 | |
| 738 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 739 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 740 | I915_READ(PORT_HOTPLUG_EN)); |
| 741 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 742 | I915_READ(VLV_DPFLIPSTAT)); |
| 743 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 744 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 745 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 746 | |
| 747 | for (i = 0; i < 4; i++) { |
| 748 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 749 | i, I915_READ(GEN8_GT_IMR(i))); |
| 750 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 751 | i, I915_READ(GEN8_GT_IIR(i))); |
| 752 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 753 | i, I915_READ(GEN8_GT_IER(i))); |
| 754 | } |
| 755 | |
| 756 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 757 | I915_READ(GEN8_PCU_IMR)); |
| 758 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 759 | I915_READ(GEN8_PCU_IIR)); |
| 760 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 761 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 762 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 763 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 764 | I915_READ(GEN8_MASTER_IRQ)); |
| 765 | |
| 766 | for (i = 0; i < 4; i++) { |
| 767 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 768 | i, I915_READ(GEN8_GT_IMR(i))); |
| 769 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 770 | i, I915_READ(GEN8_GT_IIR(i))); |
| 771 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 772 | i, I915_READ(GEN8_GT_IER(i))); |
| 773 | } |
| 774 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 775 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 776 | enum intel_display_power_domain power_domain; |
| 777 | |
| 778 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 779 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 780 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 781 | seq_printf(m, "Pipe %c power disabled\n", |
| 782 | pipe_name(pipe)); |
| 783 | continue; |
| 784 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 785 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 786 | pipe_name(pipe), |
| 787 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 788 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 789 | pipe_name(pipe), |
| 790 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 791 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 792 | pipe_name(pipe), |
| 793 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 794 | |
| 795 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 799 | I915_READ(GEN8_DE_PORT_IMR)); |
| 800 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 801 | I915_READ(GEN8_DE_PORT_IIR)); |
| 802 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 803 | I915_READ(GEN8_DE_PORT_IER)); |
| 804 | |
| 805 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 806 | I915_READ(GEN8_DE_MISC_IMR)); |
| 807 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 808 | I915_READ(GEN8_DE_MISC_IIR)); |
| 809 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 810 | I915_READ(GEN8_DE_MISC_IER)); |
| 811 | |
| 812 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 813 | I915_READ(GEN8_PCU_IMR)); |
| 814 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 815 | I915_READ(GEN8_PCU_IIR)); |
| 816 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 817 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 818 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 819 | seq_printf(m, "Display IER:\t%08x\n", |
| 820 | I915_READ(VLV_IER)); |
| 821 | seq_printf(m, "Display IIR:\t%08x\n", |
| 822 | I915_READ(VLV_IIR)); |
| 823 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 824 | I915_READ(VLV_IIR_RW)); |
| 825 | seq_printf(m, "Display IMR:\t%08x\n", |
| 826 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 827 | for_each_pipe(dev_priv, pipe) { |
| 828 | enum intel_display_power_domain power_domain; |
| 829 | |
| 830 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 831 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 832 | power_domain)) { |
| 833 | seq_printf(m, "Pipe %c power disabled\n", |
| 834 | pipe_name(pipe)); |
| 835 | continue; |
| 836 | } |
| 837 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 838 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 839 | pipe_name(pipe), |
| 840 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 841 | intel_display_power_put(dev_priv, power_domain); |
| 842 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 843 | |
| 844 | seq_printf(m, "Master IER:\t%08x\n", |
| 845 | I915_READ(VLV_MASTER_IER)); |
| 846 | |
| 847 | seq_printf(m, "Render IER:\t%08x\n", |
| 848 | I915_READ(GTIER)); |
| 849 | seq_printf(m, "Render IIR:\t%08x\n", |
| 850 | I915_READ(GTIIR)); |
| 851 | seq_printf(m, "Render IMR:\t%08x\n", |
| 852 | I915_READ(GTIMR)); |
| 853 | |
| 854 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 855 | I915_READ(GEN6_PMIER)); |
| 856 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 857 | I915_READ(GEN6_PMIIR)); |
| 858 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 859 | I915_READ(GEN6_PMIMR)); |
| 860 | |
| 861 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 862 | I915_READ(PORT_HOTPLUG_EN)); |
| 863 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 864 | I915_READ(VLV_DPFLIPSTAT)); |
| 865 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 866 | I915_READ(DPINVGTT)); |
| 867 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 868 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 869 | seq_printf(m, "Interrupt enable: %08x\n", |
| 870 | I915_READ(IER)); |
| 871 | seq_printf(m, "Interrupt identity: %08x\n", |
| 872 | I915_READ(IIR)); |
| 873 | seq_printf(m, "Interrupt mask: %08x\n", |
| 874 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 875 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 876 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 877 | pipe_name(pipe), |
| 878 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 879 | } else { |
| 880 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 881 | I915_READ(DEIER)); |
| 882 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 883 | I915_READ(DEIIR)); |
| 884 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 885 | I915_READ(DEIMR)); |
| 886 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 887 | I915_READ(SDEIER)); |
| 888 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 889 | I915_READ(SDEIIR)); |
| 890 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 891 | I915_READ(SDEIMR)); |
| 892 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 893 | I915_READ(GTIER)); |
| 894 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 895 | I915_READ(GTIIR)); |
| 896 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 897 | I915_READ(GTIMR)); |
| 898 | } |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 899 | for_each_engine(engine, dev_priv, id) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 900 | if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 901 | seq_printf(m, |
| 902 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 903 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 904 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 905 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 906 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 907 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 908 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 909 | return 0; |
| 910 | } |
| 911 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 912 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 913 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 914 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 915 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 916 | int i, ret; |
| 917 | |
| 918 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 919 | if (ret) |
| 920 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 921 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 922 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 923 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 924 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 925 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 926 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 927 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 928 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 929 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 930 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 931 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 932 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 933 | } |
| 934 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 935 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 936 | return 0; |
| 937 | } |
| 938 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 939 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 940 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 941 | size_t count, loff_t *pos) |
| 942 | { |
| 943 | struct i915_gpu_state *error = file->private_data; |
| 944 | struct drm_i915_error_state_buf str; |
| 945 | ssize_t ret; |
| 946 | loff_t tmp; |
| 947 | |
| 948 | if (!error) |
| 949 | return 0; |
| 950 | |
| 951 | ret = i915_error_state_buf_init(&str, error->i915, count, *pos); |
| 952 | if (ret) |
| 953 | return ret; |
| 954 | |
| 955 | ret = i915_error_state_to_str(&str, error); |
| 956 | if (ret) |
| 957 | goto out; |
| 958 | |
| 959 | tmp = 0; |
| 960 | ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes); |
| 961 | if (ret < 0) |
| 962 | goto out; |
| 963 | |
| 964 | *pos = str.start + ret; |
| 965 | out: |
| 966 | i915_error_state_buf_release(&str); |
| 967 | return ret; |
| 968 | } |
| 969 | |
| 970 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 971 | { |
| 972 | i915_gpu_state_put(file->private_data); |
| 973 | return 0; |
| 974 | } |
| 975 | |
| 976 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 977 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 978 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 979 | struct i915_gpu_state *gpu; |
| 980 | |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 981 | intel_runtime_pm_get(i915); |
| 982 | gpu = i915_capture_gpu_state(i915); |
| 983 | intel_runtime_pm_put(i915); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 984 | if (!gpu) |
| 985 | return -ENOMEM; |
| 986 | |
| 987 | file->private_data = gpu; |
| 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | static const struct file_operations i915_gpu_info_fops = { |
| 992 | .owner = THIS_MODULE, |
| 993 | .open = i915_gpu_info_open, |
| 994 | .read = gpu_state_read, |
| 995 | .llseek = default_llseek, |
| 996 | .release = gpu_state_release, |
| 997 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 998 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 999 | static ssize_t |
| 1000 | i915_error_state_write(struct file *filp, |
| 1001 | const char __user *ubuf, |
| 1002 | size_t cnt, |
| 1003 | loff_t *ppos) |
| 1004 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1005 | struct i915_gpu_state *error = filp->private_data; |
| 1006 | |
| 1007 | if (!error) |
| 1008 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1009 | |
| 1010 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1011 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1012 | |
| 1013 | return cnt; |
| 1014 | } |
| 1015 | |
| 1016 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1017 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1018 | file->private_data = i915_first_error_state(inode->i_private); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1019 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1020 | } |
| 1021 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1022 | static const struct file_operations i915_error_state_fops = { |
| 1023 | .owner = THIS_MODULE, |
| 1024 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1025 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1026 | .write = i915_error_state_write, |
| 1027 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1028 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1029 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1030 | #endif |
| 1031 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1032 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1033 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1034 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1035 | struct drm_i915_private *dev_priv = data; |
| 1036 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1037 | int ret; |
| 1038 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1039 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1040 | if (ret) |
| 1041 | return ret; |
| 1042 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1043 | ret = i915_gem_set_global_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1044 | mutex_unlock(&dev->struct_mutex); |
| 1045 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1046 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1047 | } |
| 1048 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1049 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
Chris Wilson | 9b6586a | 2017-02-23 07:44:08 +0000 | [diff] [blame] | 1050 | NULL, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1051 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1052 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1053 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1054 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1055 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1056 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1057 | int ret = 0; |
| 1058 | |
| 1059 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1060 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1061 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1062 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1063 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1064 | |
| 1065 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1066 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1067 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1068 | MEMSTAT_VID_SHIFT); |
| 1069 | seq_printf(m, "Current P-state: %d\n", |
| 1070 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1071 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1072 | u32 rpmodectl, freq_sts; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1073 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1074 | mutex_lock(&dev_priv->pcu_lock); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1075 | |
| 1076 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1077 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1078 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1079 | seq_printf(m, "HW control enabled: %s\n", |
| 1080 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1081 | seq_printf(m, "SW control enabled: %s\n", |
| 1082 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1083 | GEN6_RP_MEDIA_SW_MODE)); |
| 1084 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1085 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1086 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1087 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1088 | |
| 1089 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1090 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1091 | |
| 1092 | seq_printf(m, "current GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1093 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1094 | |
| 1095 | seq_printf(m, "max GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1096 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1097 | |
| 1098 | seq_printf(m, "min GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1099 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1100 | |
| 1101 | seq_printf(m, "idle GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1102 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1103 | |
| 1104 | seq_printf(m, |
| 1105 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1106 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1107 | mutex_unlock(&dev_priv->pcu_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1108 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1109 | u32 rp_state_limits; |
| 1110 | u32 gt_perf_status; |
| 1111 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1112 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1113 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1114 | u32 rpupei, rpcurup, rpprevup; |
| 1115 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1116 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1117 | int max_freq; |
| 1118 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1119 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1120 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1121 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1122 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1123 | } else { |
| 1124 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1125 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1126 | } |
| 1127 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1128 | /* RPSTAT1 is in the GT power well */ |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1129 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1130 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1131 | reqf = I915_READ(GEN6_RPNSWREQ); |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1132 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1133 | reqf >>= 23; |
| 1134 | else { |
| 1135 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1136 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1137 | reqf >>= 24; |
| 1138 | else |
| 1139 | reqf >>= 25; |
| 1140 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1141 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1142 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1143 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1144 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1145 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1146 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1147 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1148 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1149 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1150 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1151 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1152 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1153 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1154 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1155 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1156 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1157 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1158 | else |
| 1159 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1160 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1161 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1162 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1163 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1164 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1165 | pm_ier = I915_READ(GEN6_PMIER); |
| 1166 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1167 | pm_isr = I915_READ(GEN6_PMISR); |
| 1168 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1169 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1170 | } else { |
| 1171 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1172 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1173 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1174 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1175 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1176 | } |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1177 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1178 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1179 | seq_printf(m, "HW control enabled: %s\n", |
| 1180 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1181 | seq_printf(m, "SW control enabled: %s\n", |
| 1182 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1183 | GEN6_RP_MEDIA_SW_MODE)); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1184 | 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] | 1185 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1186 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1187 | rps->pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1188 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1189 | seq_printf(m, "Render p-state ratio: %d\n", |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1190 | (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1191 | seq_printf(m, "Render p-state VID: %d\n", |
| 1192 | gt_perf_status & 0xff); |
| 1193 | seq_printf(m, "Render p-state limit: %d\n", |
| 1194 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1195 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1196 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1197 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1198 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1199 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1200 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1201 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1202 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1203 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1204 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1205 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1206 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1207 | seq_printf(m, "Up threshold: %d%%\n", rps->up_threshold); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1208 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1209 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1210 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1211 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1212 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1213 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1214 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1215 | seq_printf(m, "Down threshold: %d%%\n", rps->down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1216 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1217 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1218 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1219 | max_freq *= (IS_GEN9_BC(dev_priv) || |
| 1220 | IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1221 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1222 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1223 | |
| 1224 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1225 | max_freq *= (IS_GEN9_BC(dev_priv) || |
| 1226 | IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1227 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1228 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1229 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1230 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1231 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1232 | max_freq *= (IS_GEN9_BC(dev_priv) || |
| 1233 | IS_CANNONLAKE(dev_priv) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1234 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1235 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1236 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1237 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1238 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1239 | seq_printf(m, "Current freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1240 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1241 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1242 | seq_printf(m, "Idle freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1243 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1244 | seq_printf(m, "Min freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1245 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1246 | seq_printf(m, "Boost freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1247 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1248 | seq_printf(m, "Max freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1249 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1250 | seq_printf(m, |
| 1251 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1252 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1253 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1254 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1255 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1256 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1257 | 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] | 1258 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1259 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1260 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1261 | intel_runtime_pm_put(dev_priv); |
| 1262 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1263 | } |
| 1264 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1265 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1266 | struct seq_file *m, |
| 1267 | struct intel_instdone *instdone) |
| 1268 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1269 | int slice; |
| 1270 | int subslice; |
| 1271 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1272 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1273 | instdone->instdone); |
| 1274 | |
| 1275 | if (INTEL_GEN(dev_priv) <= 3) |
| 1276 | return; |
| 1277 | |
| 1278 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1279 | instdone->slice_common); |
| 1280 | |
| 1281 | if (INTEL_GEN(dev_priv) <= 6) |
| 1282 | return; |
| 1283 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1284 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1285 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1286 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1287 | |
| 1288 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1289 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1290 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1291 | } |
| 1292 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1293 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1294 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1295 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1296 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1297 | u64 acthd[I915_NUM_ENGINES]; |
| 1298 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1299 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1300 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1301 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1302 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1303 | seq_puts(m, "Wedged\n"); |
| 1304 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
| 1305 | seq_puts(m, "Reset in progress: struct_mutex backoff\n"); |
| 1306 | if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags)) |
| 1307 | seq_puts(m, "Reset in progress: reset handoff to waiter\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1308 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1309 | seq_puts(m, "Waiter holding struct mutex\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1310 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1311 | seq_puts(m, "struct_mutex blocked for reset\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1312 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1313 | if (!i915_modparams.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1314 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1315 | return 0; |
| 1316 | } |
| 1317 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1318 | intel_runtime_pm_get(dev_priv); |
| 1319 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1320 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1321 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1322 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1323 | } |
| 1324 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1325 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1326 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1327 | intel_runtime_pm_put(dev_priv); |
| 1328 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1329 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1330 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1331 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1332 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1333 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1334 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1335 | else |
| 1336 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1337 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1338 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1339 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1340 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1341 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1342 | struct rb_node *rb; |
| 1343 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1344 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1345 | seq_printf(m, "\tseqno = %x [current %x, last %x], inflight %d\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1346 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1347 | intel_engine_last_submit(engine), |
| 1348 | engine->timeline->inflight_seqnos); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1349 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1350 | yesno(intel_engine_has_waiter(engine)), |
| 1351 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1352 | &dev_priv->gpu_error.missed_irq_rings)), |
| 1353 | yesno(engine->hangcheck.stalled)); |
| 1354 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1355 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1356 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 1357 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1358 | |
| 1359 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1360 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1361 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1362 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1363 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1364 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1365 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1366 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1367 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1368 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1369 | engine->hangcheck.action, |
| 1370 | jiffies_to_msecs(jiffies - |
| 1371 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1372 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1373 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1374 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1375 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1376 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1377 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1378 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1379 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1380 | i915_instdone_info(dev_priv, m, |
| 1381 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1382 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1388 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1389 | { |
| 1390 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1391 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1392 | struct intel_engine_cs *engine; |
| 1393 | enum intel_engine_id id; |
| 1394 | |
| 1395 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1396 | |
| 1397 | for_each_engine(engine, dev_priv, id) { |
| 1398 | seq_printf(m, "%s = %u\n", engine->name, |
| 1399 | i915_reset_engine_count(error, engine)); |
| 1400 | } |
| 1401 | |
| 1402 | return 0; |
| 1403 | } |
| 1404 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1405 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1406 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1407 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1408 | u32 rgvmodectl, rstdbyctl; |
| 1409 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1410 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1411 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1412 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1413 | crstandvid = I915_READ16(CRSTANDVID); |
| 1414 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1415 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1416 | seq_printf(m, "Boost freq: %d\n", |
| 1417 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1418 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1419 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1420 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1421 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1422 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1423 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1424 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1425 | seq_printf(m, "Starting frequency: P%d\n", |
| 1426 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1427 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1428 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1429 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1430 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1431 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1432 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1433 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1434 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1435 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1436 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1437 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1438 | break; |
| 1439 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1440 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1441 | break; |
| 1442 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1443 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1444 | break; |
| 1445 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1446 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1447 | break; |
| 1448 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1449 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1450 | break; |
| 1451 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1452 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1453 | break; |
| 1454 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1455 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1456 | break; |
| 1457 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1458 | |
| 1459 | return 0; |
| 1460 | } |
| 1461 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1462 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1463 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1464 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1465 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1466 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1467 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1468 | seq_printf(m, "user.bypass_count = %u\n", |
| 1469 | i915->uncore.user_forcewake.count); |
| 1470 | |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1471 | for_each_fw_domain(fw_domain, i915, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1472 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1473 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1474 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1475 | |
| 1476 | return 0; |
| 1477 | } |
| 1478 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1479 | static void print_rc6_res(struct seq_file *m, |
| 1480 | const char *title, |
| 1481 | const i915_reg_t reg) |
| 1482 | { |
| 1483 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1484 | |
| 1485 | seq_printf(m, "%s %u (%llu us)\n", |
| 1486 | title, I915_READ(reg), |
| 1487 | intel_rc6_residency_us(dev_priv, reg)); |
| 1488 | } |
| 1489 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1490 | static int vlv_drpc_info(struct seq_file *m) |
| 1491 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1492 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1493 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1494 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1495 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1496 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1497 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1498 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1499 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1500 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1501 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1502 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1503 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1504 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1505 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1506 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1507 | 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] | 1508 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1509 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1510 | } |
| 1511 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1512 | static int gen6_drpc_info(struct seq_file *m) |
| 1513 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1514 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1515 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1516 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1517 | unsigned forcewake_count; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1518 | int count = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1519 | |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1520 | 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] | 1521 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1522 | seq_puts(m, "RC information inaccurate because somebody " |
| 1523 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1524 | } else { |
| 1525 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1526 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1527 | udelay(10); |
| 1528 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1529 | } |
| 1530 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1531 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1532 | 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] | 1533 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1534 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1535 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1536 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1537 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1538 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1539 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1540 | mutex_lock(&dev_priv->pcu_lock); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1541 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1542 | mutex_unlock(&dev_priv->pcu_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1543 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1544 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1545 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1546 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1547 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1548 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1549 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1550 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1551 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1552 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1553 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1554 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1555 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1556 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1557 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1558 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1559 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1560 | case GEN6_RC0: |
| 1561 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1562 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1563 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1564 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1565 | break; |
| 1566 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1567 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1568 | break; |
| 1569 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1570 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1571 | break; |
| 1572 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1573 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1574 | break; |
| 1575 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1576 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1577 | break; |
| 1578 | } |
| 1579 | |
| 1580 | seq_printf(m, "Core Power Down: %s\n", |
| 1581 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1582 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1583 | seq_printf(m, "Render Power Well: %s\n", |
| 1584 | (gen9_powergate_status & |
| 1585 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1586 | seq_printf(m, "Media Power Well: %s\n", |
| 1587 | (gen9_powergate_status & |
| 1588 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1589 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1590 | |
| 1591 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1592 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1593 | GEN6_GT_GFX_RC6_LOCKED); |
| 1594 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1595 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1596 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1597 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1598 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1599 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1600 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1601 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1602 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1603 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1604 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1608 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1609 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1610 | int err; |
| 1611 | |
| 1612 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1613 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1614 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1615 | err = vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1616 | else if (INTEL_GEN(dev_priv) >= 6) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1617 | err = gen6_drpc_info(m); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1618 | else |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1619 | err = ironlake_drpc_info(m); |
| 1620 | |
| 1621 | intel_runtime_pm_put(dev_priv); |
| 1622 | |
| 1623 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1624 | } |
| 1625 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1626 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1627 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1628 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1629 | |
| 1630 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1631 | dev_priv->fb_tracking.busy_bits); |
| 1632 | |
| 1633 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1634 | dev_priv->fb_tracking.flip_bits); |
| 1635 | |
| 1636 | return 0; |
| 1637 | } |
| 1638 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1639 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1640 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1641 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1642 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1643 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1644 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1645 | return 0; |
| 1646 | } |
| 1647 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1648 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1649 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1650 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1651 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1652 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1653 | else |
| 1654 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1655 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1656 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1657 | if (intel_fbc_is_active(dev_priv)) { |
| 1658 | u32 mask; |
| 1659 | |
| 1660 | if (INTEL_GEN(dev_priv) >= 8) |
| 1661 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1662 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1663 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1664 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1665 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1666 | else if (IS_G4X(dev_priv)) |
| 1667 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1668 | else |
| 1669 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1670 | FBC_STAT_COMPRESSED); |
| 1671 | |
| 1672 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1673 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1674 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1675 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1676 | intel_runtime_pm_put(dev_priv); |
| 1677 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1678 | return 0; |
| 1679 | } |
| 1680 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1681 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1682 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1683 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1684 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1685 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1686 | return -ENODEV; |
| 1687 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1688 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1689 | |
| 1690 | return 0; |
| 1691 | } |
| 1692 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1693 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1694 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1695 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1696 | u32 reg; |
| 1697 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1698 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1699 | return -ENODEV; |
| 1700 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1701 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1702 | |
| 1703 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1704 | dev_priv->fbc.false_color = val; |
| 1705 | |
| 1706 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1707 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1708 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1709 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1710 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1711 | return 0; |
| 1712 | } |
| 1713 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1714 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1715 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1716 | "%llu\n"); |
| 1717 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1718 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1719 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1720 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1721 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1722 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1723 | seq_puts(m, "not supported\n"); |
| 1724 | return 0; |
| 1725 | } |
| 1726 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1727 | intel_runtime_pm_get(dev_priv); |
| 1728 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1729 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1730 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1731 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1732 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1733 | seq_puts(m, "Currently: unknown\n"); |
| 1734 | } else { |
| 1735 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1736 | seq_puts(m, "Currently: enabled\n"); |
| 1737 | else |
| 1738 | seq_puts(m, "Currently: disabled\n"); |
| 1739 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1740 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1741 | intel_runtime_pm_put(dev_priv); |
| 1742 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1743 | return 0; |
| 1744 | } |
| 1745 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1746 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1747 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1748 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1749 | bool sr_enabled = false; |
| 1750 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1751 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1752 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1753 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1754 | if (INTEL_GEN(dev_priv) >= 9) |
| 1755 | /* no global SR status; inspect per-plane WM */; |
| 1756 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1757 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1758 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1759 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1760 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1761 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1762 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1763 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1764 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1765 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1766 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1767 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1768 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1769 | intel_runtime_pm_put(dev_priv); |
| 1770 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1771 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1772 | |
| 1773 | return 0; |
| 1774 | } |
| 1775 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1776 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1777 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1778 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1779 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1780 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1781 | int ret; |
| 1782 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1783 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1784 | return -ENODEV; |
| 1785 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1786 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1787 | if (ret) |
| 1788 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1789 | |
| 1790 | temp = i915_mch_val(dev_priv); |
| 1791 | chipset = i915_chipset_val(dev_priv); |
| 1792 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1793 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1794 | |
| 1795 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1796 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1797 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1798 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1799 | |
| 1800 | return 0; |
| 1801 | } |
| 1802 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1803 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1804 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1805 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1806 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1807 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1808 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1809 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1810 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1811 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1812 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1813 | return 0; |
| 1814 | } |
| 1815 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1816 | intel_runtime_pm_get(dev_priv); |
| 1817 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1818 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1819 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1820 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1821 | |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1822 | if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1823 | /* Convert GT frequency to 50 HZ units */ |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1824 | min_gpu_freq = rps->min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1825 | max_gpu_freq = rps->max_freq_softlimit / GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1826 | } else { |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1827 | min_gpu_freq = rps->min_freq_softlimit; |
| 1828 | max_gpu_freq = rps->max_freq_softlimit; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1829 | } |
| 1830 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1831 | 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] | 1832 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1833 | 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] | 1834 | ia_freq = gpu_freq; |
| 1835 | sandybridge_pcode_read(dev_priv, |
| 1836 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1837 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1838 | 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] | 1839 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1840 | (IS_GEN9_BC(dev_priv) || |
| 1841 | IS_CANNONLAKE(dev_priv) ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1842 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1843 | ((ia_freq >> 0) & 0xff) * 100, |
| 1844 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1845 | } |
| 1846 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1847 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1848 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1849 | out: |
| 1850 | intel_runtime_pm_put(dev_priv); |
| 1851 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1852 | } |
| 1853 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1854 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1855 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1856 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1857 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1858 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1859 | int ret; |
| 1860 | |
| 1861 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1862 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1863 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1864 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1865 | if (opregion->header) |
| 1866 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1867 | |
| 1868 | mutex_unlock(&dev->struct_mutex); |
| 1869 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1870 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1871 | return 0; |
| 1872 | } |
| 1873 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1874 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1875 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1876 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1877 | |
| 1878 | if (opregion->vbt) |
| 1879 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1880 | |
| 1881 | return 0; |
| 1882 | } |
| 1883 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1884 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1885 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1886 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1887 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1888 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1889 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1890 | int ret; |
| 1891 | |
| 1892 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1893 | if (ret) |
| 1894 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1895 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1896 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1897 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1898 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1899 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1900 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1901 | fbdev_fb->base.width, |
| 1902 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1903 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1904 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1905 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1906 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1907 | describe_obj(m, fbdev_fb->obj); |
| 1908 | seq_putc(m, '\n'); |
| 1909 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1910 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1911 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1912 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1913 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1914 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1915 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1916 | continue; |
| 1917 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1918 | 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] | 1919 | fb->base.width, |
| 1920 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1921 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1922 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1923 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1924 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1925 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1926 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1927 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1928 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1929 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1930 | |
| 1931 | return 0; |
| 1932 | } |
| 1933 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1934 | 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] | 1935 | { |
Chris Wilson | fe085f1 | 2017-03-21 10:25:52 +0000 | [diff] [blame] | 1936 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u)", |
| 1937 | ring->space, ring->head, ring->tail); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1938 | } |
| 1939 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1940 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1941 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1942 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1943 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1944 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1945 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1946 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1947 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1948 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1949 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1950 | if (ret) |
| 1951 | return ret; |
| 1952 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1953 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1954 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1955 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1956 | struct task_struct *task; |
| 1957 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1958 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1959 | if (task) { |
| 1960 | seq_printf(m, "(%s [%d]) ", |
| 1961 | task->comm, task->pid); |
| 1962 | put_task_struct(task); |
| 1963 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1964 | } else if (IS_ERR(ctx->file_priv)) { |
| 1965 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1966 | } else { |
| 1967 | seq_puts(m, "(kernel) "); |
| 1968 | } |
| 1969 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1970 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1971 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1972 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1973 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1974 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 1975 | |
| 1976 | seq_printf(m, "%s: ", engine->name); |
| 1977 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 1978 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1979 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1980 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1981 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1982 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1983 | } |
| 1984 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1985 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1986 | } |
| 1987 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1988 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1989 | |
| 1990 | return 0; |
| 1991 | } |
| 1992 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1993 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1994 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1995 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1996 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1997 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1998 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1999 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2000 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2001 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2002 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2003 | if (!vma) { |
| 2004 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2005 | return; |
| 2006 | } |
| 2007 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2008 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 2009 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 2010 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2011 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2012 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2013 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2014 | return; |
| 2015 | } |
| 2016 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2017 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 2018 | if (page) { |
| 2019 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2020 | |
| 2021 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2022 | seq_printf(m, |
| 2023 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2024 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2025 | reg_state[j], reg_state[j + 1], |
| 2026 | reg_state[j + 2], reg_state[j + 3]); |
| 2027 | } |
| 2028 | kunmap_atomic(reg_state); |
| 2029 | } |
| 2030 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2031 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2032 | seq_putc(m, '\n'); |
| 2033 | } |
| 2034 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2035 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2036 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2037 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2038 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2039 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2040 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2041 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2042 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2043 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 2044 | if (!i915_modparams.enable_execlists) { |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2045 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2046 | return 0; |
| 2047 | } |
| 2048 | |
| 2049 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2050 | if (ret) |
| 2051 | return ret; |
| 2052 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 2053 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2054 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2055 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2056 | |
| 2057 | mutex_unlock(&dev->struct_mutex); |
| 2058 | |
| 2059 | return 0; |
| 2060 | } |
| 2061 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2062 | static const char *swizzle_string(unsigned swizzle) |
| 2063 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2064 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2065 | case I915_BIT_6_SWIZZLE_NONE: |
| 2066 | return "none"; |
| 2067 | case I915_BIT_6_SWIZZLE_9: |
| 2068 | return "bit9"; |
| 2069 | case I915_BIT_6_SWIZZLE_9_10: |
| 2070 | return "bit9/bit10"; |
| 2071 | case I915_BIT_6_SWIZZLE_9_11: |
| 2072 | return "bit9/bit11"; |
| 2073 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2074 | return "bit9/bit10/bit11"; |
| 2075 | case I915_BIT_6_SWIZZLE_9_17: |
| 2076 | return "bit9/bit17"; |
| 2077 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2078 | return "bit9/bit10/bit17"; |
| 2079 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2080 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2081 | } |
| 2082 | |
| 2083 | return "bug"; |
| 2084 | } |
| 2085 | |
| 2086 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2087 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2088 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2089 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2090 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2091 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2092 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2093 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2094 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2095 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2096 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2097 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2098 | seq_printf(m, "DDC = 0x%08x\n", |
| 2099 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2100 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2101 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2102 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2103 | I915_READ16(C0DRB3)); |
| 2104 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2105 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2106 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2107 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2108 | I915_READ(MAD_DIMM_C0)); |
| 2109 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2110 | I915_READ(MAD_DIMM_C1)); |
| 2111 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2112 | I915_READ(MAD_DIMM_C2)); |
| 2113 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2114 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2115 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2116 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2117 | I915_READ(GAMTARBMODE)); |
| 2118 | else |
| 2119 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2120 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2121 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2122 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2123 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2124 | |
| 2125 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2126 | seq_puts(m, "L-shaped memory detected\n"); |
| 2127 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2128 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2129 | |
| 2130 | return 0; |
| 2131 | } |
| 2132 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2133 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2134 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2135 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2136 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2137 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2138 | |
| 2139 | if (!ppgtt) { |
| 2140 | seq_printf(m, " no ppgtt for context %d\n", |
| 2141 | ctx->user_handle); |
| 2142 | return 0; |
| 2143 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2144 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2145 | if (i915_gem_context_is_default(ctx)) |
| 2146 | seq_puts(m, " default context:\n"); |
| 2147 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2148 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2149 | ppgtt->debug_dump(ppgtt, m); |
| 2150 | |
| 2151 | return 0; |
| 2152 | } |
| 2153 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2154 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2155 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2156 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2157 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2158 | struct intel_engine_cs *engine; |
| 2159 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2160 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2161 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2162 | if (!ppgtt) |
| 2163 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2164 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2165 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2166 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2167 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2168 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2169 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2170 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2171 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2172 | } |
| 2173 | } |
| 2174 | } |
| 2175 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2176 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2177 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2178 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2179 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2180 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2181 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2182 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2183 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2184 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2185 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2186 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2187 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2188 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2189 | I915_READ(RING_MODE_GEN7(engine))); |
| 2190 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2191 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2192 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2193 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2194 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2195 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2196 | } |
| 2197 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2198 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2199 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2200 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2201 | 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] | 2202 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2203 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2204 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2205 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2206 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2207 | } |
| 2208 | |
| 2209 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2210 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2211 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2212 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2213 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2214 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2215 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2216 | mutex_lock(&dev->filelist_mutex); |
| 2217 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2218 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2219 | goto out_unlock; |
| 2220 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2221 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2222 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2223 | if (INTEL_GEN(dev_priv) >= 8) |
| 2224 | gen8_ppgtt_info(m, dev_priv); |
| 2225 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2226 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2227 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2228 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2229 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2230 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2231 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2232 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2233 | if (!task) { |
| 2234 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2235 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2236 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2237 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2238 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2239 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2240 | (void *)(unsigned long)m); |
| 2241 | } |
| 2242 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2243 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2244 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2245 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2246 | out_unlock: |
| 2247 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2248 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2249 | } |
| 2250 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2251 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2252 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2253 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2254 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2255 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2256 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2257 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2258 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2259 | |
| 2260 | return count; |
| 2261 | } |
| 2262 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2263 | static const char *rps_power_to_str(unsigned int power) |
| 2264 | { |
| 2265 | static const char * const strings[] = { |
| 2266 | [LOW_POWER] = "low power", |
| 2267 | [BETWEEN] = "mixed", |
| 2268 | [HIGH_POWER] = "high power", |
| 2269 | }; |
| 2270 | |
| 2271 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2272 | return "unknown"; |
| 2273 | |
| 2274 | return strings[power]; |
| 2275 | } |
| 2276 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2277 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2278 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2279 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2280 | struct drm_device *dev = &dev_priv->drm; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2281 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2282 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2283 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2284 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2285 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2286 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2287 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2288 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2289 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2290 | seq_printf(m, "Frequency requested %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2291 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2292 | seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2293 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2294 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2295 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2296 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2297 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2298 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2299 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2300 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2301 | |
| 2302 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2303 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2304 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2305 | struct task_struct *task; |
| 2306 | |
| 2307 | rcu_read_lock(); |
| 2308 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2309 | seq_printf(m, "%s [%d]: %d boosts\n", |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2310 | task ? task->comm : "<unknown>", |
| 2311 | task ? task->pid : -1, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2312 | atomic_read(&file_priv->rps_client.boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2313 | rcu_read_unlock(); |
| 2314 | } |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2315 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2316 | atomic_read(&rps->boosts)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2317 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2318 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2319 | if (INTEL_GEN(dev_priv) >= 6 && |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2320 | rps->enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2321 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2322 | u32 rpup, rpupei; |
| 2323 | u32 rpdown, rpdownei; |
| 2324 | |
| 2325 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2326 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2327 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2328 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2329 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2330 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2331 | |
| 2332 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2333 | rps_power_to_str(rps->power)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2334 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2335 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2336 | rps->up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2337 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2338 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2339 | rps->down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2340 | } else { |
| 2341 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2342 | } |
| 2343 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2344 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2345 | } |
| 2346 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2347 | static int i915_llc(struct seq_file *m, void *data) |
| 2348 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2349 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2350 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2351 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2352 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2353 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2354 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2355 | |
| 2356 | return 0; |
| 2357 | } |
| 2358 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2359 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2360 | { |
| 2361 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2362 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2363 | |
| 2364 | if (!HAS_HUC_UCODE(dev_priv)) |
| 2365 | return 0; |
| 2366 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2367 | p = drm_seq_file_printer(m); |
| 2368 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2369 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2370 | intel_runtime_pm_get(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2371 | 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] | 2372 | intel_runtime_pm_put(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2373 | |
| 2374 | return 0; |
| 2375 | } |
| 2376 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2377 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2378 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2379 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2380 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2381 | u32 tmp, i; |
| 2382 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2383 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2384 | return 0; |
| 2385 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2386 | p = drm_seq_file_printer(m); |
| 2387 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2388 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2389 | intel_runtime_pm_get(dev_priv); |
| 2390 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2391 | tmp = I915_READ(GUC_STATUS); |
| 2392 | |
| 2393 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2394 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2395 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2396 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2397 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2398 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2399 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2400 | seq_puts(m, "\nScratch registers:\n"); |
| 2401 | for (i = 0; i < 16; i++) |
| 2402 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2403 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2404 | intel_runtime_pm_put(dev_priv); |
| 2405 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2406 | return 0; |
| 2407 | } |
| 2408 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2409 | static void i915_guc_log_info(struct seq_file *m, |
| 2410 | struct drm_i915_private *dev_priv) |
| 2411 | { |
| 2412 | struct intel_guc *guc = &dev_priv->guc; |
| 2413 | |
| 2414 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2415 | |
| 2416 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2417 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2418 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2419 | |
| 2420 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2421 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2422 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2423 | |
| 2424 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2425 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2426 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2427 | |
| 2428 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2429 | guc->log.flush_interrupt_count); |
| 2430 | |
| 2431 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2432 | guc->log.capture_miss_count); |
| 2433 | } |
| 2434 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2435 | static void i915_guc_client_info(struct seq_file *m, |
| 2436 | struct drm_i915_private *dev_priv, |
| 2437 | struct i915_guc_client *client) |
| 2438 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2439 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2440 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2441 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2442 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2443 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2444 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2445 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2446 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2447 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2448 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2449 | u64 submissions = client->submissions[id]; |
| 2450 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2451 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2452 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2453 | } |
| 2454 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2455 | } |
| 2456 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2457 | static bool check_guc_submission(struct seq_file *m) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2458 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2459 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2460 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2461 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2462 | if (!guc->execbuf_client) { |
| 2463 | seq_printf(m, "GuC submission %s\n", |
| 2464 | HAS_GUC_SCHED(dev_priv) ? |
| 2465 | "disabled" : |
| 2466 | "not supported"); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2467 | return false; |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2468 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2469 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2470 | return true; |
| 2471 | } |
| 2472 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2473 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2474 | { |
| 2475 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2476 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2477 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2478 | if (!check_guc_submission(m)) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2479 | return 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2480 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2481 | seq_printf(m, "Doorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2482 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2483 | 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] | 2484 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2485 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2486 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Dave Gordon | e12ab16 | 2017-10-26 16:17:37 +0200 | [diff] [blame] | 2487 | seq_printf(m, "\nGuC preempt client @ %p:\n", guc->preempt_client); |
| 2488 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2489 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2490 | i915_guc_log_info(m, dev_priv); |
| 2491 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2492 | /* Add more as required ... */ |
| 2493 | |
| 2494 | return 0; |
| 2495 | } |
| 2496 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2497 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2498 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2499 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2500 | const struct intel_guc *guc = &dev_priv->guc; |
| 2501 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
| 2502 | struct i915_guc_client *client = guc->execbuf_client; |
| 2503 | unsigned int tmp; |
| 2504 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2505 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2506 | if (!check_guc_submission(m)) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2507 | return 0; |
| 2508 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2509 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2510 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2511 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2512 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2513 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2514 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2515 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2516 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2517 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2518 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2519 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2520 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2521 | desc->engines_used); |
| 2522 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2523 | desc->db_trigger_phy, |
| 2524 | desc->db_trigger_cpu, |
| 2525 | desc->db_trigger_uk); |
| 2526 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2527 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2528 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2529 | desc->wq_addr, desc->wq_size); |
| 2530 | seq_putc(m, '\n'); |
| 2531 | |
| 2532 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2533 | u32 guc_engine_id = engine->guc_id; |
| 2534 | struct guc_execlist_context *lrc = |
| 2535 | &desc->lrc[guc_engine_id]; |
| 2536 | |
| 2537 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2538 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2539 | lrc->context_desc); |
| 2540 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2541 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2542 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2543 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2544 | seq_putc(m, '\n'); |
| 2545 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2546 | } |
| 2547 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2548 | return 0; |
| 2549 | } |
| 2550 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2551 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2552 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2553 | struct drm_info_node *node = m->private; |
| 2554 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2555 | bool dump_load_err = !!node->info_ent->data; |
| 2556 | struct drm_i915_gem_object *obj = NULL; |
| 2557 | u32 *log; |
| 2558 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2559 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2560 | if (dump_load_err) |
| 2561 | obj = dev_priv->guc.load_err_log; |
| 2562 | else if (dev_priv->guc.log.vma) |
| 2563 | obj = dev_priv->guc.log.vma->obj; |
| 2564 | |
| 2565 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2566 | return 0; |
| 2567 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2568 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2569 | if (IS_ERR(log)) { |
| 2570 | DRM_DEBUG("Failed to pin object\n"); |
| 2571 | seq_puts(m, "(log data unaccessible)\n"); |
| 2572 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2573 | } |
| 2574 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2575 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2576 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2577 | *(log + i), *(log + i + 1), |
| 2578 | *(log + i + 2), *(log + i + 3)); |
| 2579 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2580 | seq_putc(m, '\n'); |
| 2581 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2582 | i915_gem_object_unpin_map(obj); |
| 2583 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2584 | return 0; |
| 2585 | } |
| 2586 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2587 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2588 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2589 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2590 | |
| 2591 | if (!dev_priv->guc.log.vma) |
| 2592 | return -EINVAL; |
| 2593 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 2594 | *val = i915_modparams.guc_log_level; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2595 | |
| 2596 | return 0; |
| 2597 | } |
| 2598 | |
| 2599 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2600 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2601 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2602 | int ret; |
| 2603 | |
| 2604 | if (!dev_priv->guc.log.vma) |
| 2605 | return -EINVAL; |
| 2606 | |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2607 | ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2608 | if (ret) |
| 2609 | return ret; |
| 2610 | |
| 2611 | intel_runtime_pm_get(dev_priv); |
| 2612 | ret = i915_guc_log_control(dev_priv, val); |
| 2613 | intel_runtime_pm_put(dev_priv); |
| 2614 | |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2615 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2616 | return ret; |
| 2617 | } |
| 2618 | |
| 2619 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2620 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2621 | "%lld\n"); |
| 2622 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2623 | static const char *psr2_live_status(u32 val) |
| 2624 | { |
| 2625 | static const char * const live_status[] = { |
| 2626 | "IDLE", |
| 2627 | "CAPTURE", |
| 2628 | "CAPTURE_FS", |
| 2629 | "SLEEP", |
| 2630 | "BUFON_FW", |
| 2631 | "ML_UP", |
| 2632 | "SU_STANDBY", |
| 2633 | "FAST_SLEEP", |
| 2634 | "DEEP_SLEEP", |
| 2635 | "BUF_ON", |
| 2636 | "TG_ON" |
| 2637 | }; |
| 2638 | |
| 2639 | val = (val & EDP_PSR2_STATUS_STATE_MASK) >> EDP_PSR2_STATUS_STATE_SHIFT; |
| 2640 | if (val < ARRAY_SIZE(live_status)) |
| 2641 | return live_status[val]; |
| 2642 | |
| 2643 | return "unknown"; |
| 2644 | } |
| 2645 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2646 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2647 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2648 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2649 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2650 | u32 stat[3]; |
| 2651 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2652 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2653 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2654 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2655 | seq_puts(m, "PSR not supported\n"); |
| 2656 | return 0; |
| 2657 | } |
| 2658 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2659 | intel_runtime_pm_get(dev_priv); |
| 2660 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2661 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2662 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2663 | 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] | 2664 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2665 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2666 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2667 | dev_priv->psr.busy_frontbuffer_bits); |
| 2668 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2669 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2670 | |
Nagaraju, Vathsala | 7e3eb59 | 2016-12-09 23:42:09 +0530 | [diff] [blame] | 2671 | if (HAS_DDI(dev_priv)) { |
| 2672 | if (dev_priv->psr.psr2_support) |
| 2673 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2674 | else |
| 2675 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
| 2676 | } else { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2677 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2678 | enum transcoder cpu_transcoder = |
| 2679 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2680 | enum intel_display_power_domain power_domain; |
| 2681 | |
| 2682 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2683 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2684 | power_domain)) |
| 2685 | continue; |
| 2686 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2687 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2688 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2689 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2690 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2691 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2692 | |
| 2693 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2694 | } |
| 2695 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2696 | |
| 2697 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2698 | yesno(dev_priv->psr.link_standby)); |
| 2699 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2700 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2701 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2702 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2703 | for_each_pipe(dev_priv, pipe) { |
| 2704 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2705 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2706 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2707 | } |
| 2708 | seq_puts(m, "\n"); |
| 2709 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2710 | /* |
| 2711 | * VLV/CHV PSR has no kind of performance counter |
| 2712 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2713 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2714 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2715 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2716 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2717 | |
| 2718 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2719 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2720 | if (dev_priv->psr.psr2_support) { |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2721 | u32 psr2 = I915_READ(EDP_PSR2_STATUS_CTL); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2722 | |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2723 | seq_printf(m, "EDP_PSR2_STATUS_CTL: %x [%s]\n", |
| 2724 | psr2, psr2_live_status(psr2)); |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2725 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2726 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2727 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2728 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2729 | return 0; |
| 2730 | } |
| 2731 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2732 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2733 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2734 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2735 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2736 | struct intel_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2737 | struct drm_connector_list_iter conn_iter; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2738 | struct intel_dp *intel_dp = NULL; |
| 2739 | int ret; |
| 2740 | u8 crc[6]; |
| 2741 | |
| 2742 | drm_modeset_lock_all(dev); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2743 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 2744 | for_each_intel_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2745 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2746 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2747 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2748 | continue; |
| 2749 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2750 | crtc = connector->base.state->crtc; |
| 2751 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2752 | continue; |
| 2753 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2754 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2755 | continue; |
| 2756 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2757 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2758 | |
| 2759 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2760 | if (ret) |
| 2761 | goto out; |
| 2762 | |
| 2763 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2764 | crc[0], crc[1], crc[2], |
| 2765 | crc[3], crc[4], crc[5]); |
| 2766 | goto out; |
| 2767 | } |
| 2768 | ret = -ENODEV; |
| 2769 | out: |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2770 | drm_connector_list_iter_end(&conn_iter); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2771 | drm_modeset_unlock_all(dev); |
| 2772 | return ret; |
| 2773 | } |
| 2774 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2775 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2776 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2777 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2778 | unsigned long long power; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2779 | u32 units; |
| 2780 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2781 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2782 | return -ENODEV; |
| 2783 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2784 | intel_runtime_pm_get(dev_priv); |
| 2785 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2786 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) { |
| 2787 | intel_runtime_pm_put(dev_priv); |
| 2788 | return -ENODEV; |
| 2789 | } |
| 2790 | |
| 2791 | units = (power & 0x1f00) >> 8; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2792 | power = I915_READ(MCH_SECP_NRG_STTS); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2793 | power = (1000000 * power) >> units; /* convert to uJ */ |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2794 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2795 | intel_runtime_pm_put(dev_priv); |
| 2796 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2797 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2798 | |
| 2799 | return 0; |
| 2800 | } |
| 2801 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2802 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2803 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2804 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2805 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2806 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2807 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2808 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2809 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2810 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2811 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2812 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2813 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2814 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2815 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2816 | #else |
| 2817 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2818 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2819 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2820 | pci_power_name(pdev->current_state), |
| 2821 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2822 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2823 | return 0; |
| 2824 | } |
| 2825 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2826 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2827 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2828 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2829 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2830 | int i; |
| 2831 | |
| 2832 | mutex_lock(&power_domains->lock); |
| 2833 | |
| 2834 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2835 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2836 | struct i915_power_well *power_well; |
| 2837 | enum intel_display_power_domain power_domain; |
| 2838 | |
| 2839 | power_well = &power_domains->power_wells[i]; |
| 2840 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2841 | power_well->count); |
| 2842 | |
Joonas Lahtinen | 8385c2e | 2017-02-08 15:12:10 +0200 | [diff] [blame] | 2843 | for_each_power_domain(power_domain, power_well->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2844 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2845 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2846 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2847 | } |
| 2848 | |
| 2849 | mutex_unlock(&power_domains->lock); |
| 2850 | |
| 2851 | return 0; |
| 2852 | } |
| 2853 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2854 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2855 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2856 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2857 | struct intel_csr *csr; |
| 2858 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2859 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2860 | seq_puts(m, "not supported\n"); |
| 2861 | return 0; |
| 2862 | } |
| 2863 | |
| 2864 | csr = &dev_priv->csr; |
| 2865 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2866 | intel_runtime_pm_get(dev_priv); |
| 2867 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2868 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2869 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2870 | |
| 2871 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2872 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2873 | |
| 2874 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2875 | CSR_VERSION_MINOR(csr->version)); |
| 2876 | |
Mika Kuoppala | 48de568 | 2017-05-09 13:05:22 +0300 | [diff] [blame] | 2877 | if (IS_KABYLAKE(dev_priv) || |
| 2878 | (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6))) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2879 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2880 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2881 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2882 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2883 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2884 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2885 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2886 | } |
| 2887 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2888 | out: |
| 2889 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2890 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2891 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2892 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2893 | intel_runtime_pm_put(dev_priv); |
| 2894 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2895 | return 0; |
| 2896 | } |
| 2897 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2898 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2899 | struct drm_display_mode *mode) |
| 2900 | { |
| 2901 | int i; |
| 2902 | |
| 2903 | for (i = 0; i < tabs; i++) |
| 2904 | seq_putc(m, '\t'); |
| 2905 | |
| 2906 | 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", |
| 2907 | mode->base.id, mode->name, |
| 2908 | mode->vrefresh, mode->clock, |
| 2909 | mode->hdisplay, mode->hsync_start, |
| 2910 | mode->hsync_end, mode->htotal, |
| 2911 | mode->vdisplay, mode->vsync_start, |
| 2912 | mode->vsync_end, mode->vtotal, |
| 2913 | mode->type, mode->flags); |
| 2914 | } |
| 2915 | |
| 2916 | static void intel_encoder_info(struct seq_file *m, |
| 2917 | struct intel_crtc *intel_crtc, |
| 2918 | struct intel_encoder *intel_encoder) |
| 2919 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2920 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2921 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2922 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2923 | struct intel_connector *intel_connector; |
| 2924 | struct drm_encoder *encoder; |
| 2925 | |
| 2926 | encoder = &intel_encoder->base; |
| 2927 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2928 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2929 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2930 | struct drm_connector *connector = &intel_connector->base; |
| 2931 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2932 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2933 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2934 | drm_get_connector_status_name(connector->status)); |
| 2935 | if (connector->status == connector_status_connected) { |
| 2936 | struct drm_display_mode *mode = &crtc->mode; |
| 2937 | seq_printf(m, ", mode:\n"); |
| 2938 | intel_seq_print_mode(m, 2, mode); |
| 2939 | } else { |
| 2940 | seq_putc(m, '\n'); |
| 2941 | } |
| 2942 | } |
| 2943 | } |
| 2944 | |
| 2945 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2946 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2947 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2948 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2949 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2950 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2951 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2952 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2953 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2954 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2955 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2956 | fb->base.id, plane_state->src_x >> 16, |
| 2957 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2958 | else |
| 2959 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2960 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2961 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2962 | } |
| 2963 | |
| 2964 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2965 | { |
| 2966 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2967 | |
| 2968 | seq_printf(m, "\tfixed mode:\n"); |
| 2969 | intel_seq_print_mode(m, 2, mode); |
| 2970 | } |
| 2971 | |
| 2972 | static void intel_dp_info(struct seq_file *m, |
| 2973 | struct intel_connector *intel_connector) |
| 2974 | { |
| 2975 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2976 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2977 | |
| 2978 | 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] | 2979 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2980 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2981 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2982 | |
| 2983 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2984 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2985 | } |
| 2986 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2987 | static void intel_dp_mst_info(struct seq_file *m, |
| 2988 | struct intel_connector *intel_connector) |
| 2989 | { |
| 2990 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2991 | struct intel_dp_mst_encoder *intel_mst = |
| 2992 | enc_to_mst(&intel_encoder->base); |
| 2993 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2994 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2995 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2996 | intel_connector->port); |
| 2997 | |
| 2998 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2999 | } |
| 3000 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3001 | static void intel_hdmi_info(struct seq_file *m, |
| 3002 | struct intel_connector *intel_connector) |
| 3003 | { |
| 3004 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3005 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 3006 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 3007 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3008 | } |
| 3009 | |
| 3010 | static void intel_lvds_info(struct seq_file *m, |
| 3011 | struct intel_connector *intel_connector) |
| 3012 | { |
| 3013 | intel_panel_info(m, &intel_connector->panel); |
| 3014 | } |
| 3015 | |
| 3016 | static void intel_connector_info(struct seq_file *m, |
| 3017 | struct drm_connector *connector) |
| 3018 | { |
| 3019 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 3020 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3021 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3022 | |
| 3023 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 3024 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3025 | drm_get_connector_status_name(connector->status)); |
| 3026 | if (connector->status == connector_status_connected) { |
| 3027 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 3028 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 3029 | connector->display_info.width_mm, |
| 3030 | connector->display_info.height_mm); |
| 3031 | seq_printf(m, "\tsubpixel order: %s\n", |
| 3032 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 3033 | seq_printf(m, "\tCEA rev: %d\n", |
| 3034 | connector->display_info.cea_rev); |
| 3035 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3036 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 3037 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3038 | return; |
| 3039 | |
| 3040 | switch (connector->connector_type) { |
| 3041 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 3042 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3043 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3044 | intel_dp_mst_info(m, intel_connector); |
| 3045 | else |
| 3046 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3047 | break; |
| 3048 | case DRM_MODE_CONNECTOR_LVDS: |
| 3049 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3050 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3051 | break; |
| 3052 | case DRM_MODE_CONNECTOR_HDMIA: |
| 3053 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame^] | 3054 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3055 | intel_hdmi_info(m, intel_connector); |
| 3056 | break; |
| 3057 | default: |
| 3058 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3059 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3060 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3061 | seq_printf(m, "\tmodes:\n"); |
| 3062 | list_for_each_entry(mode, &connector->modes, head) |
| 3063 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3064 | } |
| 3065 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3066 | static const char *plane_type(enum drm_plane_type type) |
| 3067 | { |
| 3068 | switch (type) { |
| 3069 | case DRM_PLANE_TYPE_OVERLAY: |
| 3070 | return "OVL"; |
| 3071 | case DRM_PLANE_TYPE_PRIMARY: |
| 3072 | return "PRI"; |
| 3073 | case DRM_PLANE_TYPE_CURSOR: |
| 3074 | return "CUR"; |
| 3075 | /* |
| 3076 | * Deliberately omitting default: to generate compiler warnings |
| 3077 | * when a new drm_plane_type gets added. |
| 3078 | */ |
| 3079 | } |
| 3080 | |
| 3081 | return "unknown"; |
| 3082 | } |
| 3083 | |
| 3084 | static const char *plane_rotation(unsigned int rotation) |
| 3085 | { |
| 3086 | static char buf[48]; |
| 3087 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 3088 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3089 | * will print them all to visualize if the values are misused |
| 3090 | */ |
| 3091 | snprintf(buf, sizeof(buf), |
| 3092 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 3093 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 3094 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 3095 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 3096 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 3097 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 3098 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3099 | rotation); |
| 3100 | |
| 3101 | return buf; |
| 3102 | } |
| 3103 | |
| 3104 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3105 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3106 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3107 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3108 | struct intel_plane *intel_plane; |
| 3109 | |
| 3110 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3111 | struct drm_plane_state *state; |
| 3112 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3113 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3114 | |
| 3115 | if (!plane->state) { |
| 3116 | seq_puts(m, "plane->state is NULL!\n"); |
| 3117 | continue; |
| 3118 | } |
| 3119 | |
| 3120 | state = plane->state; |
| 3121 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3122 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3123 | drm_get_format_name(state->fb->format->format, |
| 3124 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3125 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3126 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3127 | } |
| 3128 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3129 | 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", |
| 3130 | plane->base.id, |
| 3131 | plane_type(intel_plane->base.type), |
| 3132 | state->crtc_x, state->crtc_y, |
| 3133 | state->crtc_w, state->crtc_h, |
| 3134 | (state->src_x >> 16), |
| 3135 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3136 | (state->src_y >> 16), |
| 3137 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3138 | (state->src_w >> 16), |
| 3139 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3140 | (state->src_h >> 16), |
| 3141 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3142 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3143 | plane_rotation(state->rotation)); |
| 3144 | } |
| 3145 | } |
| 3146 | |
| 3147 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3148 | { |
| 3149 | struct intel_crtc_state *pipe_config; |
| 3150 | int num_scalers = intel_crtc->num_scalers; |
| 3151 | int i; |
| 3152 | |
| 3153 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3154 | |
| 3155 | /* Not all platformas have a scaler */ |
| 3156 | if (num_scalers) { |
| 3157 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3158 | num_scalers, |
| 3159 | pipe_config->scaler_state.scaler_users, |
| 3160 | pipe_config->scaler_state.scaler_id); |
| 3161 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3162 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3163 | struct intel_scaler *sc = |
| 3164 | &pipe_config->scaler_state.scalers[i]; |
| 3165 | |
| 3166 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3167 | i, yesno(sc->in_use), sc->mode); |
| 3168 | } |
| 3169 | seq_puts(m, "\n"); |
| 3170 | } else { |
| 3171 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3172 | } |
| 3173 | } |
| 3174 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3175 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3176 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3177 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3178 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3179 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3180 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3181 | struct drm_connector_list_iter conn_iter; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3182 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3183 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3184 | seq_printf(m, "CRTC info\n"); |
| 3185 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3186 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3187 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3188 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3189 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3190 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3191 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3192 | seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n", |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3193 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3194 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3195 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3196 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3197 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3198 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3199 | struct intel_plane *cursor = |
| 3200 | to_intel_plane(crtc->base.cursor); |
| 3201 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3202 | intel_crtc_info(m, crtc); |
| 3203 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3204 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3205 | yesno(cursor->base.state->visible), |
| 3206 | cursor->base.state->crtc_x, |
| 3207 | cursor->base.state->crtc_y, |
| 3208 | cursor->base.state->crtc_w, |
| 3209 | cursor->base.state->crtc_h, |
| 3210 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3211 | intel_scaler_info(m, crtc); |
| 3212 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3213 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3214 | |
| 3215 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3216 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3217 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3218 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3219 | } |
| 3220 | |
| 3221 | seq_printf(m, "\n"); |
| 3222 | seq_printf(m, "Connector info\n"); |
| 3223 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3224 | mutex_lock(&dev->mode_config.mutex); |
| 3225 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3226 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3227 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3228 | drm_connector_list_iter_end(&conn_iter); |
| 3229 | mutex_unlock(&dev->mode_config.mutex); |
| 3230 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3231 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3232 | |
| 3233 | return 0; |
| 3234 | } |
| 3235 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3236 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3237 | { |
| 3238 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3239 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3240 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3241 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3242 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3243 | intel_runtime_pm_get(dev_priv); |
| 3244 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3245 | seq_printf(m, "GT awake? %s\n", |
| 3246 | yesno(dev_priv->gt.awake)); |
| 3247 | seq_printf(m, "Global active requests: %d\n", |
| 3248 | dev_priv->gt.active_requests); |
| 3249 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3250 | p = drm_seq_file_printer(m); |
| 3251 | for_each_engine(engine, dev_priv, id) |
| 3252 | intel_engine_dump(engine, &p); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3253 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3254 | intel_runtime_pm_put(dev_priv); |
| 3255 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3256 | return 0; |
| 3257 | } |
| 3258 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3259 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3260 | { |
| 3261 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3262 | |
| 3263 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3264 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3265 | |
| 3266 | return 0; |
| 3267 | } |
| 3268 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3269 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3270 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3271 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3272 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3273 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3274 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3275 | enum intel_engine_id id; |
| 3276 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3277 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 3278 | if (!i915_modparams.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3279 | seq_puts(m, "Semaphores are disabled\n"); |
| 3280 | return 0; |
| 3281 | } |
| 3282 | |
| 3283 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3284 | if (ret) |
| 3285 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3286 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3287 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3288 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3289 | struct page *page; |
| 3290 | uint64_t *seqno; |
| 3291 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3292 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3293 | |
| 3294 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3295 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3296 | uint64_t offset; |
| 3297 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3298 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3299 | |
| 3300 | seq_puts(m, " Last signal:"); |
| 3301 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3302 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3303 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3304 | seqno[offset], offset * 8); |
| 3305 | } |
| 3306 | seq_putc(m, '\n'); |
| 3307 | |
| 3308 | seq_puts(m, " Last wait: "); |
| 3309 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3310 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3311 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3312 | seqno[offset], offset * 8); |
| 3313 | } |
| 3314 | seq_putc(m, '\n'); |
| 3315 | |
| 3316 | } |
| 3317 | kunmap_atomic(seqno); |
| 3318 | } else { |
| 3319 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3320 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3321 | for (j = 0; j < num_rings; j++) |
| 3322 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3323 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3324 | seq_putc(m, '\n'); |
| 3325 | } |
| 3326 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3327 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3328 | mutex_unlock(&dev->struct_mutex); |
| 3329 | return 0; |
| 3330 | } |
| 3331 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3332 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3333 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3334 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3335 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3336 | int i; |
| 3337 | |
| 3338 | drm_modeset_lock_all(dev); |
| 3339 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3340 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3341 | |
| 3342 | 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] | 3343 | 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] | 3344 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3345 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3346 | 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] | 3347 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3348 | pll->state.hw_state.dpll_md); |
| 3349 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3350 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3351 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3352 | } |
| 3353 | drm_modeset_unlock_all(dev); |
| 3354 | |
| 3355 | return 0; |
| 3356 | } |
| 3357 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3358 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3359 | { |
| 3360 | int i; |
| 3361 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3362 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3363 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3364 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3365 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3366 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3367 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3368 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3369 | if (ret) |
| 3370 | return ret; |
| 3371 | |
| 3372 | intel_runtime_pm_get(dev_priv); |
| 3373 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3374 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3375 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3376 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3377 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3378 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3379 | i915_reg_t addr; |
| 3380 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3381 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3382 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3383 | addr = workarounds->reg[i].addr; |
| 3384 | mask = workarounds->reg[i].mask; |
| 3385 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3386 | read = I915_READ(addr); |
| 3387 | ok = (value & mask) == (read & mask); |
| 3388 | 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] | 3389 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3390 | } |
| 3391 | |
| 3392 | intel_runtime_pm_put(dev_priv); |
| 3393 | mutex_unlock(&dev->struct_mutex); |
| 3394 | |
| 3395 | return 0; |
| 3396 | } |
| 3397 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3398 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3399 | { |
| 3400 | struct drm_i915_private *dev_priv = m->private; |
| 3401 | |
| 3402 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3403 | yesno(dev_priv->ipc_enabled)); |
| 3404 | return 0; |
| 3405 | } |
| 3406 | |
| 3407 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3408 | { |
| 3409 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3410 | |
| 3411 | if (!HAS_IPC(dev_priv)) |
| 3412 | return -ENODEV; |
| 3413 | |
| 3414 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3415 | } |
| 3416 | |
| 3417 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3418 | size_t len, loff_t *offp) |
| 3419 | { |
| 3420 | struct seq_file *m = file->private_data; |
| 3421 | struct drm_i915_private *dev_priv = m->private; |
| 3422 | int ret; |
| 3423 | bool enable; |
| 3424 | |
| 3425 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3426 | if (ret < 0) |
| 3427 | return ret; |
| 3428 | |
| 3429 | intel_runtime_pm_get(dev_priv); |
| 3430 | if (!dev_priv->ipc_enabled && enable) |
| 3431 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3432 | dev_priv->wm.distrust_bios_wm = true; |
| 3433 | dev_priv->ipc_enabled = enable; |
| 3434 | intel_enable_ipc(dev_priv); |
| 3435 | intel_runtime_pm_put(dev_priv); |
| 3436 | |
| 3437 | return len; |
| 3438 | } |
| 3439 | |
| 3440 | static const struct file_operations i915_ipc_status_fops = { |
| 3441 | .owner = THIS_MODULE, |
| 3442 | .open = i915_ipc_status_open, |
| 3443 | .read = seq_read, |
| 3444 | .llseek = seq_lseek, |
| 3445 | .release = single_release, |
| 3446 | .write = i915_ipc_status_write |
| 3447 | }; |
| 3448 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3449 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3450 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3451 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3452 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3453 | struct skl_ddb_allocation *ddb; |
| 3454 | struct skl_ddb_entry *entry; |
| 3455 | enum pipe pipe; |
| 3456 | int plane; |
| 3457 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3458 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3459 | return 0; |
| 3460 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3461 | drm_modeset_lock_all(dev); |
| 3462 | |
| 3463 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3464 | |
| 3465 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3466 | |
| 3467 | for_each_pipe(dev_priv, pipe) { |
| 3468 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3469 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3470 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3471 | entry = &ddb->plane[pipe][plane]; |
| 3472 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3473 | entry->start, entry->end, |
| 3474 | skl_ddb_entry_size(entry)); |
| 3475 | } |
| 3476 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3477 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3478 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3479 | entry->end, skl_ddb_entry_size(entry)); |
| 3480 | } |
| 3481 | |
| 3482 | drm_modeset_unlock_all(dev); |
| 3483 | |
| 3484 | return 0; |
| 3485 | } |
| 3486 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3487 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3488 | struct drm_device *dev, |
| 3489 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3490 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3491 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3492 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3493 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3494 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3495 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3496 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3497 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3498 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3499 | if (connector->state->crtc != &intel_crtc->base) |
| 3500 | continue; |
| 3501 | |
| 3502 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3503 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3504 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3505 | |
| 3506 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3507 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3508 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3509 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3510 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3511 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3512 | else |
| 3513 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3514 | |
| 3515 | seq_puts(m, "\n\n"); |
| 3516 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3517 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3518 | struct intel_panel *panel; |
| 3519 | |
| 3520 | mutex_lock(&drrs->mutex); |
| 3521 | /* DRRS Supported */ |
| 3522 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3523 | |
| 3524 | /* disable_drrs() will make drrs->dp NULL */ |
| 3525 | if (!drrs->dp) { |
| 3526 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3527 | mutex_unlock(&drrs->mutex); |
| 3528 | return; |
| 3529 | } |
| 3530 | |
| 3531 | panel = &drrs->dp->attached_connector->panel; |
| 3532 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3533 | drrs->busy_frontbuffer_bits); |
| 3534 | |
| 3535 | seq_puts(m, "\n\t\t"); |
| 3536 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3537 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3538 | vrefresh = panel->fixed_mode->vrefresh; |
| 3539 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3540 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3541 | vrefresh = panel->downclock_mode->vrefresh; |
| 3542 | } else { |
| 3543 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3544 | drrs->refresh_rate_type); |
| 3545 | mutex_unlock(&drrs->mutex); |
| 3546 | return; |
| 3547 | } |
| 3548 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3549 | |
| 3550 | seq_puts(m, "\n\t\t"); |
| 3551 | mutex_unlock(&drrs->mutex); |
| 3552 | } else { |
| 3553 | /* DRRS not supported. Print the VBT parameter*/ |
| 3554 | seq_puts(m, "\tDRRS Supported : No"); |
| 3555 | } |
| 3556 | seq_puts(m, "\n"); |
| 3557 | } |
| 3558 | |
| 3559 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3560 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3561 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3562 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3563 | struct intel_crtc *intel_crtc; |
| 3564 | int active_crtc_cnt = 0; |
| 3565 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3566 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3567 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3568 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3569 | active_crtc_cnt++; |
| 3570 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3571 | |
| 3572 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3573 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3574 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3575 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3576 | |
| 3577 | if (!active_crtc_cnt) |
| 3578 | seq_puts(m, "No active crtc found\n"); |
| 3579 | |
| 3580 | return 0; |
| 3581 | } |
| 3582 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3583 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3584 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3585 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3586 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3587 | struct intel_encoder *intel_encoder; |
| 3588 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3589 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3590 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3591 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3592 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3593 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3594 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3595 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3596 | |
| 3597 | intel_encoder = intel_attached_encoder(connector); |
| 3598 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3599 | continue; |
| 3600 | |
| 3601 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3602 | if (!intel_dig_port->dp.can_mst) |
| 3603 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3604 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3605 | seq_printf(m, "MST Source Port %c\n", |
| 3606 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3607 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3608 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3609 | drm_connector_list_iter_end(&conn_iter); |
| 3610 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3611 | return 0; |
| 3612 | } |
| 3613 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3614 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3615 | const char __user *ubuf, |
| 3616 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3617 | { |
| 3618 | char *input_buffer; |
| 3619 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3620 | struct drm_device *dev; |
| 3621 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3622 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3623 | struct intel_dp *intel_dp; |
| 3624 | int val = 0; |
| 3625 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3626 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3627 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3628 | if (len == 0) |
| 3629 | return 0; |
| 3630 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3631 | input_buffer = memdup_user_nul(ubuf, len); |
| 3632 | if (IS_ERR(input_buffer)) |
| 3633 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3634 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3635 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3636 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3637 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3638 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3639 | struct intel_encoder *encoder; |
| 3640 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3641 | if (connector->connector_type != |
| 3642 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3643 | continue; |
| 3644 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3645 | encoder = to_intel_encoder(connector->encoder); |
| 3646 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3647 | continue; |
| 3648 | |
| 3649 | if (encoder && connector->status == connector_status_connected) { |
| 3650 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3651 | status = kstrtoint(input_buffer, 10, &val); |
| 3652 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3653 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3654 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3655 | /* To prevent erroneous activation of the compliance |
| 3656 | * testing code, only accept an actual value of 1 here |
| 3657 | */ |
| 3658 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3659 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3660 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3661 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3662 | } |
| 3663 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3664 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3665 | kfree(input_buffer); |
| 3666 | if (status < 0) |
| 3667 | return status; |
| 3668 | |
| 3669 | *offp += len; |
| 3670 | return len; |
| 3671 | } |
| 3672 | |
| 3673 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3674 | { |
| 3675 | struct drm_device *dev = m->private; |
| 3676 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3677 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3678 | struct intel_dp *intel_dp; |
| 3679 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3680 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3681 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3682 | struct intel_encoder *encoder; |
| 3683 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3684 | if (connector->connector_type != |
| 3685 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3686 | continue; |
| 3687 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3688 | encoder = to_intel_encoder(connector->encoder); |
| 3689 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3690 | continue; |
| 3691 | |
| 3692 | if (encoder && connector->status == connector_status_connected) { |
| 3693 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3694 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3695 | seq_puts(m, "1"); |
| 3696 | else |
| 3697 | seq_puts(m, "0"); |
| 3698 | } else |
| 3699 | seq_puts(m, "0"); |
| 3700 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3701 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3702 | |
| 3703 | return 0; |
| 3704 | } |
| 3705 | |
| 3706 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3707 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3708 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3709 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3710 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3711 | return single_open(file, i915_displayport_test_active_show, |
| 3712 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3713 | } |
| 3714 | |
| 3715 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3716 | .owner = THIS_MODULE, |
| 3717 | .open = i915_displayport_test_active_open, |
| 3718 | .read = seq_read, |
| 3719 | .llseek = seq_lseek, |
| 3720 | .release = single_release, |
| 3721 | .write = i915_displayport_test_active_write |
| 3722 | }; |
| 3723 | |
| 3724 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3725 | { |
| 3726 | struct drm_device *dev = m->private; |
| 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; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3729 | struct intel_dp *intel_dp; |
| 3730 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3731 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3732 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3733 | struct intel_encoder *encoder; |
| 3734 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3735 | if (connector->connector_type != |
| 3736 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3737 | continue; |
| 3738 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3739 | encoder = to_intel_encoder(connector->encoder); |
| 3740 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3741 | continue; |
| 3742 | |
| 3743 | if (encoder && connector->status == connector_status_connected) { |
| 3744 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3745 | if (intel_dp->compliance.test_type == |
| 3746 | DP_TEST_LINK_EDID_READ) |
| 3747 | seq_printf(m, "%lx", |
| 3748 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3749 | else if (intel_dp->compliance.test_type == |
| 3750 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3751 | seq_printf(m, "hdisplay: %d\n", |
| 3752 | intel_dp->compliance.test_data.hdisplay); |
| 3753 | seq_printf(m, "vdisplay: %d\n", |
| 3754 | intel_dp->compliance.test_data.vdisplay); |
| 3755 | seq_printf(m, "bpc: %u\n", |
| 3756 | intel_dp->compliance.test_data.bpc); |
| 3757 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3758 | } else |
| 3759 | seq_puts(m, "0"); |
| 3760 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3761 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3762 | |
| 3763 | return 0; |
| 3764 | } |
| 3765 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3766 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3767 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3768 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3769 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3770 | return single_open(file, i915_displayport_test_data_show, |
| 3771 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3772 | } |
| 3773 | |
| 3774 | static const struct file_operations i915_displayport_test_data_fops = { |
| 3775 | .owner = THIS_MODULE, |
| 3776 | .open = i915_displayport_test_data_open, |
| 3777 | .read = seq_read, |
| 3778 | .llseek = seq_lseek, |
| 3779 | .release = single_release |
| 3780 | }; |
| 3781 | |
| 3782 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3783 | { |
| 3784 | struct drm_device *dev = m->private; |
| 3785 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3786 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3787 | struct intel_dp *intel_dp; |
| 3788 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3789 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3790 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3791 | struct intel_encoder *encoder; |
| 3792 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3793 | if (connector->connector_type != |
| 3794 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3795 | continue; |
| 3796 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3797 | encoder = to_intel_encoder(connector->encoder); |
| 3798 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3799 | continue; |
| 3800 | |
| 3801 | if (encoder && connector->status == connector_status_connected) { |
| 3802 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3803 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3804 | } else |
| 3805 | seq_puts(m, "0"); |
| 3806 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3807 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3808 | |
| 3809 | return 0; |
| 3810 | } |
| 3811 | |
| 3812 | static int i915_displayport_test_type_open(struct inode *inode, |
| 3813 | struct file *file) |
| 3814 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3815 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3816 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3817 | return single_open(file, i915_displayport_test_type_show, |
| 3818 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3819 | } |
| 3820 | |
| 3821 | static const struct file_operations i915_displayport_test_type_fops = { |
| 3822 | .owner = THIS_MODULE, |
| 3823 | .open = i915_displayport_test_type_open, |
| 3824 | .read = seq_read, |
| 3825 | .llseek = seq_lseek, |
| 3826 | .release = single_release |
| 3827 | }; |
| 3828 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3829 | 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] | 3830 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3831 | struct drm_i915_private *dev_priv = m->private; |
| 3832 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3833 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3834 | int num_levels; |
| 3835 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3836 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3837 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3838 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3839 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3840 | else if (IS_G4X(dev_priv)) |
| 3841 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3842 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3843 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3844 | |
| 3845 | drm_modeset_lock_all(dev); |
| 3846 | |
| 3847 | for (level = 0; level < num_levels; level++) { |
| 3848 | unsigned int latency = wm[level]; |
| 3849 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3850 | /* |
| 3851 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3852 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3853 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3854 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3855 | IS_VALLEYVIEW(dev_priv) || |
| 3856 | IS_CHERRYVIEW(dev_priv) || |
| 3857 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3858 | latency *= 10; |
| 3859 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3860 | latency *= 5; |
| 3861 | |
| 3862 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3863 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3864 | } |
| 3865 | |
| 3866 | drm_modeset_unlock_all(dev); |
| 3867 | } |
| 3868 | |
| 3869 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3870 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3871 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3872 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3873 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3874 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3875 | latencies = dev_priv->wm.skl_latency; |
| 3876 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3877 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3878 | |
| 3879 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3880 | |
| 3881 | return 0; |
| 3882 | } |
| 3883 | |
| 3884 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3885 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3886 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3887 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3888 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3889 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3890 | latencies = dev_priv->wm.skl_latency; |
| 3891 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3892 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3893 | |
| 3894 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3895 | |
| 3896 | return 0; |
| 3897 | } |
| 3898 | |
| 3899 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3900 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3901 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3902 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3903 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3904 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3905 | latencies = dev_priv->wm.skl_latency; |
| 3906 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3907 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3908 | |
| 3909 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3910 | |
| 3911 | return 0; |
| 3912 | } |
| 3913 | |
| 3914 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3915 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3916 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3917 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3918 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3919 | return -ENODEV; |
| 3920 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3921 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3925 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3926 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3927 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3928 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3929 | return -ENODEV; |
| 3930 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3931 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3932 | } |
| 3933 | |
| 3934 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3935 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3936 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3937 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3938 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3939 | return -ENODEV; |
| 3940 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3941 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3942 | } |
| 3943 | |
| 3944 | 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] | 3945 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3946 | { |
| 3947 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3948 | struct drm_i915_private *dev_priv = m->private; |
| 3949 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3950 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3951 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3952 | int level; |
| 3953 | int ret; |
| 3954 | char tmp[32]; |
| 3955 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3956 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3957 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3958 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3959 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3960 | else if (IS_G4X(dev_priv)) |
| 3961 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3962 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3963 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3964 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3965 | if (len >= sizeof(tmp)) |
| 3966 | return -EINVAL; |
| 3967 | |
| 3968 | if (copy_from_user(tmp, ubuf, len)) |
| 3969 | return -EFAULT; |
| 3970 | |
| 3971 | tmp[len] = '\0'; |
| 3972 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3973 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3974 | &new[0], &new[1], &new[2], &new[3], |
| 3975 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3976 | if (ret != num_levels) |
| 3977 | return -EINVAL; |
| 3978 | |
| 3979 | drm_modeset_lock_all(dev); |
| 3980 | |
| 3981 | for (level = 0; level < num_levels; level++) |
| 3982 | wm[level] = new[level]; |
| 3983 | |
| 3984 | drm_modeset_unlock_all(dev); |
| 3985 | |
| 3986 | return len; |
| 3987 | } |
| 3988 | |
| 3989 | |
| 3990 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3991 | size_t len, loff_t *offp) |
| 3992 | { |
| 3993 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3994 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3995 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3996 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3997 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3998 | latencies = dev_priv->wm.skl_latency; |
| 3999 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4000 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4001 | |
| 4002 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4003 | } |
| 4004 | |
| 4005 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4006 | size_t len, loff_t *offp) |
| 4007 | { |
| 4008 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4009 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4010 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4011 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4012 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4013 | latencies = dev_priv->wm.skl_latency; |
| 4014 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4015 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4016 | |
| 4017 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4018 | } |
| 4019 | |
| 4020 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4021 | size_t len, loff_t *offp) |
| 4022 | { |
| 4023 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4024 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4025 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4026 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4027 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4028 | latencies = dev_priv->wm.skl_latency; |
| 4029 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4030 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4031 | |
| 4032 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4033 | } |
| 4034 | |
| 4035 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4036 | .owner = THIS_MODULE, |
| 4037 | .open = pri_wm_latency_open, |
| 4038 | .read = seq_read, |
| 4039 | .llseek = seq_lseek, |
| 4040 | .release = single_release, |
| 4041 | .write = pri_wm_latency_write |
| 4042 | }; |
| 4043 | |
| 4044 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4045 | .owner = THIS_MODULE, |
| 4046 | .open = spr_wm_latency_open, |
| 4047 | .read = seq_read, |
| 4048 | .llseek = seq_lseek, |
| 4049 | .release = single_release, |
| 4050 | .write = spr_wm_latency_write |
| 4051 | }; |
| 4052 | |
| 4053 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4054 | .owner = THIS_MODULE, |
| 4055 | .open = cur_wm_latency_open, |
| 4056 | .read = seq_read, |
| 4057 | .llseek = seq_lseek, |
| 4058 | .release = single_release, |
| 4059 | .write = cur_wm_latency_write |
| 4060 | }; |
| 4061 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4062 | static int |
| 4063 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4064 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4065 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4066 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4067 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4068 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4069 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4070 | } |
| 4071 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4072 | static int |
| 4073 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4074 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4075 | struct drm_i915_private *i915 = data; |
| 4076 | struct intel_engine_cs *engine; |
| 4077 | unsigned int tmp; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4078 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4079 | /* |
| 4080 | * There is no safeguard against this debugfs entry colliding |
| 4081 | * with the hangcheck calling same i915_handle_error() in |
| 4082 | * parallel, causing an explosion. For now we assume that the |
| 4083 | * test harness is responsible enough not to inject gpu hangs |
| 4084 | * while it is writing to 'i915_wedged' |
| 4085 | */ |
| 4086 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4087 | if (i915_reset_backoff(&i915->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4088 | return -EAGAIN; |
| 4089 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4090 | for_each_engine_masked(engine, i915, val, tmp) { |
| 4091 | engine->hangcheck.seqno = intel_engine_get_seqno(engine); |
| 4092 | engine->hangcheck.stalled = true; |
| 4093 | } |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4094 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4095 | i915_handle_error(i915, val, "Manually setting wedged to %llu", val); |
| 4096 | |
| 4097 | wait_on_bit(&i915->gpu_error.flags, |
Chris Wilson | d3df42b | 2017-03-16 17:13:05 +0000 | [diff] [blame] | 4098 | I915_RESET_HANDOFF, |
| 4099 | TASK_UNINTERRUPTIBLE); |
| 4100 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4101 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4102 | } |
| 4103 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4104 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4105 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4106 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4107 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4108 | static int |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4109 | fault_irq_set(struct drm_i915_private *i915, |
| 4110 | unsigned long *irq, |
| 4111 | unsigned long val) |
| 4112 | { |
| 4113 | int err; |
| 4114 | |
| 4115 | err = mutex_lock_interruptible(&i915->drm.struct_mutex); |
| 4116 | if (err) |
| 4117 | return err; |
| 4118 | |
| 4119 | err = i915_gem_wait_for_idle(i915, |
| 4120 | I915_WAIT_LOCKED | |
| 4121 | I915_WAIT_INTERRUPTIBLE); |
| 4122 | if (err) |
| 4123 | goto err_unlock; |
| 4124 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4125 | *irq = val; |
| 4126 | mutex_unlock(&i915->drm.struct_mutex); |
| 4127 | |
| 4128 | /* Flush idle worker to disarm irq */ |
Chris Wilson | 7c26240 | 2017-10-06 11:40:38 +0100 | [diff] [blame] | 4129 | drain_delayed_work(&i915->gt.idle_work); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4130 | |
| 4131 | return 0; |
| 4132 | |
| 4133 | err_unlock: |
| 4134 | mutex_unlock(&i915->drm.struct_mutex); |
| 4135 | return err; |
| 4136 | } |
| 4137 | |
| 4138 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4139 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4140 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4141 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4142 | |
| 4143 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4144 | return 0; |
| 4145 | } |
| 4146 | |
| 4147 | static int |
| 4148 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4149 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4150 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4151 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4152 | return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4153 | } |
| 4154 | |
| 4155 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4156 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4157 | "0x%08llx\n"); |
| 4158 | |
| 4159 | static int |
| 4160 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4161 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4162 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4163 | |
| 4164 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4165 | |
| 4166 | return 0; |
| 4167 | } |
| 4168 | |
| 4169 | static int |
| 4170 | i915_ring_test_irq_set(void *data, u64 val) |
| 4171 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4172 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4173 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4174 | val &= INTEL_INFO(i915)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4175 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4176 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4177 | return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4178 | } |
| 4179 | |
| 4180 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4181 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4182 | "0x%08llx\n"); |
| 4183 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4184 | #define DROP_UNBOUND BIT(0) |
| 4185 | #define DROP_BOUND BIT(1) |
| 4186 | #define DROP_RETIRE BIT(2) |
| 4187 | #define DROP_ACTIVE BIT(3) |
| 4188 | #define DROP_FREED BIT(4) |
| 4189 | #define DROP_SHRINK_ALL BIT(5) |
| 4190 | #define DROP_IDLE BIT(6) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4191 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4192 | DROP_BOUND | \ |
| 4193 | DROP_RETIRE | \ |
| 4194 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4195 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4196 | DROP_SHRINK_ALL |\ |
| 4197 | DROP_IDLE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4198 | static int |
| 4199 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4200 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4201 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4202 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4203 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4204 | } |
| 4205 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4206 | static int |
| 4207 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4208 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4209 | struct drm_i915_private *dev_priv = data; |
| 4210 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4211 | int ret = 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4212 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4213 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 4214 | val, val & DROP_ALL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4215 | |
| 4216 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4217 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4218 | if (val & (DROP_ACTIVE | DROP_RETIRE)) { |
| 4219 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4220 | if (ret) |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4221 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4222 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4223 | if (val & DROP_ACTIVE) |
| 4224 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4225 | I915_WAIT_INTERRUPTIBLE | |
| 4226 | I915_WAIT_LOCKED); |
| 4227 | |
| 4228 | if (val & DROP_RETIRE) |
| 4229 | i915_gem_retire_requests(dev_priv); |
| 4230 | |
| 4231 | mutex_unlock(&dev->struct_mutex); |
| 4232 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4233 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4234 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4235 | if (val & DROP_BOUND) |
Chris Wilson | 912d572 | 2017-09-06 16:19:30 -0700 | [diff] [blame] | 4236 | i915_gem_shrink(dev_priv, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4237 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4238 | if (val & DROP_UNBOUND) |
Chris Wilson | 912d572 | 2017-09-06 16:19:30 -0700 | [diff] [blame] | 4239 | i915_gem_shrink(dev_priv, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4240 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4241 | if (val & DROP_SHRINK_ALL) |
| 4242 | i915_gem_shrink_all(dev_priv); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4243 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4244 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4245 | if (val & DROP_IDLE) |
| 4246 | drain_delayed_work(&dev_priv->gt.idle_work); |
| 4247 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4248 | if (val & DROP_FREED) { |
| 4249 | synchronize_rcu(); |
Chris Wilson | bdeb978 | 2016-12-23 14:57:56 +0000 | [diff] [blame] | 4250 | i915_gem_drain_freed_objects(dev_priv); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4251 | } |
| 4252 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4253 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4254 | } |
| 4255 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4256 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4257 | i915_drop_caches_get, i915_drop_caches_set, |
| 4258 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4259 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4260 | static int |
| 4261 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4262 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4263 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4264 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4265 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4266 | return -ENODEV; |
| 4267 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4268 | *val = intel_gpu_freq(dev_priv, dev_priv->gt_pm.rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4269 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4270 | } |
| 4271 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4272 | static int |
| 4273 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4274 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4275 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4276 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4277 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4278 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4279 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4280 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4281 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4282 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4283 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4284 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 4285 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4286 | if (ret) |
| 4287 | return ret; |
| 4288 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4289 | /* |
| 4290 | * Turbo will still be enabled, but won't go above the set value. |
| 4291 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4292 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4293 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4294 | hw_max = rps->max_freq; |
| 4295 | hw_min = rps->min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4296 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4297 | if (val < hw_min || val > hw_max || val < rps->min_freq_softlimit) { |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 4298 | mutex_unlock(&dev_priv->pcu_lock); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4299 | return -EINVAL; |
| 4300 | } |
| 4301 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4302 | rps->max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4303 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 4304 | if (intel_set_rps(dev_priv, val)) |
| 4305 | DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n"); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4306 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 4307 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4308 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4309 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4310 | } |
| 4311 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4312 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4313 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4314 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4315 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4316 | static int |
| 4317 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4318 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4319 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4320 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4321 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4322 | return -ENODEV; |
| 4323 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4324 | *val = intel_gpu_freq(dev_priv, dev_priv->gt_pm.rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4325 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4326 | } |
| 4327 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4328 | static int |
| 4329 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4330 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4331 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4332 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4333 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4334 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4335 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 4336 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4337 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4338 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4339 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4340 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 4341 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4342 | if (ret) |
| 4343 | return ret; |
| 4344 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4345 | /* |
| 4346 | * Turbo will still be enabled, but won't go below the set value. |
| 4347 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4348 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4349 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4350 | hw_max = rps->max_freq; |
| 4351 | hw_min = rps->min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4352 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4353 | if (val < hw_min || |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4354 | val > hw_max || val > rps->max_freq_softlimit) { |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 4355 | mutex_unlock(&dev_priv->pcu_lock); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4356 | return -EINVAL; |
| 4357 | } |
| 4358 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 4359 | rps->min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4360 | |
Chris Wilson | 9fcee2f | 2017-01-26 10:19:19 +0000 | [diff] [blame] | 4361 | if (intel_set_rps(dev_priv, val)) |
| 4362 | DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n"); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4363 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 4364 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4365 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4366 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4367 | } |
| 4368 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4369 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4370 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4371 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4372 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4373 | static int |
| 4374 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4375 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4376 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4377 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4378 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4379 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4380 | return -ENODEV; |
| 4381 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4382 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4383 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4384 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4385 | |
| 4386 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4387 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4388 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4389 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4390 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4391 | } |
| 4392 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4393 | static int |
| 4394 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4395 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4396 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4397 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4398 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4399 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4400 | return -ENODEV; |
| 4401 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4402 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4403 | return -EINVAL; |
| 4404 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4405 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4406 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4407 | |
| 4408 | /* Update the cache sharing policy here as well */ |
| 4409 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4410 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4411 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4412 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4413 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4414 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4415 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4416 | } |
| 4417 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4418 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4419 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4420 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4421 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4422 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4423 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4424 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 4425 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4426 | int ss; |
| 4427 | u32 sig1[ss_max], sig2[ss_max]; |
| 4428 | |
| 4429 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4430 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4431 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4432 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4433 | |
| 4434 | for (ss = 0; ss < ss_max; ss++) { |
| 4435 | unsigned int eu_cnt; |
| 4436 | |
| 4437 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4438 | /* skip disabled subslice */ |
| 4439 | continue; |
| 4440 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4441 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4442 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4443 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4444 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4445 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4446 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4447 | sseu->eu_total += eu_cnt; |
| 4448 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4449 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4450 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4451 | } |
| 4452 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4453 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4454 | struct sseu_dev_info *sseu) |
| 4455 | { |
| 4456 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
| 4457 | int s_max = 6, ss_max = 4; |
| 4458 | int s, ss; |
| 4459 | u32 s_reg[s_max], eu_reg[2 * s_max], eu_mask[2]; |
| 4460 | |
| 4461 | for (s = 0; s < s_max; s++) { |
| 4462 | /* |
| 4463 | * FIXME: Valid SS Mask respects the spec and read |
| 4464 | * only valid bits for those registers, excluding reserverd |
| 4465 | * although this seems wrong because it would leave many |
| 4466 | * subslices without ACK. |
| 4467 | */ |
| 4468 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4469 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4470 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4471 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4472 | } |
| 4473 | |
| 4474 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4475 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4476 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4477 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4478 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4479 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4480 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4481 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4482 | |
| 4483 | for (s = 0; s < s_max; s++) { |
| 4484 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4485 | /* skip disabled slice */ |
| 4486 | continue; |
| 4487 | |
| 4488 | sseu->slice_mask |= BIT(s); |
| 4489 | sseu->subslice_mask = info->sseu.subslice_mask; |
| 4490 | |
| 4491 | for (ss = 0; ss < ss_max; ss++) { |
| 4492 | unsigned int eu_cnt; |
| 4493 | |
| 4494 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4495 | /* skip disabled subslice */ |
| 4496 | continue; |
| 4497 | |
| 4498 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4499 | eu_mask[ss % 2]); |
| 4500 | sseu->eu_total += eu_cnt; |
| 4501 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4502 | sseu->eu_per_subslice, |
| 4503 | eu_cnt); |
| 4504 | } |
| 4505 | } |
| 4506 | } |
| 4507 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4508 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4509 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4510 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4511 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4512 | int s, ss; |
| 4513 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4514 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4515 | /* BXT has a single slice and at most 3 subslices. */ |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4516 | if (IS_GEN9_LP(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4517 | s_max = 1; |
| 4518 | ss_max = 3; |
| 4519 | } |
| 4520 | |
| 4521 | for (s = 0; s < s_max; s++) { |
| 4522 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4523 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4524 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4525 | } |
| 4526 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4527 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4528 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4529 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4530 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4531 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4532 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4533 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4534 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4535 | |
| 4536 | for (s = 0; s < s_max; s++) { |
| 4537 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4538 | /* skip disabled slice */ |
| 4539 | continue; |
| 4540 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4541 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4542 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4543 | if (IS_GEN9_BC(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4544 | sseu->subslice_mask = |
| 4545 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4546 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4547 | for (ss = 0; ss < ss_max; ss++) { |
| 4548 | unsigned int eu_cnt; |
| 4549 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4550 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4551 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4552 | /* skip disabled subslice */ |
| 4553 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4554 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4555 | sseu->subslice_mask |= BIT(ss); |
| 4556 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4557 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4558 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4559 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4560 | sseu->eu_total += eu_cnt; |
| 4561 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4562 | sseu->eu_per_subslice, |
| 4563 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4564 | } |
| 4565 | } |
| 4566 | } |
| 4567 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4568 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4569 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4570 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4571 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4572 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4573 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4574 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4575 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4576 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4577 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4578 | sseu->eu_per_subslice = |
| 4579 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4580 | sseu->eu_total = sseu->eu_per_subslice * |
| 4581 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4582 | |
| 4583 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4584 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4585 | u8 subslice_7eu = |
| 4586 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4587 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4588 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4589 | } |
| 4590 | } |
| 4591 | } |
| 4592 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4593 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4594 | const struct sseu_dev_info *sseu) |
| 4595 | { |
| 4596 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4597 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 4598 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4599 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4600 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4601 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4602 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4603 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4604 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4605 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 4606 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4607 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4608 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4609 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4610 | sseu->eu_total); |
| 4611 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4612 | sseu->eu_per_subslice); |
| 4613 | |
| 4614 | if (!is_available_info) |
| 4615 | return; |
| 4616 | |
| 4617 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4618 | if (HAS_POOLED_EU(dev_priv)) |
| 4619 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4620 | |
| 4621 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4622 | yesno(sseu->has_slice_pg)); |
| 4623 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4624 | yesno(sseu->has_subslice_pg)); |
| 4625 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4626 | yesno(sseu->has_eu_pg)); |
| 4627 | } |
| 4628 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4629 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4630 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4631 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4632 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4633 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4634 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4635 | return -ENODEV; |
| 4636 | |
| 4637 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4638 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4639 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4640 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4641 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4642 | |
| 4643 | intel_runtime_pm_get(dev_priv); |
| 4644 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4645 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4646 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4647 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4648 | broadwell_sseu_device_status(dev_priv, &sseu); |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4649 | } else if (IS_GEN9(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4650 | gen9_sseu_device_status(dev_priv, &sseu); |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4651 | } else if (INTEL_GEN(dev_priv) >= 10) { |
| 4652 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4653 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4654 | |
| 4655 | intel_runtime_pm_put(dev_priv); |
| 4656 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4657 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4658 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4659 | return 0; |
| 4660 | } |
| 4661 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4662 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4663 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4664 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4665 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4666 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4667 | return 0; |
| 4668 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4669 | intel_runtime_pm_get(i915); |
| 4670 | intel_uncore_forcewake_user_get(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4671 | |
| 4672 | return 0; |
| 4673 | } |
| 4674 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4675 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4676 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4677 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4678 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4679 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4680 | return 0; |
| 4681 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4682 | intel_uncore_forcewake_user_put(i915); |
| 4683 | intel_runtime_pm_put(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4684 | |
| 4685 | return 0; |
| 4686 | } |
| 4687 | |
| 4688 | static const struct file_operations i915_forcewake_fops = { |
| 4689 | .owner = THIS_MODULE, |
| 4690 | .open = i915_forcewake_open, |
| 4691 | .release = i915_forcewake_release, |
| 4692 | }; |
| 4693 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4694 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4695 | { |
| 4696 | struct drm_i915_private *dev_priv = m->private; |
| 4697 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4698 | |
| 4699 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4700 | seq_printf(m, "Detected: %s\n", |
| 4701 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4702 | |
| 4703 | return 0; |
| 4704 | } |
| 4705 | |
| 4706 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4707 | const char __user *ubuf, size_t len, |
| 4708 | loff_t *offp) |
| 4709 | { |
| 4710 | struct seq_file *m = file->private_data; |
| 4711 | struct drm_i915_private *dev_priv = m->private; |
| 4712 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4713 | unsigned int new_threshold; |
| 4714 | int i; |
| 4715 | char *newline; |
| 4716 | char tmp[16]; |
| 4717 | |
| 4718 | if (len >= sizeof(tmp)) |
| 4719 | return -EINVAL; |
| 4720 | |
| 4721 | if (copy_from_user(tmp, ubuf, len)) |
| 4722 | return -EFAULT; |
| 4723 | |
| 4724 | tmp[len] = '\0'; |
| 4725 | |
| 4726 | /* Strip newline, if any */ |
| 4727 | newline = strchr(tmp, '\n'); |
| 4728 | if (newline) |
| 4729 | *newline = '\0'; |
| 4730 | |
| 4731 | if (strcmp(tmp, "reset") == 0) |
| 4732 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4733 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4734 | return -EINVAL; |
| 4735 | |
| 4736 | if (new_threshold > 0) |
| 4737 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4738 | new_threshold); |
| 4739 | else |
| 4740 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4741 | |
| 4742 | spin_lock_irq(&dev_priv->irq_lock); |
| 4743 | hotplug->hpd_storm_threshold = new_threshold; |
| 4744 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4745 | for_each_hpd_pin(i) |
| 4746 | hotplug->stats[i].count = 0; |
| 4747 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4748 | |
| 4749 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4750 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4751 | |
| 4752 | return len; |
| 4753 | } |
| 4754 | |
| 4755 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4756 | { |
| 4757 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4758 | } |
| 4759 | |
| 4760 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4761 | .owner = THIS_MODULE, |
| 4762 | .open = i915_hpd_storm_ctl_open, |
| 4763 | .read = seq_read, |
| 4764 | .llseek = seq_lseek, |
| 4765 | .release = single_release, |
| 4766 | .write = i915_hpd_storm_ctl_write |
| 4767 | }; |
| 4768 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4769 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4770 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4771 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4772 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4773 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4774 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4775 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4776 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4777 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4778 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4779 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4780 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4781 | {"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] | 4782 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4783 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4784 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4785 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4786 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4787 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4788 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4789 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4790 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4791 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4792 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4793 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4794 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4795 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4796 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4797 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 4798 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4799 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4800 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4801 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4802 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4803 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4804 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4805 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4806 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4807 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4808 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4809 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4810 | {"i915_engine_info", i915_engine_info, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4811 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4812 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4813 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4814 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4815 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4816 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4817 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4818 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4819 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4820 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4821 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4822 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4823 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4824 | const char *name; |
| 4825 | const struct file_operations *fops; |
| 4826 | } i915_debugfs_files[] = { |
| 4827 | {"i915_wedged", &i915_wedged_fops}, |
| 4828 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4829 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4830 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4831 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4832 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4833 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4834 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4835 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4836 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4837 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4838 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4839 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4840 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4841 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4842 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4843 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4844 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4845 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4846 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4847 | {"i915_guc_log_control", &i915_guc_log_control_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4848 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
| 4849 | {"i915_ipc_status", &i915_ipc_status_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4850 | }; |
| 4851 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4852 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4853 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4854 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4855 | struct dentry *ent; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4856 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4857 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4858 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4859 | minor->debugfs_root, to_i915(minor->dev), |
| 4860 | &i915_forcewake_fops); |
| 4861 | if (!ent) |
| 4862 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4863 | |
Tomeu Vizoso | 731035f | 2016-12-12 13:29:48 +0100 | [diff] [blame] | 4864 | ret = intel_pipe_crc_create(minor); |
| 4865 | if (ret) |
| 4866 | return ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4867 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4868 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4869 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4870 | S_IRUGO | S_IWUSR, |
| 4871 | minor->debugfs_root, |
| 4872 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4873 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4874 | if (!ent) |
| 4875 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4876 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4877 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4878 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4879 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4880 | minor->debugfs_root, minor); |
| 4881 | } |
| 4882 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4883 | struct dpcd_block { |
| 4884 | /* DPCD dump start address. */ |
| 4885 | unsigned int offset; |
| 4886 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4887 | unsigned int end; |
| 4888 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4889 | size_t size; |
| 4890 | /* Only valid for eDP. */ |
| 4891 | bool edp; |
| 4892 | }; |
| 4893 | |
| 4894 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4895 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4896 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4897 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4898 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4899 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4900 | { .offset = DP_SET_POWER }, |
| 4901 | { .offset = DP_EDP_DPCD_REV }, |
| 4902 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4903 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4904 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4905 | }; |
| 4906 | |
| 4907 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4908 | { |
| 4909 | struct drm_connector *connector = m->private; |
| 4910 | struct intel_dp *intel_dp = |
| 4911 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4912 | uint8_t buf[16]; |
| 4913 | ssize_t err; |
| 4914 | int i; |
| 4915 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4916 | if (connector->status != connector_status_connected) |
| 4917 | return -ENODEV; |
| 4918 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4919 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4920 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4921 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4922 | |
| 4923 | if (b->edp && |
| 4924 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4925 | continue; |
| 4926 | |
| 4927 | /* low tech for now */ |
| 4928 | if (WARN_ON(size > sizeof(buf))) |
| 4929 | continue; |
| 4930 | |
| 4931 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 4932 | if (err <= 0) { |
| 4933 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 4934 | size, b->offset, err); |
| 4935 | continue; |
| 4936 | } |
| 4937 | |
| 4938 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4939 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4940 | |
| 4941 | return 0; |
| 4942 | } |
| 4943 | |
| 4944 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 4945 | { |
| 4946 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 4947 | } |
| 4948 | |
| 4949 | static const struct file_operations i915_dpcd_fops = { |
| 4950 | .owner = THIS_MODULE, |
| 4951 | .open = i915_dpcd_open, |
| 4952 | .read = seq_read, |
| 4953 | .llseek = seq_lseek, |
| 4954 | .release = single_release, |
| 4955 | }; |
| 4956 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4957 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4958 | { |
| 4959 | struct drm_connector *connector = m->private; |
| 4960 | struct intel_dp *intel_dp = |
| 4961 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4962 | |
| 4963 | if (connector->status != connector_status_connected) |
| 4964 | return -ENODEV; |
| 4965 | |
| 4966 | seq_printf(m, "Panel power up delay: %d\n", |
| 4967 | intel_dp->panel_power_up_delay); |
| 4968 | seq_printf(m, "Panel power down delay: %d\n", |
| 4969 | intel_dp->panel_power_down_delay); |
| 4970 | seq_printf(m, "Backlight on delay: %d\n", |
| 4971 | intel_dp->backlight_on_delay); |
| 4972 | seq_printf(m, "Backlight off delay: %d\n", |
| 4973 | intel_dp->backlight_off_delay); |
| 4974 | |
| 4975 | return 0; |
| 4976 | } |
| 4977 | |
| 4978 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 4979 | { |
| 4980 | return single_open(file, i915_panel_show, inode->i_private); |
| 4981 | } |
| 4982 | |
| 4983 | static const struct file_operations i915_panel_fops = { |
| 4984 | .owner = THIS_MODULE, |
| 4985 | .open = i915_panel_open, |
| 4986 | .read = seq_read, |
| 4987 | .llseek = seq_lseek, |
| 4988 | .release = single_release, |
| 4989 | }; |
| 4990 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4991 | /** |
| 4992 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4993 | * @connector: pointer to a registered drm_connector |
| 4994 | * |
| 4995 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4996 | * drm_debugfs_connector_remove(). |
| 4997 | * |
| 4998 | * Returns 0 on success, negative error codes on error. |
| 4999 | */ |
| 5000 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5001 | { |
| 5002 | struct dentry *root = connector->debugfs_entry; |
| 5003 | |
| 5004 | /* The connector must have been registered beforehands. */ |
| 5005 | if (!root) |
| 5006 | return -ENODEV; |
| 5007 | |
| 5008 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5009 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5010 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5011 | connector, &i915_dpcd_fops); |
| 5012 | |
| 5013 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5014 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5015 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5016 | |
| 5017 | return 0; |
| 5018 | } |