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" |
Sagar Arun Kamble | a269574 | 2017-11-16 19:02:41 +0530 | [diff] [blame] | 33 | #include "intel_guc_submission.h" |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 34 | |
Chris Wilson | 9f58892 | 2019-01-16 15:33:04 +0000 | [diff] [blame] | 35 | #include "i915_reset.h" |
| 36 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 37 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 38 | { |
| 39 | return to_i915(node->minor->dev); |
| 40 | } |
| 41 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 42 | static int i915_capabilities(struct seq_file *m, void *data) |
| 43 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 44 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 45 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 46 | struct drm_printer p = drm_seq_file_printer(m); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 47 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 48 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 49 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 50 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 51 | |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 52 | intel_device_info_dump_flags(info, &p); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 53 | intel_device_info_dump_runtime(RUNTIME_INFO(dev_priv), &p); |
Chris Wilson | 3fed180 | 2018-02-07 21:05:43 +0000 | [diff] [blame] | 54 | intel_driver_caps_print(&dev_priv->caps, &p); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 55 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 56 | kernel_param_lock(THIS_MODULE); |
Michal Wajdeczko | acfb997 | 2017-12-19 11:43:46 +0000 | [diff] [blame] | 57 | i915_params_dump(&i915_modparams, &p); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 58 | kernel_param_unlock(THIS_MODULE); |
| 59 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 60 | return 0; |
| 61 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 62 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 63 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 64 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 65 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 68 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 69 | { |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 70 | return obj->pin_global ? 'p' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 73 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 74 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 75 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 76 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 77 | case I915_TILING_NONE: return ' '; |
| 78 | case I915_TILING_X: return 'X'; |
| 79 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 80 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 83 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 84 | { |
Chris Wilson | a65adaf | 2017-10-09 09:43:57 +0100 | [diff] [blame] | 85 | return obj->userfault_count ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 88 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 89 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 90 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 93 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 94 | { |
| 95 | u64 size = 0; |
| 96 | struct i915_vma *vma; |
| 97 | |
Chris Wilson | e2189dd | 2017-12-07 21:14:07 +0000 | [diff] [blame] | 98 | for_each_ggtt_vma(vma, obj) { |
| 99 | if (drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 100 | size += vma->node.size; |
| 101 | } |
| 102 | |
| 103 | return size; |
| 104 | } |
| 105 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 106 | static const char * |
| 107 | stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len) |
| 108 | { |
| 109 | size_t x = 0; |
| 110 | |
| 111 | switch (page_sizes) { |
| 112 | case 0: |
| 113 | return ""; |
| 114 | case I915_GTT_PAGE_SIZE_4K: |
| 115 | return "4K"; |
| 116 | case I915_GTT_PAGE_SIZE_64K: |
| 117 | return "64K"; |
| 118 | case I915_GTT_PAGE_SIZE_2M: |
| 119 | return "2M"; |
| 120 | default: |
| 121 | if (!buf) |
| 122 | return "M"; |
| 123 | |
| 124 | if (page_sizes & I915_GTT_PAGE_SIZE_2M) |
| 125 | x += snprintf(buf + x, len - x, "2M, "); |
| 126 | if (page_sizes & I915_GTT_PAGE_SIZE_64K) |
| 127 | x += snprintf(buf + x, len - x, "64K, "); |
| 128 | if (page_sizes & I915_GTT_PAGE_SIZE_4K) |
| 129 | x += snprintf(buf + x, len - x, "4K, "); |
| 130 | buf[x-2] = '\0'; |
| 131 | |
| 132 | return buf; |
| 133 | } |
| 134 | } |
| 135 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 136 | static void |
| 137 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 138 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 139 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 140 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 141 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 142 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 143 | int pin_count = 0; |
| 144 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 145 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 146 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 147 | 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] | 148 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 149 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 150 | get_pin_flag(obj), |
| 151 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 152 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 153 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 154 | obj->base.size / 1024, |
Christian König | c0a51fd | 2018-02-16 13:43:38 +0100 | [diff] [blame] | 155 | obj->read_domains, |
| 156 | obj->write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 157 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 158 | obj->mm.dirty ? " dirty" : "", |
| 159 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 160 | if (obj->base.name) |
| 161 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 162 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 163 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 164 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 165 | } |
| 166 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 167 | if (obj->pin_global) |
| 168 | seq_printf(m, " (global)"); |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 169 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 170 | if (!drm_mm_node_allocated(&vma->node)) |
| 171 | continue; |
| 172 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 173 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx, pages: %s", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 174 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 175 | vma->node.start, vma->node.size, |
| 176 | stringify_page_sizes(vma->page_sizes.gtt, NULL, 0)); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 177 | if (i915_vma_is_ggtt(vma)) { |
| 178 | switch (vma->ggtt_view.type) { |
| 179 | case I915_GGTT_VIEW_NORMAL: |
| 180 | seq_puts(m, ", normal"); |
| 181 | break; |
| 182 | |
| 183 | case I915_GGTT_VIEW_PARTIAL: |
| 184 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 185 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 186 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 187 | break; |
| 188 | |
| 189 | case I915_GGTT_VIEW_ROTATED: |
| 190 | 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] | 191 | vma->ggtt_view.rotated.plane[0].width, |
| 192 | vma->ggtt_view.rotated.plane[0].height, |
| 193 | vma->ggtt_view.rotated.plane[0].stride, |
| 194 | vma->ggtt_view.rotated.plane[0].offset, |
| 195 | vma->ggtt_view.rotated.plane[1].width, |
| 196 | vma->ggtt_view.rotated.plane[1].height, |
| 197 | vma->ggtt_view.rotated.plane[1].stride, |
| 198 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 199 | break; |
| 200 | |
| 201 | default: |
| 202 | MISSING_CASE(vma->ggtt_view.type); |
| 203 | break; |
| 204 | } |
| 205 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 206 | if (vma->fence) |
| 207 | seq_printf(m, " , fence: %d%s", |
| 208 | vma->fence->id, |
Chris Wilson | 21950ee | 2019-02-05 13:00:05 +0000 | [diff] [blame^] | 209 | i915_active_request_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 210 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 211 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 212 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 213 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 214 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 215 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 216 | if (engine) |
| 217 | seq_printf(m, " (%s)", engine->name); |
| 218 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 219 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 220 | if (frontbuffer_bits) |
| 221 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 224 | static int obj_rank_by_stolen(const void *A, const void *B) |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 225 | { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 226 | const struct drm_i915_gem_object *a = |
| 227 | *(const struct drm_i915_gem_object **)A; |
| 228 | const struct drm_i915_gem_object *b = |
| 229 | *(const struct drm_i915_gem_object **)B; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 230 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 231 | if (a->stolen->start < b->stolen->start) |
| 232 | return -1; |
| 233 | if (a->stolen->start > b->stolen->start) |
| 234 | return 1; |
| 235 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 239 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 240 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 241 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 242 | struct drm_i915_gem_object **objects; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 243 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 244 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 245 | unsigned long total, count, n; |
| 246 | int ret; |
| 247 | |
| 248 | total = READ_ONCE(dev_priv->mm.object_count); |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 249 | objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 250 | if (!objects) |
| 251 | return -ENOMEM; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 252 | |
| 253 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 254 | if (ret) |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 255 | goto out; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 256 | |
| 257 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 258 | |
| 259 | spin_lock(&dev_priv->mm.obj_lock); |
| 260 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 261 | if (count == total) |
| 262 | break; |
| 263 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 264 | if (obj->stolen == NULL) |
| 265 | continue; |
| 266 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 267 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 268 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 269 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 270 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 271 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 272 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 273 | if (count == total) |
| 274 | break; |
| 275 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 276 | if (obj->stolen == NULL) |
| 277 | continue; |
| 278 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 279 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | total_obj_size += obj->base.size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 281 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 282 | spin_unlock(&dev_priv->mm.obj_lock); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 283 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 284 | sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL); |
| 285 | |
| 286 | seq_puts(m, "Stolen:\n"); |
| 287 | for (n = 0; n < count; n++) { |
| 288 | seq_puts(m, " "); |
| 289 | describe_obj(m, objects[n]); |
| 290 | seq_putc(m, '\n'); |
| 291 | } |
| 292 | seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 293 | count, total_obj_size, total_gtt_size); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 294 | |
| 295 | mutex_unlock(&dev->struct_mutex); |
| 296 | out: |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 297 | kvfree(objects); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 298 | return ret; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 299 | } |
| 300 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 301 | struct file_stats { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 302 | struct i915_address_space *vm; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 303 | unsigned long count; |
| 304 | u64 total, unbound; |
| 305 | u64 global, shared; |
| 306 | u64 active, inactive; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 307 | u64 closed; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | static int per_file_stats(int id, void *ptr, void *data) |
| 311 | { |
| 312 | struct drm_i915_gem_object *obj = ptr; |
| 313 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 314 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 315 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 316 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 317 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 318 | stats->count++; |
| 319 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 320 | if (!obj->bind_count) |
| 321 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 322 | if (obj->base.name || obj->base.dma_buf) |
| 323 | stats->shared += obj->base.size; |
| 324 | |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 325 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 326 | if (!drm_mm_node_allocated(&vma->node)) |
| 327 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 328 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 329 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 330 | stats->global += vma->node.size; |
| 331 | } else { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 332 | if (vma->vm != stats->vm) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 333 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 334 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 335 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 336 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 337 | stats->active += vma->node.size; |
| 338 | else |
| 339 | stats->inactive += vma->node.size; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 340 | |
| 341 | if (i915_vma_is_closed(vma)) |
| 342 | stats->closed += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | return 0; |
| 346 | } |
| 347 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 348 | #define print_file_stats(m, name, stats) do { \ |
| 349 | if (stats.count) \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 350 | seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound, %llu closed)\n", \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 351 | name, \ |
| 352 | stats.count, \ |
| 353 | stats.total, \ |
| 354 | stats.active, \ |
| 355 | stats.inactive, \ |
| 356 | stats.global, \ |
| 357 | stats.shared, \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 358 | stats.unbound, \ |
| 359 | stats.closed); \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 360 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 361 | |
| 362 | static void print_batch_pool_stats(struct seq_file *m, |
| 363 | struct drm_i915_private *dev_priv) |
| 364 | { |
| 365 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 366 | struct intel_engine_cs *engine; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 367 | struct file_stats stats = {}; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 368 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 369 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 370 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 371 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 372 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 373 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 374 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 375 | batch_pool_link) |
| 376 | per_file_stats(0, obj, &stats); |
| 377 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 378 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 379 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 380 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 381 | } |
| 382 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 383 | static void print_context_stats(struct seq_file *m, |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 384 | struct drm_i915_private *i915) |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 385 | { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 386 | struct file_stats kstats = {}; |
| 387 | struct i915_gem_context *ctx; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 388 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 389 | list_for_each_entry(ctx, &i915->contexts.list, link) { |
| 390 | struct intel_engine_cs *engine; |
| 391 | enum intel_engine_id id; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 392 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 393 | for_each_engine(engine, i915, id) { |
| 394 | struct intel_context *ce = to_intel_context(ctx, engine); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 395 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 396 | if (ce->state) |
| 397 | per_file_stats(0, ce->state->obj, &kstats); |
| 398 | if (ce->ring) |
| 399 | per_file_stats(0, ce->ring->vma->obj, &kstats); |
| 400 | } |
| 401 | |
| 402 | if (!IS_ERR_OR_NULL(ctx->file_priv)) { |
| 403 | struct file_stats stats = { .vm = &ctx->ppgtt->vm, }; |
| 404 | struct drm_file *file = ctx->file_priv->file; |
| 405 | struct task_struct *task; |
| 406 | char name[80]; |
| 407 | |
| 408 | spin_lock(&file->table_lock); |
| 409 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
| 410 | spin_unlock(&file->table_lock); |
| 411 | |
| 412 | rcu_read_lock(); |
| 413 | task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID); |
| 414 | snprintf(name, sizeof(name), "%s/%d", |
| 415 | task ? task->comm : "<unknown>", |
| 416 | ctx->user_handle); |
| 417 | rcu_read_unlock(); |
| 418 | |
| 419 | print_file_stats(m, name, stats); |
| 420 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 421 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 422 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 423 | print_file_stats(m, "[k]contexts", kstats); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 424 | } |
| 425 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 426 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 427 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 428 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 429 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 430 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 431 | u32 count, mapped_count, purgeable_count, dpy_count, huge_count; |
| 432 | u64 size, mapped_size, purgeable_size, dpy_size, huge_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 433 | struct drm_i915_gem_object *obj; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 434 | unsigned int page_sizes = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 435 | char buf[80]; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 436 | int ret; |
| 437 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 438 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 439 | dev_priv->mm.object_count, |
| 440 | dev_priv->mm.object_memory); |
| 441 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 442 | size = count = 0; |
| 443 | mapped_size = mapped_count = 0; |
| 444 | purgeable_size = purgeable_count = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 445 | huge_size = huge_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 446 | |
| 447 | spin_lock(&dev_priv->mm.obj_lock); |
| 448 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 449 | size += obj->base.size; |
| 450 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 451 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 452 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 453 | purgeable_size += obj->base.size; |
| 454 | ++purgeable_count; |
| 455 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 456 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 457 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 458 | mapped_count++; |
| 459 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 460 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 461 | |
| 462 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 463 | huge_count++; |
| 464 | huge_size += obj->base.size; |
| 465 | page_sizes |= obj->mm.page_sizes.sg; |
| 466 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 467 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 468 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 469 | |
| 470 | size = count = dpy_size = dpy_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 471 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 472 | size += obj->base.size; |
| 473 | ++count; |
| 474 | |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 475 | if (obj->pin_global) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 476 | dpy_size += obj->base.size; |
| 477 | ++dpy_count; |
| 478 | } |
| 479 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 480 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 481 | purgeable_size += obj->base.size; |
| 482 | ++purgeable_count; |
| 483 | } |
| 484 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 485 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 486 | mapped_count++; |
| 487 | mapped_size += obj->base.size; |
| 488 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 489 | |
| 490 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 491 | huge_count++; |
| 492 | huge_size += obj->base.size; |
| 493 | page_sizes |= obj->mm.page_sizes.sg; |
| 494 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 495 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 496 | spin_unlock(&dev_priv->mm.obj_lock); |
| 497 | |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 498 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 499 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 500 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 501 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 502 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 503 | mapped_count, mapped_size); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 504 | seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n", |
| 505 | huge_count, |
| 506 | stringify_page_sizes(page_sizes, buf, sizeof(buf)), |
| 507 | huge_size); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 508 | seq_printf(m, "%u display objects (globally pinned), %llu bytes\n", |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 509 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 510 | |
Matthew Auld | b7128ef | 2017-12-11 15:18:22 +0000 | [diff] [blame] | 511 | seq_printf(m, "%llu [%pa] gtt total\n", |
Chris Wilson | 82ad644 | 2018-06-05 16:37:58 +0100 | [diff] [blame] | 512 | ggtt->vm.total, &ggtt->mappable_end); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 513 | seq_printf(m, "Supported page sizes: %s\n", |
| 514 | stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes, |
| 515 | buf, sizeof(buf))); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 516 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 517 | seq_putc(m, '\n'); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 518 | |
| 519 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 520 | if (ret) |
| 521 | return ret; |
| 522 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 523 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 524 | print_context_stats(m, dev_priv); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 525 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 526 | |
| 527 | return 0; |
| 528 | } |
| 529 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 530 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 531 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 532 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 533 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 534 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 535 | struct drm_i915_gem_object **objects; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 536 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 537 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 538 | unsigned long nobject, n; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 539 | int count, ret; |
| 540 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 541 | nobject = READ_ONCE(dev_priv->mm.object_count); |
| 542 | objects = kvmalloc_array(nobject, sizeof(*objects), GFP_KERNEL); |
| 543 | if (!objects) |
| 544 | return -ENOMEM; |
| 545 | |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 546 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 547 | if (ret) |
| 548 | return ret; |
| 549 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 550 | count = 0; |
| 551 | spin_lock(&dev_priv->mm.obj_lock); |
| 552 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
| 553 | objects[count++] = obj; |
| 554 | if (count == nobject) |
| 555 | break; |
| 556 | } |
| 557 | spin_unlock(&dev_priv->mm.obj_lock); |
| 558 | |
| 559 | total_obj_size = total_gtt_size = 0; |
| 560 | for (n = 0; n < count; n++) { |
| 561 | obj = objects[n]; |
| 562 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 563 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 564 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 565 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 566 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 567 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | mutex_unlock(&dev->struct_mutex); |
| 571 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 572 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 573 | count, total_obj_size, total_gtt_size); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 574 | kvfree(objects); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 575 | |
| 576 | return 0; |
| 577 | } |
| 578 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 579 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 580 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 581 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 582 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 583 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 584 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 585 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 586 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 587 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 588 | |
| 589 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 590 | if (ret) |
| 591 | return ret; |
| 592 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 593 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 594 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 595 | int count; |
| 596 | |
| 597 | count = 0; |
| 598 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 599 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 600 | batch_pool_link) |
| 601 | count++; |
| 602 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 603 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 604 | |
| 605 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 606 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 607 | batch_pool_link) { |
| 608 | seq_puts(m, " "); |
| 609 | describe_obj(m, obj); |
| 610 | seq_putc(m, '\n'); |
| 611 | } |
| 612 | |
| 613 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 614 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 615 | } |
| 616 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 617 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 618 | |
| 619 | mutex_unlock(&dev->struct_mutex); |
| 620 | |
| 621 | return 0; |
| 622 | } |
| 623 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 624 | static void gen8_display_interrupt_info(struct seq_file *m) |
| 625 | { |
| 626 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 627 | int pipe; |
| 628 | |
| 629 | for_each_pipe(dev_priv, pipe) { |
| 630 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 631 | intel_wakeref_t wakeref; |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 632 | |
| 633 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 634 | wakeref = intel_display_power_get_if_enabled(dev_priv, |
| 635 | power_domain); |
| 636 | if (!wakeref) { |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 637 | seq_printf(m, "Pipe %c power disabled\n", |
| 638 | pipe_name(pipe)); |
| 639 | continue; |
| 640 | } |
| 641 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
| 642 | pipe_name(pipe), |
| 643 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
| 644 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
| 645 | pipe_name(pipe), |
| 646 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
| 647 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
| 648 | pipe_name(pipe), |
| 649 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
| 650 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 651 | intel_display_power_put(dev_priv, power_domain, wakeref); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 655 | I915_READ(GEN8_DE_PORT_IMR)); |
| 656 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 657 | I915_READ(GEN8_DE_PORT_IIR)); |
| 658 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 659 | I915_READ(GEN8_DE_PORT_IER)); |
| 660 | |
| 661 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 662 | I915_READ(GEN8_DE_MISC_IMR)); |
| 663 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 664 | I915_READ(GEN8_DE_MISC_IIR)); |
| 665 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 666 | I915_READ(GEN8_DE_MISC_IER)); |
| 667 | |
| 668 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 669 | I915_READ(GEN8_PCU_IMR)); |
| 670 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 671 | I915_READ(GEN8_PCU_IIR)); |
| 672 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 673 | I915_READ(GEN8_PCU_IER)); |
| 674 | } |
| 675 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 676 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 677 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 678 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 679 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 680 | enum intel_engine_id id; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 681 | intel_wakeref_t wakeref; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 682 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 683 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 684 | wakeref = intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 685 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 686 | if (IS_CHERRYVIEW(dev_priv)) { |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 687 | intel_wakeref_t pref; |
| 688 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 689 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 690 | I915_READ(GEN8_MASTER_IRQ)); |
| 691 | |
| 692 | seq_printf(m, "Display IER:\t%08x\n", |
| 693 | I915_READ(VLV_IER)); |
| 694 | seq_printf(m, "Display IIR:\t%08x\n", |
| 695 | I915_READ(VLV_IIR)); |
| 696 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 697 | I915_READ(VLV_IIR_RW)); |
| 698 | seq_printf(m, "Display IMR:\t%08x\n", |
| 699 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 700 | for_each_pipe(dev_priv, pipe) { |
| 701 | enum intel_display_power_domain power_domain; |
| 702 | |
| 703 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 704 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 705 | power_domain); |
| 706 | if (!pref) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 707 | seq_printf(m, "Pipe %c power disabled\n", |
| 708 | pipe_name(pipe)); |
| 709 | continue; |
| 710 | } |
| 711 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 712 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 713 | pipe_name(pipe), |
| 714 | I915_READ(PIPESTAT(pipe))); |
| 715 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 716 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 717 | } |
| 718 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 719 | pref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 720 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 721 | I915_READ(PORT_HOTPLUG_EN)); |
| 722 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 723 | I915_READ(VLV_DPFLIPSTAT)); |
| 724 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 725 | I915_READ(DPINVGTT)); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 726 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, pref); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 727 | |
| 728 | for (i = 0; i < 4; i++) { |
| 729 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 730 | i, I915_READ(GEN8_GT_IMR(i))); |
| 731 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 732 | i, I915_READ(GEN8_GT_IIR(i))); |
| 733 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 734 | i, I915_READ(GEN8_GT_IER(i))); |
| 735 | } |
| 736 | |
| 737 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 738 | I915_READ(GEN8_PCU_IMR)); |
| 739 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 740 | I915_READ(GEN8_PCU_IIR)); |
| 741 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 742 | I915_READ(GEN8_PCU_IER)); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 743 | } else if (INTEL_GEN(dev_priv) >= 11) { |
| 744 | seq_printf(m, "Master Interrupt Control: %08x\n", |
| 745 | I915_READ(GEN11_GFX_MSTR_IRQ)); |
| 746 | |
| 747 | seq_printf(m, "Render/Copy Intr Enable: %08x\n", |
| 748 | I915_READ(GEN11_RENDER_COPY_INTR_ENABLE)); |
| 749 | seq_printf(m, "VCS/VECS Intr Enable: %08x\n", |
| 750 | I915_READ(GEN11_VCS_VECS_INTR_ENABLE)); |
| 751 | seq_printf(m, "GUC/SG Intr Enable:\t %08x\n", |
| 752 | I915_READ(GEN11_GUC_SG_INTR_ENABLE)); |
| 753 | seq_printf(m, "GPM/WGBOXPERF Intr Enable: %08x\n", |
| 754 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE)); |
| 755 | seq_printf(m, "Crypto Intr Enable:\t %08x\n", |
| 756 | I915_READ(GEN11_CRYPTO_RSVD_INTR_ENABLE)); |
| 757 | seq_printf(m, "GUnit/CSME Intr Enable:\t %08x\n", |
| 758 | I915_READ(GEN11_GUNIT_CSME_INTR_ENABLE)); |
| 759 | |
| 760 | seq_printf(m, "Display Interrupt Control:\t%08x\n", |
| 761 | I915_READ(GEN11_DISPLAY_INT_CTL)); |
| 762 | |
| 763 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 764 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 765 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 766 | I915_READ(GEN8_MASTER_IRQ)); |
| 767 | |
| 768 | for (i = 0; i < 4; i++) { |
| 769 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 770 | i, I915_READ(GEN8_GT_IMR(i))); |
| 771 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 772 | i, I915_READ(GEN8_GT_IIR(i))); |
| 773 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 774 | i, I915_READ(GEN8_GT_IER(i))); |
| 775 | } |
| 776 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 777 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 778 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 779 | seq_printf(m, "Display IER:\t%08x\n", |
| 780 | I915_READ(VLV_IER)); |
| 781 | seq_printf(m, "Display IIR:\t%08x\n", |
| 782 | I915_READ(VLV_IIR)); |
| 783 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 784 | I915_READ(VLV_IIR_RW)); |
| 785 | seq_printf(m, "Display IMR:\t%08x\n", |
| 786 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 787 | for_each_pipe(dev_priv, pipe) { |
| 788 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 789 | intel_wakeref_t pref; |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 790 | |
| 791 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 792 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 793 | power_domain); |
| 794 | if (!pref) { |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 795 | seq_printf(m, "Pipe %c power disabled\n", |
| 796 | pipe_name(pipe)); |
| 797 | continue; |
| 798 | } |
| 799 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 800 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 801 | pipe_name(pipe), |
| 802 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 803 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 804 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 805 | |
| 806 | seq_printf(m, "Master IER:\t%08x\n", |
| 807 | I915_READ(VLV_MASTER_IER)); |
| 808 | |
| 809 | seq_printf(m, "Render IER:\t%08x\n", |
| 810 | I915_READ(GTIER)); |
| 811 | seq_printf(m, "Render IIR:\t%08x\n", |
| 812 | I915_READ(GTIIR)); |
| 813 | seq_printf(m, "Render IMR:\t%08x\n", |
| 814 | I915_READ(GTIMR)); |
| 815 | |
| 816 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 817 | I915_READ(GEN6_PMIER)); |
| 818 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 819 | I915_READ(GEN6_PMIIR)); |
| 820 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 821 | I915_READ(GEN6_PMIMR)); |
| 822 | |
| 823 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 824 | I915_READ(PORT_HOTPLUG_EN)); |
| 825 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 826 | I915_READ(VLV_DPFLIPSTAT)); |
| 827 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 828 | I915_READ(DPINVGTT)); |
| 829 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 830 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 831 | seq_printf(m, "Interrupt enable: %08x\n", |
| 832 | I915_READ(IER)); |
| 833 | seq_printf(m, "Interrupt identity: %08x\n", |
| 834 | I915_READ(IIR)); |
| 835 | seq_printf(m, "Interrupt mask: %08x\n", |
| 836 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 837 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 838 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 839 | pipe_name(pipe), |
| 840 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 841 | } else { |
| 842 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 843 | I915_READ(DEIER)); |
| 844 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 845 | I915_READ(DEIIR)); |
| 846 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 847 | I915_READ(DEIMR)); |
| 848 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 849 | I915_READ(SDEIER)); |
| 850 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 851 | I915_READ(SDEIIR)); |
| 852 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 853 | I915_READ(SDEIMR)); |
| 854 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 855 | I915_READ(GTIER)); |
| 856 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 857 | I915_READ(GTIIR)); |
| 858 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 859 | I915_READ(GTIMR)); |
| 860 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 861 | |
| 862 | if (INTEL_GEN(dev_priv) >= 11) { |
| 863 | seq_printf(m, "RCS Intr Mask:\t %08x\n", |
| 864 | I915_READ(GEN11_RCS0_RSVD_INTR_MASK)); |
| 865 | seq_printf(m, "BCS Intr Mask:\t %08x\n", |
| 866 | I915_READ(GEN11_BCS_RSVD_INTR_MASK)); |
| 867 | seq_printf(m, "VCS0/VCS1 Intr Mask:\t %08x\n", |
| 868 | I915_READ(GEN11_VCS0_VCS1_INTR_MASK)); |
| 869 | seq_printf(m, "VCS2/VCS3 Intr Mask:\t %08x\n", |
| 870 | I915_READ(GEN11_VCS2_VCS3_INTR_MASK)); |
| 871 | seq_printf(m, "VECS0/VECS1 Intr Mask:\t %08x\n", |
| 872 | I915_READ(GEN11_VECS0_VECS1_INTR_MASK)); |
| 873 | seq_printf(m, "GUC/SG Intr Mask:\t %08x\n", |
| 874 | I915_READ(GEN11_GUC_SG_INTR_MASK)); |
| 875 | seq_printf(m, "GPM/WGBOXPERF Intr Mask: %08x\n", |
| 876 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK)); |
| 877 | seq_printf(m, "Crypto Intr Mask:\t %08x\n", |
| 878 | I915_READ(GEN11_CRYPTO_RSVD_INTR_MASK)); |
| 879 | seq_printf(m, "Gunit/CSME Intr Mask:\t %08x\n", |
| 880 | I915_READ(GEN11_GUNIT_CSME_INTR_MASK)); |
| 881 | |
| 882 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | d5acadf | 2017-12-09 10:44:18 +0000 | [diff] [blame] | 883 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 884 | seq_printf(m, |
| 885 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 886 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 887 | } |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 888 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 889 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 890 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 891 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 892 | return 0; |
| 893 | } |
| 894 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 895 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 896 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 897 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 898 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 899 | int i, ret; |
| 900 | |
| 901 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 902 | if (ret) |
| 903 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 904 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 905 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 906 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 907 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 908 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 909 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 910 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 911 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 912 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 913 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 914 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 915 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 916 | } |
| 917 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 918 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 919 | return 0; |
| 920 | } |
| 921 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 922 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 923 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 924 | size_t count, loff_t *pos) |
| 925 | { |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 926 | struct i915_gpu_state *error; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 927 | ssize_t ret; |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 928 | void *buf; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 929 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 930 | error = file->private_data; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 931 | if (!error) |
| 932 | return 0; |
| 933 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 934 | /* Bounce buffer required because of kernfs __user API convenience. */ |
| 935 | buf = kmalloc(count, GFP_KERNEL); |
| 936 | if (!buf) |
| 937 | return -ENOMEM; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 938 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 939 | ret = i915_gpu_state_copy_to_buffer(error, buf, *pos, count); |
| 940 | if (ret <= 0) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 941 | goto out; |
| 942 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 943 | if (!copy_to_user(ubuf, buf, ret)) |
| 944 | *pos += ret; |
| 945 | else |
| 946 | ret = -EFAULT; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 947 | |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 948 | out: |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 949 | kfree(buf); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 950 | return ret; |
| 951 | } |
| 952 | |
| 953 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 954 | { |
| 955 | i915_gpu_state_put(file->private_data); |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 960 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 961 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 962 | struct i915_gpu_state *gpu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 963 | intel_wakeref_t wakeref; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 964 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 965 | gpu = NULL; |
| 966 | with_intel_runtime_pm(i915, wakeref) |
| 967 | gpu = i915_capture_gpu_state(i915); |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 968 | if (IS_ERR(gpu)) |
| 969 | return PTR_ERR(gpu); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 970 | |
| 971 | file->private_data = gpu; |
| 972 | return 0; |
| 973 | } |
| 974 | |
| 975 | static const struct file_operations i915_gpu_info_fops = { |
| 976 | .owner = THIS_MODULE, |
| 977 | .open = i915_gpu_info_open, |
| 978 | .read = gpu_state_read, |
| 979 | .llseek = default_llseek, |
| 980 | .release = gpu_state_release, |
| 981 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 982 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 983 | static ssize_t |
| 984 | i915_error_state_write(struct file *filp, |
| 985 | const char __user *ubuf, |
| 986 | size_t cnt, |
| 987 | loff_t *ppos) |
| 988 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 989 | struct i915_gpu_state *error = filp->private_data; |
| 990 | |
| 991 | if (!error) |
| 992 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 993 | |
| 994 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 995 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 996 | |
| 997 | return cnt; |
| 998 | } |
| 999 | |
| 1000 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1001 | { |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 1002 | struct i915_gpu_state *error; |
| 1003 | |
| 1004 | error = i915_first_error_state(inode->i_private); |
| 1005 | if (IS_ERR(error)) |
| 1006 | return PTR_ERR(error); |
| 1007 | |
| 1008 | file->private_data = error; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1009 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1010 | } |
| 1011 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1012 | static const struct file_operations i915_error_state_fops = { |
| 1013 | .owner = THIS_MODULE, |
| 1014 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1015 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1016 | .write = i915_error_state_write, |
| 1017 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1018 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1019 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1020 | #endif |
| 1021 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1022 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1023 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1024 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1025 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1026 | intel_wakeref_t wakeref; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1027 | int ret = 0; |
| 1028 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1029 | wakeref = intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1030 | |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 1031 | if (IS_GEN(dev_priv, 5)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1032 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1033 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1034 | |
| 1035 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1036 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1037 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1038 | MEMSTAT_VID_SHIFT); |
| 1039 | seq_printf(m, "Current P-state: %d\n", |
| 1040 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1041 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1042 | u32 rpmodectl, freq_sts; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1043 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1044 | mutex_lock(&dev_priv->pcu_lock); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1045 | |
| 1046 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1047 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1048 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1049 | seq_printf(m, "HW control enabled: %s\n", |
| 1050 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1051 | seq_printf(m, "SW control enabled: %s\n", |
| 1052 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1053 | GEN6_RP_MEDIA_SW_MODE)); |
| 1054 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1055 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1056 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1057 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1058 | |
| 1059 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1060 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1061 | |
| 1062 | seq_printf(m, "current GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1063 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1064 | |
| 1065 | seq_printf(m, "max GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1066 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1067 | |
| 1068 | seq_printf(m, "min GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1069 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1070 | |
| 1071 | seq_printf(m, "idle GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1072 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1073 | |
| 1074 | seq_printf(m, |
| 1075 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1076 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1077 | mutex_unlock(&dev_priv->pcu_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1078 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1079 | u32 rp_state_limits; |
| 1080 | u32 gt_perf_status; |
| 1081 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1082 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1083 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1084 | u32 rpupei, rpcurup, rpprevup; |
| 1085 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1086 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1087 | int max_freq; |
| 1088 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1089 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1090 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1091 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1092 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1093 | } else { |
| 1094 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1095 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1096 | } |
| 1097 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1098 | /* RPSTAT1 is in the GT power well */ |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1099 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1100 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1101 | reqf = I915_READ(GEN6_RPNSWREQ); |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1102 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1103 | reqf >>= 23; |
| 1104 | else { |
| 1105 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1106 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1107 | reqf >>= 24; |
| 1108 | else |
| 1109 | reqf >>= 25; |
| 1110 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1111 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1112 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1113 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1114 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1115 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1116 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1117 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1118 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1119 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1120 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1121 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1122 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1123 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Tvrtko Ursulin | c84b270 | 2017-11-21 18:18:44 +0000 | [diff] [blame] | 1124 | cagf = intel_gpu_freq(dev_priv, |
| 1125 | intel_get_cagf(dev_priv, rpstat)); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1126 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1127 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1128 | |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1129 | if (INTEL_GEN(dev_priv) >= 11) { |
| 1130 | pm_ier = I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE); |
| 1131 | pm_imr = I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK); |
| 1132 | /* |
| 1133 | * The equivalent to the PM ISR & IIR cannot be read |
| 1134 | * without affecting the current state of the system |
| 1135 | */ |
| 1136 | pm_isr = 0; |
| 1137 | pm_iir = 0; |
| 1138 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1139 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1140 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1141 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1142 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1143 | } else { |
| 1144 | pm_ier = I915_READ(GEN6_PMIER); |
| 1145 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1146 | pm_isr = I915_READ(GEN6_PMISR); |
| 1147 | pm_iir = I915_READ(GEN6_PMIIR); |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1148 | } |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1149 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1150 | |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1151 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1152 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1153 | seq_printf(m, "HW control enabled: %s\n", |
| 1154 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1155 | seq_printf(m, "SW control enabled: %s\n", |
| 1156 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1157 | GEN6_RP_MEDIA_SW_MODE)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1158 | |
| 1159 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x, MASK=0x%08x\n", |
| 1160 | pm_ier, pm_imr, pm_mask); |
| 1161 | if (INTEL_GEN(dev_priv) <= 10) |
| 1162 | seq_printf(m, "PM ISR=0x%08x IIR=0x%08x\n", |
| 1163 | pm_isr, pm_iir); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1164 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1165 | rps->pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1166 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1167 | seq_printf(m, "Render p-state ratio: %d\n", |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1168 | (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1169 | seq_printf(m, "Render p-state VID: %d\n", |
| 1170 | gt_perf_status & 0xff); |
| 1171 | seq_printf(m, "Render p-state limit: %d\n", |
| 1172 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1173 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1174 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1175 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1176 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1177 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1178 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1179 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1180 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1181 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1182 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1183 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1184 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1185 | seq_printf(m, "Up threshold: %d%%\n", |
| 1186 | rps->power.up_threshold); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1187 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1188 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1189 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1190 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1191 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1192 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1193 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1194 | seq_printf(m, "Down threshold: %d%%\n", |
| 1195 | rps->power.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1196 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1197 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1198 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1199 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1200 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1201 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1202 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1203 | |
| 1204 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1205 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1206 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1207 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1208 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1209 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1210 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1211 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1212 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1213 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1214 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1215 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1216 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1217 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1218 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1219 | seq_printf(m, "Current freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1220 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1221 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1222 | seq_printf(m, "Idle freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1223 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1224 | seq_printf(m, "Min freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1225 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1226 | seq_printf(m, "Boost freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1227 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1228 | seq_printf(m, "Max freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1229 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1230 | seq_printf(m, |
| 1231 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1232 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1233 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1234 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1235 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1236 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1237 | 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] | 1238 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1239 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1240 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1241 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1242 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1243 | } |
| 1244 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1245 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1246 | struct seq_file *m, |
| 1247 | struct intel_instdone *instdone) |
| 1248 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1249 | int slice; |
| 1250 | int subslice; |
| 1251 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1252 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1253 | instdone->instdone); |
| 1254 | |
| 1255 | if (INTEL_GEN(dev_priv) <= 3) |
| 1256 | return; |
| 1257 | |
| 1258 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1259 | instdone->slice_common); |
| 1260 | |
| 1261 | if (INTEL_GEN(dev_priv) <= 6) |
| 1262 | return; |
| 1263 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1264 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1265 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1266 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1267 | |
| 1268 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1269 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1270 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1271 | } |
| 1272 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1273 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1274 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1275 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1276 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1277 | u64 acthd[I915_NUM_ENGINES]; |
| 1278 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1279 | struct intel_instdone instdone; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1280 | intel_wakeref_t wakeref; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1281 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1282 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1283 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1284 | seq_puts(m, "Wedged\n"); |
| 1285 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
| 1286 | seq_puts(m, "Reset in progress: struct_mutex backoff\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1287 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1288 | seq_puts(m, "Waiter holding struct mutex\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1289 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1290 | seq_puts(m, "struct_mutex blocked for reset\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1291 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1292 | if (!i915_modparams.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1293 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1294 | return 0; |
| 1295 | } |
| 1296 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1297 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1298 | for_each_engine(engine, dev_priv, id) { |
| 1299 | acthd[id] = intel_engine_get_active_head(engine); |
| 1300 | seqno[id] = intel_engine_get_seqno(engine); |
| 1301 | } |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1302 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1303 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1304 | } |
| 1305 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1306 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1307 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1308 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1309 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1310 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1311 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1312 | else |
| 1313 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1314 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1315 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1316 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1317 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1318 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame] | 1319 | seq_printf(m, "\tseqno = %x [current %x, last %x], %dms ago\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1320 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame] | 1321 | intel_engine_last_submit(engine), |
| 1322 | jiffies_to_msecs(jiffies - |
| 1323 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1324 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1325 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1326 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1327 | (long long)acthd[id]); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1328 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1329 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1330 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1331 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1332 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1333 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1334 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1335 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1336 | i915_instdone_info(dev_priv, m, |
| 1337 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1338 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1339 | } |
| 1340 | |
| 1341 | return 0; |
| 1342 | } |
| 1343 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1344 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1345 | { |
| 1346 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1347 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1348 | struct intel_engine_cs *engine; |
| 1349 | enum intel_engine_id id; |
| 1350 | |
| 1351 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1352 | |
| 1353 | for_each_engine(engine, dev_priv, id) { |
| 1354 | seq_printf(m, "%s = %u\n", engine->name, |
| 1355 | i915_reset_engine_count(error, engine)); |
| 1356 | } |
| 1357 | |
| 1358 | return 0; |
| 1359 | } |
| 1360 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1361 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1362 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1363 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1364 | u32 rgvmodectl, rstdbyctl; |
| 1365 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1366 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1367 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1368 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1369 | crstandvid = I915_READ16(CRSTANDVID); |
| 1370 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1371 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1372 | seq_printf(m, "Boost freq: %d\n", |
| 1373 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1374 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1375 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1376 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1377 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1378 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1379 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1380 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1381 | seq_printf(m, "Starting frequency: P%d\n", |
| 1382 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1383 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1384 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1385 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1386 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1387 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1388 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1389 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1390 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1391 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1392 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1393 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1394 | break; |
| 1395 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1396 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1397 | break; |
| 1398 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1399 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1400 | break; |
| 1401 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1402 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1403 | break; |
| 1404 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1405 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1406 | break; |
| 1407 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1408 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1409 | break; |
| 1410 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1411 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1412 | break; |
| 1413 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1414 | |
| 1415 | return 0; |
| 1416 | } |
| 1417 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1418 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1419 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1420 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1421 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1422 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1423 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1424 | seq_printf(m, "user.bypass_count = %u\n", |
| 1425 | i915->uncore.user_forcewake.count); |
| 1426 | |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1427 | for_each_fw_domain(fw_domain, i915, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1428 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1429 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1430 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1431 | |
| 1432 | return 0; |
| 1433 | } |
| 1434 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1435 | static void print_rc6_res(struct seq_file *m, |
| 1436 | const char *title, |
| 1437 | const i915_reg_t reg) |
| 1438 | { |
| 1439 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1440 | |
| 1441 | seq_printf(m, "%s %u (%llu us)\n", |
| 1442 | title, I915_READ(reg), |
| 1443 | intel_rc6_residency_us(dev_priv, reg)); |
| 1444 | } |
| 1445 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1446 | static int vlv_drpc_info(struct seq_file *m) |
| 1447 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1448 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1449 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1450 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1451 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1452 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1453 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1454 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1455 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1456 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1457 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1458 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1459 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1460 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1461 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1462 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1463 | 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] | 1464 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1465 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1466 | } |
| 1467 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1468 | static int gen6_drpc_info(struct seq_file *m) |
| 1469 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1470 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1471 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1472 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1473 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1474 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1475 | 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] | 1476 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1477 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1478 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1479 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1480 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1481 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1482 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1483 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1484 | mutex_lock(&dev_priv->pcu_lock); |
| 1485 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, |
| 1486 | &rc6vids); |
| 1487 | mutex_unlock(&dev_priv->pcu_lock); |
| 1488 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1489 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1490 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1491 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1492 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1493 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1494 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1495 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1496 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1497 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1498 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1499 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1500 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1501 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1502 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1503 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1504 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1505 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1506 | case GEN6_RC0: |
| 1507 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1508 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1509 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1510 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1511 | break; |
| 1512 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1513 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1514 | break; |
| 1515 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1516 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1517 | break; |
| 1518 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1519 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1520 | break; |
| 1521 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1522 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1523 | break; |
| 1524 | } |
| 1525 | |
| 1526 | seq_printf(m, "Core Power Down: %s\n", |
| 1527 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1528 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1529 | seq_printf(m, "Render Power Well: %s\n", |
| 1530 | (gen9_powergate_status & |
| 1531 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1532 | seq_printf(m, "Media Power Well: %s\n", |
| 1533 | (gen9_powergate_status & |
| 1534 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1535 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1536 | |
| 1537 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1538 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1539 | GEN6_GT_GFX_RC6_LOCKED); |
| 1540 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1541 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1542 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1543 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1544 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1545 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1546 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1547 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1548 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1549 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1550 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
| 1551 | } |
| 1552 | |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1553 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1554 | } |
| 1555 | |
| 1556 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1557 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1558 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1559 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1560 | int err = -ENODEV; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1561 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1562 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1563 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 1564 | err = vlv_drpc_info(m); |
| 1565 | else if (INTEL_GEN(dev_priv) >= 6) |
| 1566 | err = gen6_drpc_info(m); |
| 1567 | else |
| 1568 | err = ironlake_drpc_info(m); |
| 1569 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1570 | |
| 1571 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1572 | } |
| 1573 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1574 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1575 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1576 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1577 | |
| 1578 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1579 | dev_priv->fb_tracking.busy_bits); |
| 1580 | |
| 1581 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1582 | dev_priv->fb_tracking.flip_bits); |
| 1583 | |
| 1584 | return 0; |
| 1585 | } |
| 1586 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1587 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1588 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1589 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1590 | struct intel_fbc *fbc = &dev_priv->fbc; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1591 | intel_wakeref_t wakeref; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1592 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1593 | if (!HAS_FBC(dev_priv)) |
| 1594 | return -ENODEV; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1595 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1596 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1597 | mutex_lock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1598 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1599 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1600 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1601 | else |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1602 | seq_printf(m, "FBC disabled: %s\n", fbc->no_fbc_reason); |
| 1603 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1604 | if (intel_fbc_is_active(dev_priv)) { |
| 1605 | u32 mask; |
| 1606 | |
| 1607 | if (INTEL_GEN(dev_priv) >= 8) |
| 1608 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1609 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1610 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1611 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1612 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1613 | else if (IS_G4X(dev_priv)) |
| 1614 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1615 | else |
| 1616 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1617 | FBC_STAT_COMPRESSED); |
| 1618 | |
| 1619 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1620 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1621 | |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1622 | mutex_unlock(&fbc->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1623 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1624 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1625 | return 0; |
| 1626 | } |
| 1627 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1628 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1629 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1630 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1631 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1632 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1633 | return -ENODEV; |
| 1634 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1635 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1636 | |
| 1637 | return 0; |
| 1638 | } |
| 1639 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1640 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1641 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1642 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1643 | u32 reg; |
| 1644 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1645 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1646 | return -ENODEV; |
| 1647 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1648 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1649 | |
| 1650 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1651 | dev_priv->fbc.false_color = val; |
| 1652 | |
| 1653 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1654 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1655 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1656 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1657 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1658 | return 0; |
| 1659 | } |
| 1660 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1661 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1662 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1663 | "%llu\n"); |
| 1664 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1665 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1666 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1667 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1668 | intel_wakeref_t wakeref; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1669 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1670 | if (!HAS_IPS(dev_priv)) |
| 1671 | return -ENODEV; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1672 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1673 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1674 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1675 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1676 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1677 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1678 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1679 | seq_puts(m, "Currently: unknown\n"); |
| 1680 | } else { |
| 1681 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1682 | seq_puts(m, "Currently: enabled\n"); |
| 1683 | else |
| 1684 | seq_puts(m, "Currently: disabled\n"); |
| 1685 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1686 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1687 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1688 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1689 | return 0; |
| 1690 | } |
| 1691 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1692 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1693 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1694 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1695 | intel_wakeref_t wakeref; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1696 | bool sr_enabled = false; |
| 1697 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1698 | wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1699 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1700 | if (INTEL_GEN(dev_priv) >= 9) |
| 1701 | /* no global SR status; inspect per-plane WM */; |
| 1702 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1703 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1704 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1705 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1706 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1707 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1708 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1709 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1710 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1711 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1712 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1713 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1714 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1715 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1716 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1717 | |
| 1718 | return 0; |
| 1719 | } |
| 1720 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1721 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1722 | { |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1723 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1724 | intel_wakeref_t wakeref; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1725 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1726 | if (!IS_GEN(i915, 5)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1727 | return -ENODEV; |
| 1728 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1729 | with_intel_runtime_pm(i915, wakeref) { |
| 1730 | unsigned long temp, chipset, gfx; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1731 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1732 | temp = i915_mch_val(i915); |
| 1733 | chipset = i915_chipset_val(i915); |
| 1734 | gfx = i915_gfx_val(i915); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1735 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1736 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1737 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1738 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1739 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1740 | } |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1741 | |
| 1742 | return 0; |
| 1743 | } |
| 1744 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1745 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1746 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1747 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1748 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1749 | unsigned int max_gpu_freq, min_gpu_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1750 | intel_wakeref_t wakeref; |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1751 | int gpu_freq, ia_freq; |
| 1752 | int ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1753 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1754 | if (!HAS_LLC(dev_priv)) |
| 1755 | return -ENODEV; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1756 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1757 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1758 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1759 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1760 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1761 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1762 | |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1763 | min_gpu_freq = rps->min_freq; |
| 1764 | max_gpu_freq = rps->max_freq; |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1765 | if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1766 | /* Convert GT frequency to 50 HZ units */ |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1767 | min_gpu_freq /= GEN9_FREQ_SCALER; |
| 1768 | max_gpu_freq /= GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1769 | } |
| 1770 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1771 | 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] | 1772 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1773 | 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] | 1774 | ia_freq = gpu_freq; |
| 1775 | sandybridge_pcode_read(dev_priv, |
| 1776 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1777 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1778 | 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] | 1779 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1780 | (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1781 | INTEL_GEN(dev_priv) >= 10 ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1782 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1783 | ((ia_freq >> 0) & 0xff) * 100, |
| 1784 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1785 | } |
| 1786 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1787 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1788 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1789 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1790 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1791 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1792 | } |
| 1793 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1794 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1795 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1796 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1797 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1798 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1799 | int ret; |
| 1800 | |
| 1801 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1802 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1803 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1804 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1805 | if (opregion->header) |
| 1806 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1807 | |
| 1808 | mutex_unlock(&dev->struct_mutex); |
| 1809 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1810 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1811 | return 0; |
| 1812 | } |
| 1813 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1814 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1815 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1816 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1817 | |
| 1818 | if (opregion->vbt) |
| 1819 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1820 | |
| 1821 | return 0; |
| 1822 | } |
| 1823 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1824 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1825 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1826 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1827 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1828 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1829 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1830 | int ret; |
| 1831 | |
| 1832 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1833 | if (ret) |
| 1834 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1835 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1836 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1837 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1838 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1839 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1840 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1841 | fbdev_fb->base.width, |
| 1842 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1843 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1844 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1845 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1846 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1847 | describe_obj(m, intel_fb_obj(&fbdev_fb->base)); |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1848 | seq_putc(m, '\n'); |
| 1849 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1850 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1851 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1852 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1853 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1854 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1855 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1856 | continue; |
| 1857 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1858 | 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] | 1859 | fb->base.width, |
| 1860 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1861 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1862 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1863 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1864 | drm_framebuffer_read_refcount(&fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1865 | describe_obj(m, intel_fb_obj(&fb->base)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1866 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1867 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1868 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1869 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1870 | |
| 1871 | return 0; |
| 1872 | } |
| 1873 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1874 | 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] | 1875 | { |
Chris Wilson | ef5032a | 2018-03-07 13:42:24 +0000 | [diff] [blame] | 1876 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", |
| 1877 | ring->space, ring->head, ring->tail, ring->emit); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1878 | } |
| 1879 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1880 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1881 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1882 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1883 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1884 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1885 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1886 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1887 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1888 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1889 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1890 | if (ret) |
| 1891 | return ret; |
| 1892 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1893 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 288f1ce | 2018-09-04 16:31:17 +0100 | [diff] [blame] | 1894 | seq_puts(m, "HW context "); |
| 1895 | if (!list_empty(&ctx->hw_id_link)) |
| 1896 | seq_printf(m, "%x [pin %u]", ctx->hw_id, |
| 1897 | atomic_read(&ctx->hw_id_pin_count)); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1898 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1899 | struct task_struct *task; |
| 1900 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1901 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1902 | if (task) { |
| 1903 | seq_printf(m, "(%s [%d]) ", |
| 1904 | task->comm, task->pid); |
| 1905 | put_task_struct(task); |
| 1906 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1907 | } else if (IS_ERR(ctx->file_priv)) { |
| 1908 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1909 | } else { |
| 1910 | seq_puts(m, "(kernel) "); |
| 1911 | } |
| 1912 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1913 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1914 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1915 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1916 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 1917 | struct intel_context *ce = |
| 1918 | to_intel_context(ctx, engine); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1919 | |
| 1920 | seq_printf(m, "%s: ", engine->name); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1921 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1922 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1923 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1924 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1925 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1926 | } |
| 1927 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1928 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1929 | } |
| 1930 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1931 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1932 | |
| 1933 | return 0; |
| 1934 | } |
| 1935 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1936 | static const char *swizzle_string(unsigned swizzle) |
| 1937 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1938 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1939 | case I915_BIT_6_SWIZZLE_NONE: |
| 1940 | return "none"; |
| 1941 | case I915_BIT_6_SWIZZLE_9: |
| 1942 | return "bit9"; |
| 1943 | case I915_BIT_6_SWIZZLE_9_10: |
| 1944 | return "bit9/bit10"; |
| 1945 | case I915_BIT_6_SWIZZLE_9_11: |
| 1946 | return "bit9/bit11"; |
| 1947 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1948 | return "bit9/bit10/bit11"; |
| 1949 | case I915_BIT_6_SWIZZLE_9_17: |
| 1950 | return "bit9/bit17"; |
| 1951 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1952 | return "bit9/bit10/bit17"; |
| 1953 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1954 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1955 | } |
| 1956 | |
| 1957 | return "bug"; |
| 1958 | } |
| 1959 | |
| 1960 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1961 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1962 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1963 | intel_wakeref_t wakeref; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1964 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1965 | wakeref = intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1966 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1967 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1968 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1969 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1970 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1971 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 1972 | if (IS_GEN_RANGE(dev_priv, 3, 4)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1973 | seq_printf(m, "DDC = 0x%08x\n", |
| 1974 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1975 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 1976 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1977 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1978 | I915_READ16(C0DRB3)); |
| 1979 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1980 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1981 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1982 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1983 | I915_READ(MAD_DIMM_C0)); |
| 1984 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1985 | I915_READ(MAD_DIMM_C1)); |
| 1986 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1987 | I915_READ(MAD_DIMM_C2)); |
| 1988 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1989 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1990 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 1991 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 1992 | I915_READ(GAMTARBMODE)); |
| 1993 | else |
| 1994 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 1995 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1996 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 1997 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1998 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1999 | |
| 2000 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2001 | seq_puts(m, "L-shaped memory detected\n"); |
| 2002 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2003 | intel_runtime_pm_put(dev_priv, wakeref); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2004 | |
| 2005 | return 0; |
| 2006 | } |
| 2007 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2008 | static const char *rps_power_to_str(unsigned int power) |
| 2009 | { |
| 2010 | static const char * const strings[] = { |
| 2011 | [LOW_POWER] = "low power", |
| 2012 | [BETWEEN] = "mixed", |
| 2013 | [HIGH_POWER] = "high power", |
| 2014 | }; |
| 2015 | |
| 2016 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2017 | return "unknown"; |
| 2018 | |
| 2019 | return strings[power]; |
| 2020 | } |
| 2021 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2022 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2023 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2024 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2025 | struct drm_device *dev = &dev_priv->drm; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2026 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2027 | u32 act_freq = rps->cur_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2028 | intel_wakeref_t wakeref; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2029 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2030 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2031 | with_intel_runtime_pm_if_in_use(dev_priv, wakeref) { |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2032 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 2033 | mutex_lock(&dev_priv->pcu_lock); |
| 2034 | act_freq = vlv_punit_read(dev_priv, |
| 2035 | PUNIT_REG_GPU_FREQ_STS); |
| 2036 | act_freq = (act_freq >> 8) & 0xff; |
| 2037 | mutex_unlock(&dev_priv->pcu_lock); |
| 2038 | } else { |
| 2039 | act_freq = intel_get_cagf(dev_priv, |
| 2040 | I915_READ(GEN6_RPSTAT1)); |
| 2041 | } |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2042 | } |
| 2043 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2044 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2045 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2046 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2047 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2048 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2049 | seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2050 | seq_printf(m, "Frequency requested %d, actual %d\n", |
| 2051 | intel_gpu_freq(dev_priv, rps->cur_freq), |
| 2052 | intel_gpu_freq(dev_priv, act_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2053 | 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] | 2054 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2055 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2056 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2057 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2058 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2059 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2060 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2061 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2062 | |
| 2063 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2064 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2065 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2066 | struct task_struct *task; |
| 2067 | |
| 2068 | rcu_read_lock(); |
| 2069 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2070 | seq_printf(m, "%s [%d]: %d boosts\n", |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2071 | task ? task->comm : "<unknown>", |
| 2072 | task ? task->pid : -1, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2073 | atomic_read(&file_priv->rps_client.boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2074 | rcu_read_unlock(); |
| 2075 | } |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2076 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2077 | atomic_read(&rps->boosts)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2078 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2079 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2080 | if (INTEL_GEN(dev_priv) >= 6 && |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2081 | rps->enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2082 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2083 | u32 rpup, rpupei; |
| 2084 | u32 rpdown, rpdownei; |
| 2085 | |
| 2086 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2087 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2088 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2089 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2090 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2091 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2092 | |
| 2093 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2094 | rps_power_to_str(rps->power.mode)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2095 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2096 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2097 | rps->power.up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2098 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2099 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2100 | rps->power.down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2101 | } else { |
| 2102 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2103 | } |
| 2104 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2105 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2106 | } |
| 2107 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2108 | static int i915_llc(struct seq_file *m, void *data) |
| 2109 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2110 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2111 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2112 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2113 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2114 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2115 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2116 | |
| 2117 | return 0; |
| 2118 | } |
| 2119 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2120 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2121 | { |
| 2122 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2123 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2124 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2125 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2126 | if (!HAS_HUC(dev_priv)) |
| 2127 | return -ENODEV; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2128 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2129 | p = drm_seq_file_printer(m); |
| 2130 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2131 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2132 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2133 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2134 | |
| 2135 | return 0; |
| 2136 | } |
| 2137 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2138 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2139 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2140 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2141 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2142 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2143 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2144 | if (!HAS_GUC(dev_priv)) |
| 2145 | return -ENODEV; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2146 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2147 | p = drm_seq_file_printer(m); |
| 2148 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2149 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2150 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 2151 | u32 tmp = I915_READ(GUC_STATUS); |
| 2152 | u32 i; |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2153 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2154 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2155 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2156 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2157 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2158 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2159 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2160 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2161 | seq_puts(m, "\nScratch registers:\n"); |
| 2162 | for (i = 0; i < 16; i++) { |
| 2163 | seq_printf(m, "\t%2d: \t0x%x\n", |
| 2164 | i, I915_READ(SOFT_SCRATCH(i))); |
| 2165 | } |
| 2166 | } |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2167 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2168 | return 0; |
| 2169 | } |
| 2170 | |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2171 | static const char * |
| 2172 | stringify_guc_log_type(enum guc_log_buffer_type type) |
| 2173 | { |
| 2174 | switch (type) { |
| 2175 | case GUC_ISR_LOG_BUFFER: |
| 2176 | return "ISR"; |
| 2177 | case GUC_DPC_LOG_BUFFER: |
| 2178 | return "DPC"; |
| 2179 | case GUC_CRASH_DUMP_LOG_BUFFER: |
| 2180 | return "CRASH"; |
| 2181 | default: |
| 2182 | MISSING_CASE(type); |
| 2183 | } |
| 2184 | |
| 2185 | return ""; |
| 2186 | } |
| 2187 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2188 | static void i915_guc_log_info(struct seq_file *m, |
| 2189 | struct drm_i915_private *dev_priv) |
| 2190 | { |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2191 | struct intel_guc_log *log = &dev_priv->guc.log; |
| 2192 | enum guc_log_buffer_type type; |
| 2193 | |
| 2194 | if (!intel_guc_log_relay_enabled(log)) { |
| 2195 | seq_puts(m, "GuC log relay disabled\n"); |
| 2196 | return; |
| 2197 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2198 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2199 | seq_puts(m, "GuC logging stats:\n"); |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2200 | |
Michał Winiarski | 6a96be2 | 2018-03-19 10:53:42 +0100 | [diff] [blame] | 2201 | seq_printf(m, "\tRelay full count: %u\n", |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2202 | log->relay.full_count); |
| 2203 | |
| 2204 | for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { |
| 2205 | seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", |
| 2206 | stringify_guc_log_type(type), |
| 2207 | log->stats[type].flush, |
| 2208 | log->stats[type].sampled_overflow); |
| 2209 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2210 | } |
| 2211 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2212 | static void i915_guc_client_info(struct seq_file *m, |
| 2213 | struct drm_i915_private *dev_priv, |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2214 | struct intel_guc_client *client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2215 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2216 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2217 | enum intel_engine_id id; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 2218 | u64 tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2219 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2220 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2221 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2222 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2223 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2224 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2225 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2226 | u64 submissions = client->submissions[id]; |
| 2227 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2228 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2229 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2230 | } |
| 2231 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2232 | } |
| 2233 | |
| 2234 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2235 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2236 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2237 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2238 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2239 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2240 | return -ENODEV; |
| 2241 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2242 | i915_guc_log_info(m, dev_priv); |
| 2243 | |
| 2244 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2245 | return 0; |
| 2246 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2247 | GEM_BUG_ON(!guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2248 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2249 | seq_printf(m, "\nDoorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2250 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2251 | seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2252 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2253 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2254 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Chris Wilson | e78c917 | 2018-02-07 21:05:42 +0000 | [diff] [blame] | 2255 | if (guc->preempt_client) { |
| 2256 | seq_printf(m, "\nGuC preempt client @ %p:\n", |
| 2257 | guc->preempt_client); |
| 2258 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
| 2259 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2260 | |
| 2261 | /* Add more as required ... */ |
| 2262 | |
| 2263 | return 0; |
| 2264 | } |
| 2265 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2266 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2267 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2268 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2269 | const struct intel_guc *guc = &dev_priv->guc; |
| 2270 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2271 | struct intel_guc_client *client = guc->execbuf_client; |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2272 | unsigned int tmp; |
| 2273 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2274 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2275 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2276 | return -ENODEV; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2277 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2278 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2279 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2280 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2281 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2282 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2283 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2284 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2285 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2286 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2287 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2288 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2289 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2290 | desc->engines_used); |
| 2291 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2292 | desc->db_trigger_phy, |
| 2293 | desc->db_trigger_cpu, |
| 2294 | desc->db_trigger_uk); |
| 2295 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2296 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2297 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2298 | desc->wq_addr, desc->wq_size); |
| 2299 | seq_putc(m, '\n'); |
| 2300 | |
| 2301 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2302 | u32 guc_engine_id = engine->guc_id; |
| 2303 | struct guc_execlist_context *lrc = |
| 2304 | &desc->lrc[guc_engine_id]; |
| 2305 | |
| 2306 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2307 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2308 | lrc->context_desc); |
| 2309 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2310 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2311 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2312 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2313 | seq_putc(m, '\n'); |
| 2314 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2315 | } |
| 2316 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2317 | return 0; |
| 2318 | } |
| 2319 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2320 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2321 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2322 | struct drm_info_node *node = m->private; |
| 2323 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2324 | bool dump_load_err = !!node->info_ent->data; |
| 2325 | struct drm_i915_gem_object *obj = NULL; |
| 2326 | u32 *log; |
| 2327 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2328 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2329 | if (!HAS_GUC(dev_priv)) |
| 2330 | return -ENODEV; |
| 2331 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2332 | if (dump_load_err) |
| 2333 | obj = dev_priv->guc.load_err_log; |
| 2334 | else if (dev_priv->guc.log.vma) |
| 2335 | obj = dev_priv->guc.log.vma->obj; |
| 2336 | |
| 2337 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2338 | return 0; |
| 2339 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2340 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2341 | if (IS_ERR(log)) { |
| 2342 | DRM_DEBUG("Failed to pin object\n"); |
| 2343 | seq_puts(m, "(log data unaccessible)\n"); |
| 2344 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2345 | } |
| 2346 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2347 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2348 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2349 | *(log + i), *(log + i + 1), |
| 2350 | *(log + i + 2), *(log + i + 3)); |
| 2351 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2352 | seq_putc(m, '\n'); |
| 2353 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2354 | i915_gem_object_unpin_map(obj); |
| 2355 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2356 | return 0; |
| 2357 | } |
| 2358 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2359 | static int i915_guc_log_level_get(void *data, u64 *val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2360 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2361 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2362 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2363 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2364 | return -ENODEV; |
| 2365 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2366 | *val = intel_guc_log_get_level(&dev_priv->guc.log); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2367 | |
| 2368 | return 0; |
| 2369 | } |
| 2370 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2371 | static int i915_guc_log_level_set(void *data, u64 val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2372 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2373 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2374 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2375 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2376 | return -ENODEV; |
| 2377 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2378 | return intel_guc_log_set_level(&dev_priv->guc.log, val); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2379 | } |
| 2380 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2381 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, |
| 2382 | i915_guc_log_level_get, i915_guc_log_level_set, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2383 | "%lld\n"); |
| 2384 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2385 | static int i915_guc_log_relay_open(struct inode *inode, struct file *file) |
| 2386 | { |
| 2387 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2388 | |
| 2389 | if (!USES_GUC(dev_priv)) |
| 2390 | return -ENODEV; |
| 2391 | |
| 2392 | file->private_data = &dev_priv->guc.log; |
| 2393 | |
| 2394 | return intel_guc_log_relay_open(&dev_priv->guc.log); |
| 2395 | } |
| 2396 | |
| 2397 | static ssize_t |
| 2398 | i915_guc_log_relay_write(struct file *filp, |
| 2399 | const char __user *ubuf, |
| 2400 | size_t cnt, |
| 2401 | loff_t *ppos) |
| 2402 | { |
| 2403 | struct intel_guc_log *log = filp->private_data; |
| 2404 | |
| 2405 | intel_guc_log_relay_flush(log); |
| 2406 | |
| 2407 | return cnt; |
| 2408 | } |
| 2409 | |
| 2410 | static int i915_guc_log_relay_release(struct inode *inode, struct file *file) |
| 2411 | { |
| 2412 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2413 | |
| 2414 | intel_guc_log_relay_close(&dev_priv->guc.log); |
| 2415 | |
| 2416 | return 0; |
| 2417 | } |
| 2418 | |
| 2419 | static const struct file_operations i915_guc_log_relay_fops = { |
| 2420 | .owner = THIS_MODULE, |
| 2421 | .open = i915_guc_log_relay_open, |
| 2422 | .write = i915_guc_log_relay_write, |
| 2423 | .release = i915_guc_log_relay_release, |
| 2424 | }; |
| 2425 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2426 | static int i915_psr_sink_status_show(struct seq_file *m, void *data) |
| 2427 | { |
| 2428 | u8 val; |
| 2429 | static const char * const sink_status[] = { |
| 2430 | "inactive", |
| 2431 | "transition to active, capture and display", |
| 2432 | "active, display from RFB", |
| 2433 | "active, capture and display on sink device timings", |
| 2434 | "transition to inactive, capture and display, timing re-sync", |
| 2435 | "reserved", |
| 2436 | "reserved", |
| 2437 | "sink internal error", |
| 2438 | }; |
| 2439 | struct drm_connector *connector = m->private; |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2440 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2441 | struct intel_dp *intel_dp = |
| 2442 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2443 | int ret; |
| 2444 | |
| 2445 | if (!CAN_PSR(dev_priv)) { |
| 2446 | seq_puts(m, "PSR Unsupported\n"); |
| 2447 | return -ENODEV; |
| 2448 | } |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2449 | |
| 2450 | if (connector->status != connector_status_connected) |
| 2451 | return -ENODEV; |
| 2452 | |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2453 | ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val); |
| 2454 | |
| 2455 | if (ret == 1) { |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2456 | const char *str = "unknown"; |
| 2457 | |
| 2458 | val &= DP_PSR_SINK_STATE_MASK; |
| 2459 | if (val < ARRAY_SIZE(sink_status)) |
| 2460 | str = sink_status[val]; |
| 2461 | seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str); |
| 2462 | } else { |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2463 | return ret; |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2464 | } |
| 2465 | |
| 2466 | return 0; |
| 2467 | } |
| 2468 | DEFINE_SHOW_ATTRIBUTE(i915_psr_sink_status); |
| 2469 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2470 | static void |
| 2471 | psr_source_status(struct drm_i915_private *dev_priv, struct seq_file *m) |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2472 | { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2473 | u32 val, status_val; |
| 2474 | const char *status = "unknown"; |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2475 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2476 | if (dev_priv->psr.psr2_enabled) { |
| 2477 | static const char * const live_status[] = { |
| 2478 | "IDLE", |
| 2479 | "CAPTURE", |
| 2480 | "CAPTURE_FS", |
| 2481 | "SLEEP", |
| 2482 | "BUFON_FW", |
| 2483 | "ML_UP", |
| 2484 | "SU_STANDBY", |
| 2485 | "FAST_SLEEP", |
| 2486 | "DEEP_SLEEP", |
| 2487 | "BUF_ON", |
| 2488 | "TG_ON" |
| 2489 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2490 | val = I915_READ(EDP_PSR2_STATUS); |
| 2491 | status_val = (val & EDP_PSR2_STATUS_STATE_MASK) >> |
| 2492 | EDP_PSR2_STATUS_STATE_SHIFT; |
| 2493 | if (status_val < ARRAY_SIZE(live_status)) |
| 2494 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2495 | } else { |
| 2496 | static const char * const live_status[] = { |
| 2497 | "IDLE", |
| 2498 | "SRDONACK", |
| 2499 | "SRDENT", |
| 2500 | "BUFOFF", |
| 2501 | "BUFON", |
| 2502 | "AUXACK", |
| 2503 | "SRDOFFACK", |
| 2504 | "SRDENT_ON", |
| 2505 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2506 | val = I915_READ(EDP_PSR_STATUS); |
| 2507 | status_val = (val & EDP_PSR_STATUS_STATE_MASK) >> |
| 2508 | EDP_PSR_STATUS_STATE_SHIFT; |
| 2509 | if (status_val < ARRAY_SIZE(live_status)) |
| 2510 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2511 | } |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2512 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2513 | seq_printf(m, "Source PSR status: %s [0x%08x]\n", status, val); |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2514 | } |
| 2515 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2516 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2517 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2518 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2519 | struct i915_psr *psr = &dev_priv->psr; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2520 | intel_wakeref_t wakeref; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2521 | const char *status; |
| 2522 | bool enabled; |
| 2523 | u32 val; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2524 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2525 | if (!HAS_PSR(dev_priv)) |
| 2526 | return -ENODEV; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2527 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2528 | seq_printf(m, "Sink support: %s", yesno(psr->sink_support)); |
| 2529 | if (psr->dp) |
| 2530 | seq_printf(m, " [0x%02x]", psr->dp->psr_dpcd[0]); |
| 2531 | seq_puts(m, "\n"); |
| 2532 | |
| 2533 | if (!psr->sink_support) |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2534 | return 0; |
| 2535 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2536 | wakeref = intel_runtime_pm_get(dev_priv); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2537 | mutex_lock(&psr->lock); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2538 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2539 | if (psr->enabled) |
| 2540 | status = psr->psr2_enabled ? "PSR2 enabled" : "PSR1 enabled"; |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2541 | else |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2542 | status = "disabled"; |
| 2543 | seq_printf(m, "PSR mode: %s\n", status); |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2544 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2545 | if (!psr->enabled) |
| 2546 | goto unlock; |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2547 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2548 | if (psr->psr2_enabled) { |
| 2549 | val = I915_READ(EDP_PSR2_CTL); |
| 2550 | enabled = val & EDP_PSR2_ENABLE; |
| 2551 | } else { |
| 2552 | val = I915_READ(EDP_PSR_CTL); |
| 2553 | enabled = val & EDP_PSR_ENABLE; |
| 2554 | } |
| 2555 | seq_printf(m, "Source PSR ctl: %s [0x%08x]\n", |
| 2556 | enableddisabled(enabled), val); |
| 2557 | psr_source_status(dev_priv, m); |
| 2558 | seq_printf(m, "Busy frontbuffer bits: 0x%08x\n", |
| 2559 | psr->busy_frontbuffer_bits); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2560 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2561 | /* |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2562 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2563 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2564 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2565 | val = I915_READ(EDP_PSR_PERF_CNT) & EDP_PSR_PERF_CNT_MASK; |
| 2566 | seq_printf(m, "Performance counter: %u\n", val); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2567 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2568 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2569 | if (psr->debug & I915_PSR_DEBUG_IRQ) { |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2570 | seq_printf(m, "Last attempted entry at: %lld\n", |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2571 | psr->last_entry_attempt); |
| 2572 | seq_printf(m, "Last exit at: %lld\n", psr->last_exit); |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2573 | } |
| 2574 | |
José Roberto de Souza | a81f781 | 2019-01-17 12:55:48 -0800 | [diff] [blame] | 2575 | if (psr->psr2_enabled) { |
| 2576 | u32 su_frames_val[3]; |
| 2577 | int frame; |
| 2578 | |
| 2579 | /* |
| 2580 | * Reading all 3 registers before hand to minimize crossing a |
| 2581 | * frame boundary between register reads |
| 2582 | */ |
| 2583 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame += 3) |
| 2584 | su_frames_val[frame / 3] = I915_READ(PSR2_SU_STATUS(frame)); |
| 2585 | |
| 2586 | seq_puts(m, "Frame:\tPSR2 SU blocks:\n"); |
| 2587 | |
| 2588 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame++) { |
| 2589 | u32 su_blocks; |
| 2590 | |
| 2591 | su_blocks = su_frames_val[frame / 3] & |
| 2592 | PSR2_SU_STATUS_MASK(frame); |
| 2593 | su_blocks = su_blocks >> PSR2_SU_STATUS_SHIFT(frame); |
| 2594 | seq_printf(m, "%d\t%d\n", frame, su_blocks); |
| 2595 | } |
| 2596 | } |
| 2597 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2598 | unlock: |
| 2599 | mutex_unlock(&psr->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2600 | intel_runtime_pm_put(dev_priv, wakeref); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2601 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2602 | return 0; |
| 2603 | } |
| 2604 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2605 | static int |
| 2606 | i915_edp_psr_debug_set(void *data, u64 val) |
| 2607 | { |
| 2608 | struct drm_i915_private *dev_priv = data; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2609 | struct drm_modeset_acquire_ctx ctx; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2610 | intel_wakeref_t wakeref; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2611 | int ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2612 | |
| 2613 | if (!CAN_PSR(dev_priv)) |
| 2614 | return -ENODEV; |
| 2615 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2616 | DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2617 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2618 | wakeref = intel_runtime_pm_get(dev_priv); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2619 | |
| 2620 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 2621 | |
| 2622 | retry: |
| 2623 | ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val); |
| 2624 | if (ret == -EDEADLK) { |
| 2625 | ret = drm_modeset_backoff(&ctx); |
| 2626 | if (!ret) |
| 2627 | goto retry; |
| 2628 | } |
| 2629 | |
| 2630 | drm_modeset_drop_locks(&ctx); |
| 2631 | drm_modeset_acquire_fini(&ctx); |
| 2632 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2633 | intel_runtime_pm_put(dev_priv, wakeref); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2634 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2635 | return ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2636 | } |
| 2637 | |
| 2638 | static int |
| 2639 | i915_edp_psr_debug_get(void *data, u64 *val) |
| 2640 | { |
| 2641 | struct drm_i915_private *dev_priv = data; |
| 2642 | |
| 2643 | if (!CAN_PSR(dev_priv)) |
| 2644 | return -ENODEV; |
| 2645 | |
| 2646 | *val = READ_ONCE(dev_priv->psr.debug); |
| 2647 | return 0; |
| 2648 | } |
| 2649 | |
| 2650 | DEFINE_SIMPLE_ATTRIBUTE(i915_edp_psr_debug_fops, |
| 2651 | i915_edp_psr_debug_get, i915_edp_psr_debug_set, |
| 2652 | "%llu\n"); |
| 2653 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2654 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2655 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2656 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2657 | unsigned long long power; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2658 | intel_wakeref_t wakeref; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2659 | u32 units; |
| 2660 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2661 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2662 | return -ENODEV; |
| 2663 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2664 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2665 | return -ENODEV; |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2666 | |
| 2667 | units = (power & 0x1f00) >> 8; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2668 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2669 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2670 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2671 | power = (1000000 * power) >> units; /* convert to uJ */ |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2672 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2673 | |
| 2674 | return 0; |
| 2675 | } |
| 2676 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2677 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2678 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2679 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2680 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2681 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2682 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2683 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2684 | |
Chris Wilson | 25c896bd | 2019-01-14 14:21:25 +0000 | [diff] [blame] | 2685 | seq_printf(m, "Runtime power status: %s\n", |
| 2686 | enableddisabled(!dev_priv->power_domains.wakeref)); |
| 2687 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 2688 | seq_printf(m, "GPU idle: %s (epoch %u)\n", |
| 2689 | yesno(!dev_priv->gt.awake), dev_priv->gt.epoch); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2690 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2691 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2692 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2693 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2694 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2695 | #else |
| 2696 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2697 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2698 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2699 | pci_power_name(pdev->current_state), |
| 2700 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2701 | |
Chris Wilson | bd780f3 | 2019-01-14 14:21:09 +0000 | [diff] [blame] | 2702 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) { |
| 2703 | struct drm_printer p = drm_seq_file_printer(m); |
| 2704 | |
| 2705 | print_intel_runtime_pm_wakeref(dev_priv, &p); |
| 2706 | } |
| 2707 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2708 | return 0; |
| 2709 | } |
| 2710 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2711 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2712 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2713 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2714 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2715 | int i; |
| 2716 | |
| 2717 | mutex_lock(&power_domains->lock); |
| 2718 | |
| 2719 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2720 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2721 | struct i915_power_well *power_well; |
| 2722 | enum intel_display_power_domain power_domain; |
| 2723 | |
| 2724 | power_well = &power_domains->power_wells[i]; |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2725 | seq_printf(m, "%-25s %d\n", power_well->desc->name, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2726 | power_well->count); |
| 2727 | |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2728 | for_each_power_domain(power_domain, power_well->desc->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2729 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2730 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2731 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | mutex_unlock(&power_domains->lock); |
| 2735 | |
| 2736 | return 0; |
| 2737 | } |
| 2738 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2739 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2740 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2741 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2742 | intel_wakeref_t wakeref; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2743 | struct intel_csr *csr; |
| 2744 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2745 | if (!HAS_CSR(dev_priv)) |
| 2746 | return -ENODEV; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2747 | |
| 2748 | csr = &dev_priv->csr; |
| 2749 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2750 | wakeref = intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2751 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2752 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2753 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2754 | |
| 2755 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2756 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2757 | |
| 2758 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2759 | CSR_VERSION_MINOR(csr->version)); |
| 2760 | |
Imre Deak | 34b2f8d | 2018-10-31 22:02:20 +0200 | [diff] [blame] | 2761 | if (WARN_ON(INTEL_GEN(dev_priv) > 11)) |
| 2762 | goto out; |
| 2763 | |
| 2764 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2765 | I915_READ(IS_BROXTON(dev_priv) ? BXT_CSR_DC3_DC5_COUNT : |
| 2766 | SKL_CSR_DC3_DC5_COUNT)); |
| 2767 | if (!IS_GEN9_LP(dev_priv)) |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2768 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2769 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2770 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2771 | out: |
| 2772 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2773 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2774 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2775 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2776 | intel_runtime_pm_put(dev_priv, wakeref); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2777 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2778 | return 0; |
| 2779 | } |
| 2780 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2781 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2782 | struct drm_display_mode *mode) |
| 2783 | { |
| 2784 | int i; |
| 2785 | |
| 2786 | for (i = 0; i < tabs; i++) |
| 2787 | seq_putc(m, '\t'); |
| 2788 | |
Shayenne Moura | 4fb6bb8 | 2018-12-20 10:27:57 -0200 | [diff] [blame] | 2789 | seq_printf(m, DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2790 | } |
| 2791 | |
| 2792 | static void intel_encoder_info(struct seq_file *m, |
| 2793 | struct intel_crtc *intel_crtc, |
| 2794 | struct intel_encoder *intel_encoder) |
| 2795 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2796 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2797 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2798 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2799 | struct intel_connector *intel_connector; |
| 2800 | struct drm_encoder *encoder; |
| 2801 | |
| 2802 | encoder = &intel_encoder->base; |
| 2803 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2804 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2805 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2806 | struct drm_connector *connector = &intel_connector->base; |
| 2807 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2808 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2809 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2810 | drm_get_connector_status_name(connector->status)); |
| 2811 | if (connector->status == connector_status_connected) { |
| 2812 | struct drm_display_mode *mode = &crtc->mode; |
| 2813 | seq_printf(m, ", mode:\n"); |
| 2814 | intel_seq_print_mode(m, 2, mode); |
| 2815 | } else { |
| 2816 | seq_putc(m, '\n'); |
| 2817 | } |
| 2818 | } |
| 2819 | } |
| 2820 | |
| 2821 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2822 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2823 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2824 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2825 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2826 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2827 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2828 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2829 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2830 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2831 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2832 | fb->base.id, plane_state->src_x >> 16, |
| 2833 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2834 | else |
| 2835 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2836 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2837 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2838 | } |
| 2839 | |
| 2840 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2841 | { |
| 2842 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2843 | |
| 2844 | seq_printf(m, "\tfixed mode:\n"); |
| 2845 | intel_seq_print_mode(m, 2, mode); |
| 2846 | } |
| 2847 | |
| 2848 | static void intel_dp_info(struct seq_file *m, |
| 2849 | struct intel_connector *intel_connector) |
| 2850 | { |
| 2851 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2852 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2853 | |
| 2854 | 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] | 2855 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2856 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2857 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2858 | |
| 2859 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2860 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2861 | } |
| 2862 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2863 | static void intel_dp_mst_info(struct seq_file *m, |
| 2864 | struct intel_connector *intel_connector) |
| 2865 | { |
| 2866 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2867 | struct intel_dp_mst_encoder *intel_mst = |
| 2868 | enc_to_mst(&intel_encoder->base); |
| 2869 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2870 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2871 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2872 | intel_connector->port); |
| 2873 | |
| 2874 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2875 | } |
| 2876 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2877 | static void intel_hdmi_info(struct seq_file *m, |
| 2878 | struct intel_connector *intel_connector) |
| 2879 | { |
| 2880 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2881 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2882 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2883 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2884 | } |
| 2885 | |
| 2886 | static void intel_lvds_info(struct seq_file *m, |
| 2887 | struct intel_connector *intel_connector) |
| 2888 | { |
| 2889 | intel_panel_info(m, &intel_connector->panel); |
| 2890 | } |
| 2891 | |
| 2892 | static void intel_connector_info(struct seq_file *m, |
| 2893 | struct drm_connector *connector) |
| 2894 | { |
| 2895 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2896 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2897 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2898 | |
| 2899 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2900 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2901 | drm_get_connector_status_name(connector->status)); |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame] | 2902 | |
| 2903 | if (connector->status == connector_status_disconnected) |
| 2904 | return; |
| 2905 | |
| 2906 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2907 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2908 | connector->display_info.width_mm, |
| 2909 | connector->display_info.height_mm); |
| 2910 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2911 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2912 | seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2913 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 2914 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2915 | return; |
| 2916 | |
| 2917 | switch (connector->connector_type) { |
| 2918 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2919 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2920 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2921 | intel_dp_mst_info(m, intel_connector); |
| 2922 | else |
| 2923 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2924 | break; |
| 2925 | case DRM_MODE_CONNECTOR_LVDS: |
| 2926 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2927 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2928 | break; |
| 2929 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2930 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 2931 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2932 | intel_hdmi_info(m, intel_connector); |
| 2933 | break; |
| 2934 | default: |
| 2935 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2936 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2937 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2938 | seq_printf(m, "\tmodes:\n"); |
| 2939 | list_for_each_entry(mode, &connector->modes, head) |
| 2940 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2941 | } |
| 2942 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2943 | static const char *plane_type(enum drm_plane_type type) |
| 2944 | { |
| 2945 | switch (type) { |
| 2946 | case DRM_PLANE_TYPE_OVERLAY: |
| 2947 | return "OVL"; |
| 2948 | case DRM_PLANE_TYPE_PRIMARY: |
| 2949 | return "PRI"; |
| 2950 | case DRM_PLANE_TYPE_CURSOR: |
| 2951 | return "CUR"; |
| 2952 | /* |
| 2953 | * Deliberately omitting default: to generate compiler warnings |
| 2954 | * when a new drm_plane_type gets added. |
| 2955 | */ |
| 2956 | } |
| 2957 | |
| 2958 | return "unknown"; |
| 2959 | } |
| 2960 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2961 | static void plane_rotation(char *buf, size_t bufsize, unsigned int rotation) |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2962 | { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2963 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2964 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2965 | * will print them all to visualize if the values are misused |
| 2966 | */ |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2967 | snprintf(buf, bufsize, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2968 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2969 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 2970 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 2971 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 2972 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 2973 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 2974 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2975 | rotation); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2976 | } |
| 2977 | |
| 2978 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2979 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2980 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2981 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2982 | struct intel_plane *intel_plane; |
| 2983 | |
| 2984 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 2985 | struct drm_plane_state *state; |
| 2986 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2987 | struct drm_format_name_buf format_name; |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2988 | char rot_str[48]; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2989 | |
| 2990 | if (!plane->state) { |
| 2991 | seq_puts(m, "plane->state is NULL!\n"); |
| 2992 | continue; |
| 2993 | } |
| 2994 | |
| 2995 | state = plane->state; |
| 2996 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2997 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 2998 | drm_get_format_name(state->fb->format->format, |
| 2999 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3000 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3001 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3002 | } |
| 3003 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3004 | plane_rotation(rot_str, sizeof(rot_str), state->rotation); |
| 3005 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3006 | 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", |
| 3007 | plane->base.id, |
| 3008 | plane_type(intel_plane->base.type), |
| 3009 | state->crtc_x, state->crtc_y, |
| 3010 | state->crtc_w, state->crtc_h, |
| 3011 | (state->src_x >> 16), |
| 3012 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3013 | (state->src_y >> 16), |
| 3014 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3015 | (state->src_w >> 16), |
| 3016 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3017 | (state->src_h >> 16), |
| 3018 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3019 | format_name.str, |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3020 | rot_str); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3021 | } |
| 3022 | } |
| 3023 | |
| 3024 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3025 | { |
| 3026 | struct intel_crtc_state *pipe_config; |
| 3027 | int num_scalers = intel_crtc->num_scalers; |
| 3028 | int i; |
| 3029 | |
| 3030 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3031 | |
| 3032 | /* Not all platformas have a scaler */ |
| 3033 | if (num_scalers) { |
| 3034 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3035 | num_scalers, |
| 3036 | pipe_config->scaler_state.scaler_users, |
| 3037 | pipe_config->scaler_state.scaler_id); |
| 3038 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3039 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3040 | struct intel_scaler *sc = |
| 3041 | &pipe_config->scaler_state.scalers[i]; |
| 3042 | |
| 3043 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3044 | i, yesno(sc->in_use), sc->mode); |
| 3045 | } |
| 3046 | seq_puts(m, "\n"); |
| 3047 | } else { |
| 3048 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3049 | } |
| 3050 | } |
| 3051 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3052 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3053 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3054 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3055 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3056 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3057 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3058 | struct drm_connector_list_iter conn_iter; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3059 | intel_wakeref_t wakeref; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3060 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3061 | wakeref = intel_runtime_pm_get(dev_priv); |
| 3062 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3063 | seq_printf(m, "CRTC info\n"); |
| 3064 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3065 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3066 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3067 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3068 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3069 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3070 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3071 | seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n", |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3072 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3073 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3074 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3075 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3076 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3077 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3078 | struct intel_plane *cursor = |
| 3079 | to_intel_plane(crtc->base.cursor); |
| 3080 | |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3081 | intel_crtc_info(m, crtc); |
| 3082 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3083 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3084 | yesno(cursor->base.state->visible), |
| 3085 | cursor->base.state->crtc_x, |
| 3086 | cursor->base.state->crtc_y, |
| 3087 | cursor->base.state->crtc_w, |
| 3088 | cursor->base.state->crtc_h, |
| 3089 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3090 | intel_scaler_info(m, crtc); |
| 3091 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3092 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3093 | |
| 3094 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3095 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3096 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3097 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3098 | } |
| 3099 | |
| 3100 | seq_printf(m, "\n"); |
| 3101 | seq_printf(m, "Connector info\n"); |
| 3102 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3103 | mutex_lock(&dev->mode_config.mutex); |
| 3104 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3105 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3106 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3107 | drm_connector_list_iter_end(&conn_iter); |
| 3108 | mutex_unlock(&dev->mode_config.mutex); |
| 3109 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3110 | intel_runtime_pm_put(dev_priv, wakeref); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3111 | |
| 3112 | return 0; |
| 3113 | } |
| 3114 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3115 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3116 | { |
| 3117 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3118 | struct intel_engine_cs *engine; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3119 | intel_wakeref_t wakeref; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3120 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3121 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3122 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3123 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3124 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 3125 | seq_printf(m, "GT awake? %s (epoch %u)\n", |
| 3126 | yesno(dev_priv->gt.awake), dev_priv->gt.epoch); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3127 | seq_printf(m, "Global active requests: %d\n", |
| 3128 | dev_priv->gt.active_requests); |
Lionel Landwerlin | f577a03 | 2017-11-13 23:34:53 +0000 | [diff] [blame] | 3129 | seq_printf(m, "CS timestamp frequency: %u kHz\n", |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3130 | RUNTIME_INFO(dev_priv)->cs_timestamp_frequency_khz); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3131 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3132 | p = drm_seq_file_printer(m); |
| 3133 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 0db18b1 | 2017-12-08 01:23:00 +0000 | [diff] [blame] | 3134 | intel_engine_dump(engine, &p, "%s\n", engine->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3135 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3136 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3137 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3138 | return 0; |
| 3139 | } |
| 3140 | |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3141 | static int i915_rcs_topology(struct seq_file *m, void *unused) |
| 3142 | { |
| 3143 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3144 | struct drm_printer p = drm_seq_file_printer(m); |
| 3145 | |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3146 | intel_device_info_dump_topology(&RUNTIME_INFO(dev_priv)->sseu, &p); |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3147 | |
| 3148 | return 0; |
| 3149 | } |
| 3150 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3151 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3152 | { |
| 3153 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3154 | |
| 3155 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3156 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3157 | |
| 3158 | return 0; |
| 3159 | } |
| 3160 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3161 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3162 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3163 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3164 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3165 | int i; |
| 3166 | |
| 3167 | drm_modeset_lock_all(dev); |
| 3168 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3169 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3170 | |
Lucas De Marchi | 72f775f | 2018-03-20 15:06:34 -0700 | [diff] [blame] | 3171 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->info->name, |
Lucas De Marchi | 0823eb9 | 2018-03-20 15:06:35 -0700 | [diff] [blame] | 3172 | pll->info->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3173 | 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] | 3174 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3175 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3176 | 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] | 3177 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3178 | pll->state.hw_state.dpll_md); |
| 3179 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3180 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3181 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Paulo Zanoni | c27e917 | 2018-04-27 16:14:36 -0700 | [diff] [blame] | 3182 | seq_printf(m, " cfgcr0: 0x%08x\n", pll->state.hw_state.cfgcr0); |
| 3183 | seq_printf(m, " cfgcr1: 0x%08x\n", pll->state.hw_state.cfgcr1); |
| 3184 | seq_printf(m, " mg_refclkin_ctl: 0x%08x\n", |
| 3185 | pll->state.hw_state.mg_refclkin_ctl); |
| 3186 | seq_printf(m, " mg_clktop2_coreclkctl1: 0x%08x\n", |
| 3187 | pll->state.hw_state.mg_clktop2_coreclkctl1); |
| 3188 | seq_printf(m, " mg_clktop2_hsclkctl: 0x%08x\n", |
| 3189 | pll->state.hw_state.mg_clktop2_hsclkctl); |
| 3190 | seq_printf(m, " mg_pll_div0: 0x%08x\n", |
| 3191 | pll->state.hw_state.mg_pll_div0); |
| 3192 | seq_printf(m, " mg_pll_div1: 0x%08x\n", |
| 3193 | pll->state.hw_state.mg_pll_div1); |
| 3194 | seq_printf(m, " mg_pll_lf: 0x%08x\n", |
| 3195 | pll->state.hw_state.mg_pll_lf); |
| 3196 | seq_printf(m, " mg_pll_frac_lock: 0x%08x\n", |
| 3197 | pll->state.hw_state.mg_pll_frac_lock); |
| 3198 | seq_printf(m, " mg_pll_ssc: 0x%08x\n", |
| 3199 | pll->state.hw_state.mg_pll_ssc); |
| 3200 | seq_printf(m, " mg_pll_bias: 0x%08x\n", |
| 3201 | pll->state.hw_state.mg_pll_bias); |
| 3202 | seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", |
| 3203 | pll->state.hw_state.mg_pll_tdc_coldst_bias); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3204 | } |
| 3205 | drm_modeset_unlock_all(dev); |
| 3206 | |
| 3207 | return 0; |
| 3208 | } |
| 3209 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3210 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3211 | { |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3212 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3213 | const struct i915_wa_list *wal = &i915->engine[RCS]->ctx_wa_list; |
| 3214 | struct i915_wa *wa; |
| 3215 | unsigned int i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3216 | |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3217 | seq_printf(m, "Workarounds applied: %u\n", wal->count); |
| 3218 | for (i = 0, wa = wal->list; i < wal->count; i++, wa++) |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3219 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n", |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3220 | i915_mmio_reg_offset(wa->reg), wa->val, wa->mask); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3221 | |
| 3222 | return 0; |
| 3223 | } |
| 3224 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3225 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3226 | { |
| 3227 | struct drm_i915_private *dev_priv = m->private; |
| 3228 | |
| 3229 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3230 | yesno(dev_priv->ipc_enabled)); |
| 3231 | return 0; |
| 3232 | } |
| 3233 | |
| 3234 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3235 | { |
| 3236 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3237 | |
| 3238 | if (!HAS_IPC(dev_priv)) |
| 3239 | return -ENODEV; |
| 3240 | |
| 3241 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3242 | } |
| 3243 | |
| 3244 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3245 | size_t len, loff_t *offp) |
| 3246 | { |
| 3247 | struct seq_file *m = file->private_data; |
| 3248 | struct drm_i915_private *dev_priv = m->private; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3249 | intel_wakeref_t wakeref; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3250 | bool enable; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3251 | int ret; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3252 | |
| 3253 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3254 | if (ret < 0) |
| 3255 | return ret; |
| 3256 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3257 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3258 | if (!dev_priv->ipc_enabled && enable) |
| 3259 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3260 | dev_priv->wm.distrust_bios_wm = true; |
| 3261 | dev_priv->ipc_enabled = enable; |
| 3262 | intel_enable_ipc(dev_priv); |
| 3263 | } |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3264 | |
| 3265 | return len; |
| 3266 | } |
| 3267 | |
| 3268 | static const struct file_operations i915_ipc_status_fops = { |
| 3269 | .owner = THIS_MODULE, |
| 3270 | .open = i915_ipc_status_open, |
| 3271 | .read = seq_read, |
| 3272 | .llseek = seq_lseek, |
| 3273 | .release = single_release, |
| 3274 | .write = i915_ipc_status_write |
| 3275 | }; |
| 3276 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3277 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3278 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3279 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3280 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3281 | struct skl_ddb_entry *entry; |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3282 | struct intel_crtc *crtc; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3283 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3284 | if (INTEL_GEN(dev_priv) < 9) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 3285 | return -ENODEV; |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3286 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3287 | drm_modeset_lock_all(dev); |
| 3288 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3289 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3290 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3291 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
| 3292 | struct intel_crtc_state *crtc_state = |
| 3293 | to_intel_crtc_state(crtc->base.state); |
| 3294 | enum pipe pipe = crtc->pipe; |
| 3295 | enum plane_id plane_id; |
| 3296 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3297 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3298 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3299 | for_each_plane_id_on_crtc(crtc, plane_id) { |
| 3300 | entry = &crtc_state->wm.skl.plane_ddb_y[plane_id]; |
| 3301 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane_id + 1, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3302 | entry->start, entry->end, |
| 3303 | skl_ddb_entry_size(entry)); |
| 3304 | } |
| 3305 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3306 | entry = &crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3307 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3308 | entry->end, skl_ddb_entry_size(entry)); |
| 3309 | } |
| 3310 | |
| 3311 | drm_modeset_unlock_all(dev); |
| 3312 | |
| 3313 | return 0; |
| 3314 | } |
| 3315 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3316 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3317 | struct drm_device *dev, |
| 3318 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3319 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3320 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3321 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3322 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3323 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3324 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3325 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3326 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3327 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3328 | if (connector->state->crtc != &intel_crtc->base) |
| 3329 | continue; |
| 3330 | |
| 3331 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3332 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3333 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3334 | |
| 3335 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3336 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3337 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3338 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3339 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3340 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3341 | else |
| 3342 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3343 | |
| 3344 | seq_puts(m, "\n\n"); |
| 3345 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3346 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3347 | struct intel_panel *panel; |
| 3348 | |
| 3349 | mutex_lock(&drrs->mutex); |
| 3350 | /* DRRS Supported */ |
| 3351 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3352 | |
| 3353 | /* disable_drrs() will make drrs->dp NULL */ |
| 3354 | if (!drrs->dp) { |
C, Ramalingam | ce6e213 | 2017-11-20 09:53:47 +0530 | [diff] [blame] | 3355 | seq_puts(m, "Idleness DRRS: Disabled\n"); |
| 3356 | if (dev_priv->psr.enabled) |
| 3357 | seq_puts(m, |
| 3358 | "\tAs PSR is enabled, DRRS is not enabled\n"); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3359 | mutex_unlock(&drrs->mutex); |
| 3360 | return; |
| 3361 | } |
| 3362 | |
| 3363 | panel = &drrs->dp->attached_connector->panel; |
| 3364 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3365 | drrs->busy_frontbuffer_bits); |
| 3366 | |
| 3367 | seq_puts(m, "\n\t\t"); |
| 3368 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3369 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3370 | vrefresh = panel->fixed_mode->vrefresh; |
| 3371 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3372 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3373 | vrefresh = panel->downclock_mode->vrefresh; |
| 3374 | } else { |
| 3375 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3376 | drrs->refresh_rate_type); |
| 3377 | mutex_unlock(&drrs->mutex); |
| 3378 | return; |
| 3379 | } |
| 3380 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3381 | |
| 3382 | seq_puts(m, "\n\t\t"); |
| 3383 | mutex_unlock(&drrs->mutex); |
| 3384 | } else { |
| 3385 | /* DRRS not supported. Print the VBT parameter*/ |
| 3386 | seq_puts(m, "\tDRRS Supported : No"); |
| 3387 | } |
| 3388 | seq_puts(m, "\n"); |
| 3389 | } |
| 3390 | |
| 3391 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3392 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3393 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3394 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3395 | struct intel_crtc *intel_crtc; |
| 3396 | int active_crtc_cnt = 0; |
| 3397 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3398 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3399 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3400 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3401 | active_crtc_cnt++; |
| 3402 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3403 | |
| 3404 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3405 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3406 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3407 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3408 | |
| 3409 | if (!active_crtc_cnt) |
| 3410 | seq_puts(m, "No active crtc found\n"); |
| 3411 | |
| 3412 | return 0; |
| 3413 | } |
| 3414 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3415 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3416 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3417 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3418 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3419 | struct intel_encoder *intel_encoder; |
| 3420 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3421 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3422 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3423 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3424 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3425 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3426 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3427 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3428 | |
| 3429 | intel_encoder = intel_attached_encoder(connector); |
| 3430 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3431 | continue; |
| 3432 | |
| 3433 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3434 | if (!intel_dig_port->dp.can_mst) |
| 3435 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3436 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3437 | seq_printf(m, "MST Source Port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3438 | port_name(intel_dig_port->base.port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3439 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3440 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3441 | drm_connector_list_iter_end(&conn_iter); |
| 3442 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3443 | return 0; |
| 3444 | } |
| 3445 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3446 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3447 | const char __user *ubuf, |
| 3448 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3449 | { |
| 3450 | char *input_buffer; |
| 3451 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3452 | struct drm_device *dev; |
| 3453 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3454 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3455 | struct intel_dp *intel_dp; |
| 3456 | int val = 0; |
| 3457 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3458 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3459 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3460 | if (len == 0) |
| 3461 | return 0; |
| 3462 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3463 | input_buffer = memdup_user_nul(ubuf, len); |
| 3464 | if (IS_ERR(input_buffer)) |
| 3465 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3466 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3467 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3468 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3469 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3470 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3471 | struct intel_encoder *encoder; |
| 3472 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3473 | if (connector->connector_type != |
| 3474 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3475 | continue; |
| 3476 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3477 | encoder = to_intel_encoder(connector->encoder); |
| 3478 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3479 | continue; |
| 3480 | |
| 3481 | if (encoder && connector->status == connector_status_connected) { |
| 3482 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3483 | status = kstrtoint(input_buffer, 10, &val); |
| 3484 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3485 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3486 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3487 | /* To prevent erroneous activation of the compliance |
| 3488 | * testing code, only accept an actual value of 1 here |
| 3489 | */ |
| 3490 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3491 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3492 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3493 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3494 | } |
| 3495 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3496 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3497 | kfree(input_buffer); |
| 3498 | if (status < 0) |
| 3499 | return status; |
| 3500 | |
| 3501 | *offp += len; |
| 3502 | return len; |
| 3503 | } |
| 3504 | |
| 3505 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3506 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3507 | struct drm_i915_private *dev_priv = m->private; |
| 3508 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3509 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3510 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3511 | struct intel_dp *intel_dp; |
| 3512 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3513 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3514 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3515 | struct intel_encoder *encoder; |
| 3516 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3517 | if (connector->connector_type != |
| 3518 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3519 | continue; |
| 3520 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3521 | encoder = to_intel_encoder(connector->encoder); |
| 3522 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3523 | continue; |
| 3524 | |
| 3525 | if (encoder && connector->status == connector_status_connected) { |
| 3526 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3527 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3528 | seq_puts(m, "1"); |
| 3529 | else |
| 3530 | seq_puts(m, "0"); |
| 3531 | } else |
| 3532 | seq_puts(m, "0"); |
| 3533 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3534 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3535 | |
| 3536 | return 0; |
| 3537 | } |
| 3538 | |
| 3539 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3540 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3541 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3542 | return single_open(file, i915_displayport_test_active_show, |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3543 | inode->i_private); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3544 | } |
| 3545 | |
| 3546 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3547 | .owner = THIS_MODULE, |
| 3548 | .open = i915_displayport_test_active_open, |
| 3549 | .read = seq_read, |
| 3550 | .llseek = seq_lseek, |
| 3551 | .release = single_release, |
| 3552 | .write = i915_displayport_test_active_write |
| 3553 | }; |
| 3554 | |
| 3555 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3556 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3557 | struct drm_i915_private *dev_priv = m->private; |
| 3558 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3559 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3560 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3561 | struct intel_dp *intel_dp; |
| 3562 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3563 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3564 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3565 | struct intel_encoder *encoder; |
| 3566 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3567 | if (connector->connector_type != |
| 3568 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3569 | continue; |
| 3570 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3571 | encoder = to_intel_encoder(connector->encoder); |
| 3572 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3573 | continue; |
| 3574 | |
| 3575 | if (encoder && connector->status == connector_status_connected) { |
| 3576 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3577 | if (intel_dp->compliance.test_type == |
| 3578 | DP_TEST_LINK_EDID_READ) |
| 3579 | seq_printf(m, "%lx", |
| 3580 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3581 | else if (intel_dp->compliance.test_type == |
| 3582 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3583 | seq_printf(m, "hdisplay: %d\n", |
| 3584 | intel_dp->compliance.test_data.hdisplay); |
| 3585 | seq_printf(m, "vdisplay: %d\n", |
| 3586 | intel_dp->compliance.test_data.vdisplay); |
| 3587 | seq_printf(m, "bpc: %u\n", |
| 3588 | intel_dp->compliance.test_data.bpc); |
| 3589 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3590 | } else |
| 3591 | seq_puts(m, "0"); |
| 3592 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3593 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3594 | |
| 3595 | return 0; |
| 3596 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3597 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3598 | |
| 3599 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3600 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3601 | struct drm_i915_private *dev_priv = m->private; |
| 3602 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3603 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3604 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3605 | struct intel_dp *intel_dp; |
| 3606 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3607 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3608 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3609 | struct intel_encoder *encoder; |
| 3610 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3611 | if (connector->connector_type != |
| 3612 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3613 | continue; |
| 3614 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3615 | encoder = to_intel_encoder(connector->encoder); |
| 3616 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3617 | continue; |
| 3618 | |
| 3619 | if (encoder && connector->status == connector_status_connected) { |
| 3620 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3621 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3622 | } else |
| 3623 | seq_puts(m, "0"); |
| 3624 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3625 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3626 | |
| 3627 | return 0; |
| 3628 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3629 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3630 | |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3631 | static void wm_latency_show(struct seq_file *m, const u16 wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3632 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3633 | struct drm_i915_private *dev_priv = m->private; |
| 3634 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3635 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3636 | int num_levels; |
| 3637 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3638 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3639 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3640 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3641 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3642 | else if (IS_G4X(dev_priv)) |
| 3643 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3644 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3645 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3646 | |
| 3647 | drm_modeset_lock_all(dev); |
| 3648 | |
| 3649 | for (level = 0; level < num_levels; level++) { |
| 3650 | unsigned int latency = wm[level]; |
| 3651 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3652 | /* |
| 3653 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3654 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3655 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3656 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3657 | IS_VALLEYVIEW(dev_priv) || |
| 3658 | IS_CHERRYVIEW(dev_priv) || |
| 3659 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3660 | latency *= 10; |
| 3661 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3662 | latency *= 5; |
| 3663 | |
| 3664 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3665 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3666 | } |
| 3667 | |
| 3668 | drm_modeset_unlock_all(dev); |
| 3669 | } |
| 3670 | |
| 3671 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3672 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3673 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3674 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3675 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3676 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3677 | latencies = dev_priv->wm.skl_latency; |
| 3678 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3679 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3680 | |
| 3681 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3682 | |
| 3683 | return 0; |
| 3684 | } |
| 3685 | |
| 3686 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3687 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3688 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3689 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3690 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3691 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3692 | latencies = dev_priv->wm.skl_latency; |
| 3693 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3694 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3695 | |
| 3696 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3697 | |
| 3698 | return 0; |
| 3699 | } |
| 3700 | |
| 3701 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3702 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3703 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3704 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3705 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3706 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3707 | latencies = dev_priv->wm.skl_latency; |
| 3708 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3709 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3710 | |
| 3711 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3712 | |
| 3713 | return 0; |
| 3714 | } |
| 3715 | |
| 3716 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3717 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3718 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3719 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3720 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3721 | return -ENODEV; |
| 3722 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3723 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3724 | } |
| 3725 | |
| 3726 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3727 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3728 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3729 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3730 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3731 | return -ENODEV; |
| 3732 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3733 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3734 | } |
| 3735 | |
| 3736 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3737 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3738 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3739 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3740 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3741 | return -ENODEV; |
| 3742 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3743 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3744 | } |
| 3745 | |
| 3746 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3747 | size_t len, loff_t *offp, u16 wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3748 | { |
| 3749 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3750 | struct drm_i915_private *dev_priv = m->private; |
| 3751 | struct drm_device *dev = &dev_priv->drm; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3752 | u16 new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3753 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3754 | int level; |
| 3755 | int ret; |
| 3756 | char tmp[32]; |
| 3757 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3758 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3759 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3760 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3761 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3762 | else if (IS_G4X(dev_priv)) |
| 3763 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3764 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3765 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3766 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3767 | if (len >= sizeof(tmp)) |
| 3768 | return -EINVAL; |
| 3769 | |
| 3770 | if (copy_from_user(tmp, ubuf, len)) |
| 3771 | return -EFAULT; |
| 3772 | |
| 3773 | tmp[len] = '\0'; |
| 3774 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3775 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3776 | &new[0], &new[1], &new[2], &new[3], |
| 3777 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3778 | if (ret != num_levels) |
| 3779 | return -EINVAL; |
| 3780 | |
| 3781 | drm_modeset_lock_all(dev); |
| 3782 | |
| 3783 | for (level = 0; level < num_levels; level++) |
| 3784 | wm[level] = new[level]; |
| 3785 | |
| 3786 | drm_modeset_unlock_all(dev); |
| 3787 | |
| 3788 | return len; |
| 3789 | } |
| 3790 | |
| 3791 | |
| 3792 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3793 | size_t len, loff_t *offp) |
| 3794 | { |
| 3795 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3796 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3797 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3798 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3799 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3800 | latencies = dev_priv->wm.skl_latency; |
| 3801 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3802 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3803 | |
| 3804 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3805 | } |
| 3806 | |
| 3807 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3808 | size_t len, loff_t *offp) |
| 3809 | { |
| 3810 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3811 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3812 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3813 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3814 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3815 | latencies = dev_priv->wm.skl_latency; |
| 3816 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3817 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3818 | |
| 3819 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3820 | } |
| 3821 | |
| 3822 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3823 | size_t len, loff_t *offp) |
| 3824 | { |
| 3825 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3826 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3827 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3828 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3829 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3830 | latencies = dev_priv->wm.skl_latency; |
| 3831 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3832 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3833 | |
| 3834 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3835 | } |
| 3836 | |
| 3837 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3838 | .owner = THIS_MODULE, |
| 3839 | .open = pri_wm_latency_open, |
| 3840 | .read = seq_read, |
| 3841 | .llseek = seq_lseek, |
| 3842 | .release = single_release, |
| 3843 | .write = pri_wm_latency_write |
| 3844 | }; |
| 3845 | |
| 3846 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3847 | .owner = THIS_MODULE, |
| 3848 | .open = spr_wm_latency_open, |
| 3849 | .read = seq_read, |
| 3850 | .llseek = seq_lseek, |
| 3851 | .release = single_release, |
| 3852 | .write = spr_wm_latency_write |
| 3853 | }; |
| 3854 | |
| 3855 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3856 | .owner = THIS_MODULE, |
| 3857 | .open = cur_wm_latency_open, |
| 3858 | .read = seq_read, |
| 3859 | .llseek = seq_lseek, |
| 3860 | .release = single_release, |
| 3861 | .write = cur_wm_latency_write |
| 3862 | }; |
| 3863 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3864 | static int |
| 3865 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3866 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3867 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3868 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 3869 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3870 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3871 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3872 | } |
| 3873 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3874 | static int |
| 3875 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3876 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3877 | struct drm_i915_private *i915 = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3878 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3879 | /* |
| 3880 | * There is no safeguard against this debugfs entry colliding |
| 3881 | * with the hangcheck calling same i915_handle_error() in |
| 3882 | * parallel, causing an explosion. For now we assume that the |
| 3883 | * test harness is responsible enough not to inject gpu hangs |
| 3884 | * while it is writing to 'i915_wedged' |
| 3885 | */ |
| 3886 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3887 | if (i915_reset_backoff(&i915->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3888 | return -EAGAIN; |
| 3889 | |
Chris Wilson | ce80075 | 2018-03-20 10:04:49 +0000 | [diff] [blame] | 3890 | i915_handle_error(i915, val, I915_ERROR_CAPTURE, |
| 3891 | "Manually set wedged engine mask = %llx", val); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3892 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3893 | } |
| 3894 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3895 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3896 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3897 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3898 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3899 | #define DROP_UNBOUND BIT(0) |
| 3900 | #define DROP_BOUND BIT(1) |
| 3901 | #define DROP_RETIRE BIT(2) |
| 3902 | #define DROP_ACTIVE BIT(3) |
| 3903 | #define DROP_FREED BIT(4) |
| 3904 | #define DROP_SHRINK_ALL BIT(5) |
| 3905 | #define DROP_IDLE BIT(6) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3906 | #define DROP_RESET_ACTIVE BIT(7) |
| 3907 | #define DROP_RESET_SEQNO BIT(8) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 3908 | #define DROP_ALL (DROP_UNBOUND | \ |
| 3909 | DROP_BOUND | \ |
| 3910 | DROP_RETIRE | \ |
| 3911 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3912 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3913 | DROP_SHRINK_ALL |\ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3914 | DROP_IDLE | \ |
| 3915 | DROP_RESET_ACTIVE | \ |
| 3916 | DROP_RESET_SEQNO) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3917 | static int |
| 3918 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3919 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3920 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3921 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3922 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3923 | } |
| 3924 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3925 | static int |
| 3926 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3927 | { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3928 | struct drm_i915_private *i915 = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3929 | intel_wakeref_t wakeref; |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3930 | int ret = 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3931 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3932 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 3933 | val, val & DROP_ALL); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3934 | wakeref = intel_runtime_pm_get(i915); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3935 | |
Chris Wilson | ad4062d | 2019-01-28 01:02:18 +0000 | [diff] [blame] | 3936 | if (val & DROP_RESET_ACTIVE && |
| 3937 | wait_for(intel_engines_are_idle(i915), I915_IDLE_ENGINES_TIMEOUT)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3938 | i915_gem_set_wedged(i915); |
| 3939 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3940 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 3941 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3942 | if (val & (DROP_ACTIVE | DROP_RETIRE | DROP_RESET_SEQNO)) { |
| 3943 | ret = mutex_lock_interruptible(&i915->drm.struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3944 | if (ret) |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 3945 | goto out; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3946 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3947 | if (val & DROP_ACTIVE) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3948 | ret = i915_gem_wait_for_idle(i915, |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3949 | I915_WAIT_INTERRUPTIBLE | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 3950 | I915_WAIT_LOCKED, |
| 3951 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3952 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3953 | if (val & DROP_RETIRE) |
| 3954 | i915_retire_requests(i915); |
| 3955 | |
| 3956 | mutex_unlock(&i915->drm.struct_mutex); |
| 3957 | } |
| 3958 | |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame] | 3959 | if (val & DROP_RESET_ACTIVE && i915_terminally_wedged(&i915->gpu_error)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3960 | i915_handle_error(i915, ALL_ENGINES, 0, NULL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3961 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 3962 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3963 | if (val & DROP_BOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3964 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 3965 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3966 | if (val & DROP_UNBOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3967 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3968 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3969 | if (val & DROP_SHRINK_ALL) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3970 | i915_gem_shrink_all(i915); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 3971 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3972 | |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 3973 | if (val & DROP_IDLE) { |
| 3974 | do { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3975 | if (READ_ONCE(i915->gt.active_requests)) |
| 3976 | flush_delayed_work(&i915->gt.retire_work); |
| 3977 | drain_delayed_work(&i915->gt.idle_work); |
| 3978 | } while (READ_ONCE(i915->gt.awake)); |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 3979 | } |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3980 | |
Chris Wilson | c9c70471 | 2018-02-19 22:06:31 +0000 | [diff] [blame] | 3981 | if (val & DROP_FREED) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3982 | i915_gem_drain_freed_objects(i915); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 3983 | |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 3984 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3985 | intel_runtime_pm_put(i915, wakeref); |
Chris Wilson | 9d3eb2c | 2018-10-15 12:58:56 +0100 | [diff] [blame] | 3986 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3987 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3988 | } |
| 3989 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3990 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 3991 | i915_drop_caches_get, i915_drop_caches_set, |
| 3992 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3993 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3994 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3995 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3996 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3997 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3998 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3999 | u32 snpcr = 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4000 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 4001 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4002 | return -ENODEV; |
| 4003 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4004 | with_intel_runtime_pm(dev_priv, wakeref) |
| 4005 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4006 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4007 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4008 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4009 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4010 | } |
| 4011 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4012 | static int |
| 4013 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4014 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4015 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4016 | intel_wakeref_t wakeref; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4017 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 4018 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4019 | return -ENODEV; |
| 4020 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4021 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4022 | return -EINVAL; |
| 4023 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4024 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4025 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4026 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4027 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4028 | /* Update the cache sharing policy here as well */ |
| 4029 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4030 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4031 | snpcr |= val << GEN6_MBC_SNPCR_SHIFT; |
| 4032 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4033 | } |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4034 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4035 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4036 | } |
| 4037 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4038 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4039 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4040 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4041 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4042 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4043 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4044 | { |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4045 | #define SS_MAX 2 |
| 4046 | const int ss_max = SS_MAX; |
| 4047 | u32 sig1[SS_MAX], sig2[SS_MAX]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4048 | int ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4049 | |
| 4050 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4051 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4052 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4053 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4054 | |
| 4055 | for (ss = 0; ss < ss_max; ss++) { |
| 4056 | unsigned int eu_cnt; |
| 4057 | |
| 4058 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4059 | /* skip disabled subslice */ |
| 4060 | continue; |
| 4061 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4062 | sseu->slice_mask = BIT(0); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4063 | sseu->subslice_mask[0] |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4064 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4065 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4066 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4067 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4068 | sseu->eu_total += eu_cnt; |
| 4069 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4070 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4071 | } |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4072 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4073 | } |
| 4074 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4075 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4076 | struct sseu_dev_info *sseu) |
| 4077 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4078 | #define SS_MAX 6 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4079 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4080 | u32 s_reg[SS_MAX], eu_reg[2 * SS_MAX], eu_mask[2]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4081 | int s, ss; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4082 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4083 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4084 | /* |
| 4085 | * FIXME: Valid SS Mask respects the spec and read |
Alexandre Belloni | 3c64ea8 | 2018-11-20 16:14:15 +0100 | [diff] [blame] | 4086 | * only valid bits for those registers, excluding reserved |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4087 | * although this seems wrong because it would leave many |
| 4088 | * subslices without ACK. |
| 4089 | */ |
| 4090 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4091 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4092 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4093 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4094 | } |
| 4095 | |
| 4096 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4097 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4098 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4099 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4100 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4101 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4102 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4103 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4104 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4105 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4106 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4107 | /* skip disabled slice */ |
| 4108 | continue; |
| 4109 | |
| 4110 | sseu->slice_mask |= BIT(s); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4111 | sseu->subslice_mask[s] = info->sseu.subslice_mask[s]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4112 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4113 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4114 | unsigned int eu_cnt; |
| 4115 | |
| 4116 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4117 | /* skip disabled subslice */ |
| 4118 | continue; |
| 4119 | |
| 4120 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4121 | eu_mask[ss % 2]); |
| 4122 | sseu->eu_total += eu_cnt; |
| 4123 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4124 | sseu->eu_per_subslice, |
| 4125 | eu_cnt); |
| 4126 | } |
| 4127 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4128 | #undef SS_MAX |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4129 | } |
| 4130 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4131 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4132 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4133 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4134 | #define SS_MAX 3 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4135 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4136 | u32 s_reg[SS_MAX], eu_reg[2 * SS_MAX], eu_mask[2]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4137 | int s, ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4138 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4139 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4140 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4141 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4142 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4143 | } |
| 4144 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4145 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4146 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4147 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4148 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4149 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4150 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4151 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4152 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4153 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4154 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4155 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4156 | /* skip disabled slice */ |
| 4157 | continue; |
| 4158 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4159 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4160 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4161 | if (IS_GEN9_BC(dev_priv)) |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4162 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4163 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4164 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4165 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4166 | unsigned int eu_cnt; |
| 4167 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4168 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4169 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4170 | /* skip disabled subslice */ |
| 4171 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4172 | |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4173 | sseu->subslice_mask[s] |= BIT(ss); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4174 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4175 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4176 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4177 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4178 | sseu->eu_total += eu_cnt; |
| 4179 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4180 | sseu->eu_per_subslice, |
| 4181 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4182 | } |
| 4183 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4184 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4185 | } |
| 4186 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4187 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4188 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4189 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4190 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4191 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4192 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4193 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4194 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4195 | if (sseu->slice_mask) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4196 | sseu->eu_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4197 | RUNTIME_INFO(dev_priv)->sseu.eu_per_subslice; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4198 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4199 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4200 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4201 | } |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4202 | sseu->eu_total = sseu->eu_per_subslice * |
| 4203 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4204 | |
| 4205 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4206 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4207 | u8 subslice_7eu = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4208 | RUNTIME_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4209 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4210 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4211 | } |
| 4212 | } |
| 4213 | } |
| 4214 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4215 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4216 | const struct sseu_dev_info *sseu) |
| 4217 | { |
| 4218 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4219 | const char *type = is_available_info ? "Available" : "Enabled"; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4220 | int s; |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4221 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4222 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4223 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4224 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4225 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4226 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4227 | sseu_subslice_total(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4228 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4229 | seq_printf(m, " %s Slice%i subslices: %u\n", type, |
| 4230 | s, hweight8(sseu->subslice_mask[s])); |
| 4231 | } |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4232 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4233 | sseu->eu_total); |
| 4234 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4235 | sseu->eu_per_subslice); |
| 4236 | |
| 4237 | if (!is_available_info) |
| 4238 | return; |
| 4239 | |
| 4240 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4241 | if (HAS_POOLED_EU(dev_priv)) |
| 4242 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4243 | |
| 4244 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4245 | yesno(sseu->has_slice_pg)); |
| 4246 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4247 | yesno(sseu->has_subslice_pg)); |
| 4248 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4249 | yesno(sseu->has_eu_pg)); |
| 4250 | } |
| 4251 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4252 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4253 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4254 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4255 | struct sseu_dev_info sseu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4256 | intel_wakeref_t wakeref; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4257 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4258 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4259 | return -ENODEV; |
| 4260 | |
| 4261 | seq_puts(m, "SSEU Device Info\n"); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4262 | i915_print_sseu_info(m, true, &RUNTIME_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4263 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4264 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4265 | memset(&sseu, 0, sizeof(sseu)); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4266 | sseu.max_slices = RUNTIME_INFO(dev_priv)->sseu.max_slices; |
| 4267 | sseu.max_subslices = RUNTIME_INFO(dev_priv)->sseu.max_subslices; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4268 | sseu.max_eus_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4269 | RUNTIME_INFO(dev_priv)->sseu.max_eus_per_subslice; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4270 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4271 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4272 | if (IS_CHERRYVIEW(dev_priv)) |
| 4273 | cherryview_sseu_device_status(dev_priv, &sseu); |
| 4274 | else if (IS_BROADWELL(dev_priv)) |
| 4275 | broadwell_sseu_device_status(dev_priv, &sseu); |
| 4276 | else if (IS_GEN(dev_priv, 9)) |
| 4277 | gen9_sseu_device_status(dev_priv, &sseu); |
| 4278 | else if (INTEL_GEN(dev_priv) >= 10) |
| 4279 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4280 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4281 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4282 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4283 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4284 | return 0; |
| 4285 | } |
| 4286 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4287 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4288 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4289 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4290 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4291 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4292 | return 0; |
| 4293 | |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4294 | file->private_data = (void *)(uintptr_t)intel_runtime_pm_get(i915); |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4295 | intel_uncore_forcewake_user_get(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4296 | |
| 4297 | return 0; |
| 4298 | } |
| 4299 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4300 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4301 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4302 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4303 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4304 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4305 | return 0; |
| 4306 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4307 | intel_uncore_forcewake_user_put(i915); |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4308 | intel_runtime_pm_put(i915, |
| 4309 | (intel_wakeref_t)(uintptr_t)file->private_data); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4310 | |
| 4311 | return 0; |
| 4312 | } |
| 4313 | |
| 4314 | static const struct file_operations i915_forcewake_fops = { |
| 4315 | .owner = THIS_MODULE, |
| 4316 | .open = i915_forcewake_open, |
| 4317 | .release = i915_forcewake_release, |
| 4318 | }; |
| 4319 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4320 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4321 | { |
| 4322 | struct drm_i915_private *dev_priv = m->private; |
| 4323 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4324 | |
Lyude Paul | 6fc5d78 | 2018-11-20 19:37:17 -0500 | [diff] [blame] | 4325 | /* Synchronize with everything first in case there's been an HPD |
| 4326 | * storm, but we haven't finished handling it in the kernel yet |
| 4327 | */ |
| 4328 | synchronize_irq(dev_priv->drm.irq); |
| 4329 | flush_work(&dev_priv->hotplug.dig_port_work); |
| 4330 | flush_work(&dev_priv->hotplug.hotplug_work); |
| 4331 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4332 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4333 | seq_printf(m, "Detected: %s\n", |
| 4334 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4335 | |
| 4336 | return 0; |
| 4337 | } |
| 4338 | |
| 4339 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4340 | const char __user *ubuf, size_t len, |
| 4341 | loff_t *offp) |
| 4342 | { |
| 4343 | struct seq_file *m = file->private_data; |
| 4344 | struct drm_i915_private *dev_priv = m->private; |
| 4345 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4346 | unsigned int new_threshold; |
| 4347 | int i; |
| 4348 | char *newline; |
| 4349 | char tmp[16]; |
| 4350 | |
| 4351 | if (len >= sizeof(tmp)) |
| 4352 | return -EINVAL; |
| 4353 | |
| 4354 | if (copy_from_user(tmp, ubuf, len)) |
| 4355 | return -EFAULT; |
| 4356 | |
| 4357 | tmp[len] = '\0'; |
| 4358 | |
| 4359 | /* Strip newline, if any */ |
| 4360 | newline = strchr(tmp, '\n'); |
| 4361 | if (newline) |
| 4362 | *newline = '\0'; |
| 4363 | |
| 4364 | if (strcmp(tmp, "reset") == 0) |
| 4365 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4366 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4367 | return -EINVAL; |
| 4368 | |
| 4369 | if (new_threshold > 0) |
| 4370 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4371 | new_threshold); |
| 4372 | else |
| 4373 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4374 | |
| 4375 | spin_lock_irq(&dev_priv->irq_lock); |
| 4376 | hotplug->hpd_storm_threshold = new_threshold; |
| 4377 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4378 | for_each_hpd_pin(i) |
| 4379 | hotplug->stats[i].count = 0; |
| 4380 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4381 | |
| 4382 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4383 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4384 | |
| 4385 | return len; |
| 4386 | } |
| 4387 | |
| 4388 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4389 | { |
| 4390 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4391 | } |
| 4392 | |
| 4393 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4394 | .owner = THIS_MODULE, |
| 4395 | .open = i915_hpd_storm_ctl_open, |
| 4396 | .read = seq_read, |
| 4397 | .llseek = seq_lseek, |
| 4398 | .release = single_release, |
| 4399 | .write = i915_hpd_storm_ctl_write |
| 4400 | }; |
| 4401 | |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4402 | static int i915_hpd_short_storm_ctl_show(struct seq_file *m, void *data) |
| 4403 | { |
| 4404 | struct drm_i915_private *dev_priv = m->private; |
| 4405 | |
| 4406 | seq_printf(m, "Enabled: %s\n", |
| 4407 | yesno(dev_priv->hotplug.hpd_short_storm_enabled)); |
| 4408 | |
| 4409 | return 0; |
| 4410 | } |
| 4411 | |
| 4412 | static int |
| 4413 | i915_hpd_short_storm_ctl_open(struct inode *inode, struct file *file) |
| 4414 | { |
| 4415 | return single_open(file, i915_hpd_short_storm_ctl_show, |
| 4416 | inode->i_private); |
| 4417 | } |
| 4418 | |
| 4419 | static ssize_t i915_hpd_short_storm_ctl_write(struct file *file, |
| 4420 | const char __user *ubuf, |
| 4421 | size_t len, loff_t *offp) |
| 4422 | { |
| 4423 | struct seq_file *m = file->private_data; |
| 4424 | struct drm_i915_private *dev_priv = m->private; |
| 4425 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4426 | char *newline; |
| 4427 | char tmp[16]; |
| 4428 | int i; |
| 4429 | bool new_state; |
| 4430 | |
| 4431 | if (len >= sizeof(tmp)) |
| 4432 | return -EINVAL; |
| 4433 | |
| 4434 | if (copy_from_user(tmp, ubuf, len)) |
| 4435 | return -EFAULT; |
| 4436 | |
| 4437 | tmp[len] = '\0'; |
| 4438 | |
| 4439 | /* Strip newline, if any */ |
| 4440 | newline = strchr(tmp, '\n'); |
| 4441 | if (newline) |
| 4442 | *newline = '\0'; |
| 4443 | |
| 4444 | /* Reset to the "default" state for this system */ |
| 4445 | if (strcmp(tmp, "reset") == 0) |
| 4446 | new_state = !HAS_DP_MST(dev_priv); |
| 4447 | else if (kstrtobool(tmp, &new_state) != 0) |
| 4448 | return -EINVAL; |
| 4449 | |
| 4450 | DRM_DEBUG_KMS("%sabling HPD short storm detection\n", |
| 4451 | new_state ? "En" : "Dis"); |
| 4452 | |
| 4453 | spin_lock_irq(&dev_priv->irq_lock); |
| 4454 | hotplug->hpd_short_storm_enabled = new_state; |
| 4455 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4456 | for_each_hpd_pin(i) |
| 4457 | hotplug->stats[i].count = 0; |
| 4458 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4459 | |
| 4460 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4461 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4462 | |
| 4463 | return len; |
| 4464 | } |
| 4465 | |
| 4466 | static const struct file_operations i915_hpd_short_storm_ctl_fops = { |
| 4467 | .owner = THIS_MODULE, |
| 4468 | .open = i915_hpd_short_storm_ctl_open, |
| 4469 | .read = seq_read, |
| 4470 | .llseek = seq_lseek, |
| 4471 | .release = single_release, |
| 4472 | .write = i915_hpd_short_storm_ctl_write, |
| 4473 | }; |
| 4474 | |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4475 | static int i915_drrs_ctl_set(void *data, u64 val) |
| 4476 | { |
| 4477 | struct drm_i915_private *dev_priv = data; |
| 4478 | struct drm_device *dev = &dev_priv->drm; |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4479 | struct intel_crtc *crtc; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4480 | |
| 4481 | if (INTEL_GEN(dev_priv) < 7) |
| 4482 | return -ENODEV; |
| 4483 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4484 | for_each_intel_crtc(dev, crtc) { |
| 4485 | struct drm_connector_list_iter conn_iter; |
| 4486 | struct intel_crtc_state *crtc_state; |
| 4487 | struct drm_connector *connector; |
| 4488 | struct drm_crtc_commit *commit; |
| 4489 | int ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4490 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4491 | ret = drm_modeset_lock_single_interruptible(&crtc->base.mutex); |
| 4492 | if (ret) |
| 4493 | return ret; |
| 4494 | |
| 4495 | crtc_state = to_intel_crtc_state(crtc->base.state); |
| 4496 | |
| 4497 | if (!crtc_state->base.active || |
| 4498 | !crtc_state->has_drrs) |
| 4499 | goto out; |
| 4500 | |
| 4501 | commit = crtc_state->base.commit; |
| 4502 | if (commit) { |
| 4503 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4504 | if (ret) |
| 4505 | goto out; |
| 4506 | } |
| 4507 | |
| 4508 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 4509 | drm_for_each_connector_iter(connector, &conn_iter) { |
| 4510 | struct intel_encoder *encoder; |
| 4511 | struct intel_dp *intel_dp; |
| 4512 | |
| 4513 | if (!(crtc_state->base.connector_mask & |
| 4514 | drm_connector_mask(connector))) |
| 4515 | continue; |
| 4516 | |
| 4517 | encoder = intel_attached_encoder(connector); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4518 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 4519 | continue; |
| 4520 | |
| 4521 | DRM_DEBUG_DRIVER("Manually %sabling DRRS. %llu\n", |
| 4522 | val ? "en" : "dis", val); |
| 4523 | |
| 4524 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 4525 | if (val) |
| 4526 | intel_edp_drrs_enable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4527 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4528 | else |
| 4529 | intel_edp_drrs_disable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4530 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4531 | } |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4532 | drm_connector_list_iter_end(&conn_iter); |
| 4533 | |
| 4534 | out: |
| 4535 | drm_modeset_unlock(&crtc->base.mutex); |
| 4536 | if (ret) |
| 4537 | return ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4538 | } |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4539 | |
| 4540 | return 0; |
| 4541 | } |
| 4542 | |
| 4543 | DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); |
| 4544 | |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4545 | static ssize_t |
| 4546 | i915_fifo_underrun_reset_write(struct file *filp, |
| 4547 | const char __user *ubuf, |
| 4548 | size_t cnt, loff_t *ppos) |
| 4549 | { |
| 4550 | struct drm_i915_private *dev_priv = filp->private_data; |
| 4551 | struct intel_crtc *intel_crtc; |
| 4552 | struct drm_device *dev = &dev_priv->drm; |
| 4553 | int ret; |
| 4554 | bool reset; |
| 4555 | |
| 4556 | ret = kstrtobool_from_user(ubuf, cnt, &reset); |
| 4557 | if (ret) |
| 4558 | return ret; |
| 4559 | |
| 4560 | if (!reset) |
| 4561 | return cnt; |
| 4562 | |
| 4563 | for_each_intel_crtc(dev, intel_crtc) { |
| 4564 | struct drm_crtc_commit *commit; |
| 4565 | struct intel_crtc_state *crtc_state; |
| 4566 | |
| 4567 | ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); |
| 4568 | if (ret) |
| 4569 | return ret; |
| 4570 | |
| 4571 | crtc_state = to_intel_crtc_state(intel_crtc->base.state); |
| 4572 | commit = crtc_state->base.commit; |
| 4573 | if (commit) { |
| 4574 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4575 | if (!ret) |
| 4576 | ret = wait_for_completion_interruptible(&commit->flip_done); |
| 4577 | } |
| 4578 | |
| 4579 | if (!ret && crtc_state->base.active) { |
| 4580 | DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", |
| 4581 | pipe_name(intel_crtc->pipe)); |
| 4582 | |
| 4583 | intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); |
| 4584 | } |
| 4585 | |
| 4586 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 4587 | |
| 4588 | if (ret) |
| 4589 | return ret; |
| 4590 | } |
| 4591 | |
| 4592 | ret = intel_fbc_reset_underrun(dev_priv); |
| 4593 | if (ret) |
| 4594 | return ret; |
| 4595 | |
| 4596 | return cnt; |
| 4597 | } |
| 4598 | |
| 4599 | static const struct file_operations i915_fifo_underrun_reset_ops = { |
| 4600 | .owner = THIS_MODULE, |
| 4601 | .open = simple_open, |
| 4602 | .write = i915_fifo_underrun_reset_write, |
| 4603 | .llseek = default_llseek, |
| 4604 | }; |
| 4605 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4606 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4607 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4608 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4609 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4610 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4611 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4612 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4613 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4614 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4615 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4616 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4617 | {"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] | 4618 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4619 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4620 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4621 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4622 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4623 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4624 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4625 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4626 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4627 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4628 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4629 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4630 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4631 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4632 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4633 | {"i915_context_status", i915_context_status, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4634 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4635 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4636 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4637 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4638 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4639 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4640 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4641 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4642 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4643 | {"i915_engine_info", i915_engine_info, 0}, |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 4644 | {"i915_rcs_topology", i915_rcs_topology, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4645 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4646 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4647 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4648 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4649 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4650 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4651 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4652 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4653 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4654 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4655 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4656 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4657 | const char *name; |
| 4658 | const struct file_operations *fops; |
| 4659 | } i915_debugfs_files[] = { |
| 4660 | {"i915_wedged", &i915_wedged_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4661 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4662 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4663 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4664 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4665 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4666 | #endif |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4667 | {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4668 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4669 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4670 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4671 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4672 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4673 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4674 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 4675 | {"i915_guc_log_level", &i915_guc_log_level_fops}, |
| 4676 | {"i915_guc_log_relay", &i915_guc_log_relay_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4677 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4678 | {"i915_hpd_short_storm_ctl", &i915_hpd_short_storm_ctl_fops}, |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4679 | {"i915_ipc_status", &i915_ipc_status_fops}, |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4680 | {"i915_drrs_ctl", &i915_drrs_ctl_fops}, |
| 4681 | {"i915_edp_psr_debug", &i915_edp_psr_debug_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4682 | }; |
| 4683 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4684 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4685 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4686 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4687 | struct dentry *ent; |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 4688 | int i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4689 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4690 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4691 | minor->debugfs_root, to_i915(minor->dev), |
| 4692 | &i915_forcewake_fops); |
| 4693 | if (!ent) |
| 4694 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4695 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4696 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4697 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4698 | S_IRUGO | S_IWUSR, |
| 4699 | minor->debugfs_root, |
| 4700 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4701 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4702 | if (!ent) |
| 4703 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4704 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4705 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4706 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4707 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4708 | minor->debugfs_root, minor); |
| 4709 | } |
| 4710 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4711 | struct dpcd_block { |
| 4712 | /* DPCD dump start address. */ |
| 4713 | unsigned int offset; |
| 4714 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4715 | unsigned int end; |
| 4716 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4717 | size_t size; |
| 4718 | /* Only valid for eDP. */ |
| 4719 | bool edp; |
| 4720 | }; |
| 4721 | |
| 4722 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4723 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4724 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4725 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4726 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4727 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4728 | { .offset = DP_SET_POWER }, |
| 4729 | { .offset = DP_EDP_DPCD_REV }, |
| 4730 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4731 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4732 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4733 | }; |
| 4734 | |
| 4735 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4736 | { |
| 4737 | struct drm_connector *connector = m->private; |
| 4738 | struct intel_dp *intel_dp = |
| 4739 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 4740 | u8 buf[16]; |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4741 | ssize_t err; |
| 4742 | int i; |
| 4743 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4744 | if (connector->status != connector_status_connected) |
| 4745 | return -ENODEV; |
| 4746 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4747 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4748 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4749 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4750 | |
| 4751 | if (b->edp && |
| 4752 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4753 | continue; |
| 4754 | |
| 4755 | /* low tech for now */ |
| 4756 | if (WARN_ON(size > sizeof(buf))) |
| 4757 | continue; |
| 4758 | |
| 4759 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
Chris Wilson | 65404c8 | 2018-10-10 09:17:06 +0100 | [diff] [blame] | 4760 | if (err < 0) |
| 4761 | seq_printf(m, "%04x: ERROR %d\n", b->offset, (int)err); |
| 4762 | else |
| 4763 | seq_printf(m, "%04x: %*ph\n", b->offset, (int)err, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4764 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4765 | |
| 4766 | return 0; |
| 4767 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4768 | DEFINE_SHOW_ATTRIBUTE(i915_dpcd); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4769 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4770 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4771 | { |
| 4772 | struct drm_connector *connector = m->private; |
| 4773 | struct intel_dp *intel_dp = |
| 4774 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4775 | |
| 4776 | if (connector->status != connector_status_connected) |
| 4777 | return -ENODEV; |
| 4778 | |
| 4779 | seq_printf(m, "Panel power up delay: %d\n", |
| 4780 | intel_dp->panel_power_up_delay); |
| 4781 | seq_printf(m, "Panel power down delay: %d\n", |
| 4782 | intel_dp->panel_power_down_delay); |
| 4783 | seq_printf(m, "Backlight on delay: %d\n", |
| 4784 | intel_dp->backlight_on_delay); |
| 4785 | seq_printf(m, "Backlight off delay: %d\n", |
| 4786 | intel_dp->backlight_off_delay); |
| 4787 | |
| 4788 | return 0; |
| 4789 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4790 | DEFINE_SHOW_ATTRIBUTE(i915_panel); |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4791 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4792 | static int i915_hdcp_sink_capability_show(struct seq_file *m, void *data) |
| 4793 | { |
| 4794 | struct drm_connector *connector = m->private; |
| 4795 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 4796 | |
| 4797 | if (connector->status != connector_status_connected) |
| 4798 | return -ENODEV; |
| 4799 | |
| 4800 | /* HDCP is supported by connector */ |
Ramalingam C | d3dacc7 | 2018-10-29 15:15:46 +0530 | [diff] [blame] | 4801 | if (!intel_connector->hdcp.shim) |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4802 | return -EINVAL; |
| 4803 | |
| 4804 | seq_printf(m, "%s:%d HDCP version: ", connector->name, |
| 4805 | connector->base.id); |
| 4806 | seq_printf(m, "%s ", !intel_hdcp_capable(intel_connector) ? |
| 4807 | "None" : "HDCP1.4"); |
| 4808 | seq_puts(m, "\n"); |
| 4809 | |
| 4810 | return 0; |
| 4811 | } |
| 4812 | DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability); |
| 4813 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4814 | static int i915_dsc_fec_support_show(struct seq_file *m, void *data) |
| 4815 | { |
| 4816 | struct drm_connector *connector = m->private; |
| 4817 | struct drm_device *dev = connector->dev; |
| 4818 | struct drm_crtc *crtc; |
| 4819 | struct intel_dp *intel_dp; |
| 4820 | struct drm_modeset_acquire_ctx ctx; |
| 4821 | struct intel_crtc_state *crtc_state = NULL; |
| 4822 | int ret = 0; |
| 4823 | bool try_again = false; |
| 4824 | |
| 4825 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 4826 | |
| 4827 | do { |
Manasi Navare | 6afe892 | 2018-12-19 15:51:20 -0800 | [diff] [blame] | 4828 | try_again = false; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4829 | ret = drm_modeset_lock(&dev->mode_config.connection_mutex, |
| 4830 | &ctx); |
| 4831 | if (ret) { |
| 4832 | ret = -EINTR; |
| 4833 | break; |
| 4834 | } |
| 4835 | crtc = connector->state->crtc; |
| 4836 | if (connector->status != connector_status_connected || !crtc) { |
| 4837 | ret = -ENODEV; |
| 4838 | break; |
| 4839 | } |
| 4840 | ret = drm_modeset_lock(&crtc->mutex, &ctx); |
| 4841 | if (ret == -EDEADLK) { |
| 4842 | ret = drm_modeset_backoff(&ctx); |
| 4843 | if (!ret) { |
| 4844 | try_again = true; |
| 4845 | continue; |
| 4846 | } |
| 4847 | break; |
| 4848 | } else if (ret) { |
| 4849 | break; |
| 4850 | } |
| 4851 | intel_dp = enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4852 | crtc_state = to_intel_crtc_state(crtc->state); |
| 4853 | seq_printf(m, "DSC_Enabled: %s\n", |
| 4854 | yesno(crtc_state->dsc_params.compression_enable)); |
Radhakrishna Sripada | fed8569 | 2019-01-09 13:14:14 -0800 | [diff] [blame] | 4855 | seq_printf(m, "DSC_Sink_Support: %s\n", |
| 4856 | yesno(drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd))); |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4857 | if (!intel_dp_is_edp(intel_dp)) |
| 4858 | seq_printf(m, "FEC_Sink_Support: %s\n", |
| 4859 | yesno(drm_dp_sink_supports_fec(intel_dp->fec_capable))); |
| 4860 | } while (try_again); |
| 4861 | |
| 4862 | drm_modeset_drop_locks(&ctx); |
| 4863 | drm_modeset_acquire_fini(&ctx); |
| 4864 | |
| 4865 | return ret; |
| 4866 | } |
| 4867 | |
| 4868 | static ssize_t i915_dsc_fec_support_write(struct file *file, |
| 4869 | const char __user *ubuf, |
| 4870 | size_t len, loff_t *offp) |
| 4871 | { |
| 4872 | bool dsc_enable = false; |
| 4873 | int ret; |
| 4874 | struct drm_connector *connector = |
| 4875 | ((struct seq_file *)file->private_data)->private; |
| 4876 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
| 4877 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 4878 | |
| 4879 | if (len == 0) |
| 4880 | return 0; |
| 4881 | |
| 4882 | DRM_DEBUG_DRIVER("Copied %zu bytes from user to force DSC\n", |
| 4883 | len); |
| 4884 | |
| 4885 | ret = kstrtobool_from_user(ubuf, len, &dsc_enable); |
| 4886 | if (ret < 0) |
| 4887 | return ret; |
| 4888 | |
| 4889 | DRM_DEBUG_DRIVER("Got %s for DSC Enable\n", |
| 4890 | (dsc_enable) ? "true" : "false"); |
| 4891 | intel_dp->force_dsc_en = dsc_enable; |
| 4892 | |
| 4893 | *offp += len; |
| 4894 | return len; |
| 4895 | } |
| 4896 | |
| 4897 | static int i915_dsc_fec_support_open(struct inode *inode, |
| 4898 | struct file *file) |
| 4899 | { |
| 4900 | return single_open(file, i915_dsc_fec_support_show, |
| 4901 | inode->i_private); |
| 4902 | } |
| 4903 | |
| 4904 | static const struct file_operations i915_dsc_fec_support_fops = { |
| 4905 | .owner = THIS_MODULE, |
| 4906 | .open = i915_dsc_fec_support_open, |
| 4907 | .read = seq_read, |
| 4908 | .llseek = seq_lseek, |
| 4909 | .release = single_release, |
| 4910 | .write = i915_dsc_fec_support_write |
| 4911 | }; |
| 4912 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4913 | /** |
| 4914 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4915 | * @connector: pointer to a registered drm_connector |
| 4916 | * |
| 4917 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4918 | * drm_debugfs_connector_remove(). |
| 4919 | * |
| 4920 | * Returns 0 on success, negative error codes on error. |
| 4921 | */ |
| 4922 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 4923 | { |
| 4924 | struct dentry *root = connector->debugfs_entry; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4925 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4926 | |
| 4927 | /* The connector must have been registered beforehands. */ |
| 4928 | if (!root) |
| 4929 | return -ENODEV; |
| 4930 | |
| 4931 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4932 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4933 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 4934 | connector, &i915_dpcd_fops); |
| 4935 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 4936 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4937 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 4938 | connector, &i915_panel_fops); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 4939 | debugfs_create_file("i915_psr_sink_status", S_IRUGO, root, |
| 4940 | connector, &i915_psr_sink_status_fops); |
| 4941 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4942 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4943 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4944 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || |
| 4945 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { |
| 4946 | debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, |
| 4947 | connector, &i915_hdcp_sink_capability_fops); |
| 4948 | } |
| 4949 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4950 | if (INTEL_GEN(dev_priv) >= 10 && |
| 4951 | (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4952 | connector->connector_type == DRM_MODE_CONNECTOR_eDP)) |
| 4953 | debugfs_create_file("i915_dsc_fec_support", S_IRUGO, root, |
| 4954 | connector, &i915_dsc_fec_support_fops); |
| 4955 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4956 | return 0; |
| 4957 | } |