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 | 1c7f4bc | 2016-02-26 11:03:19 +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 | 1c7f4bc | 2016-02-26 11:03:19 +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, |
| 209 | i915_gem_active_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 | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 325 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 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) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1318 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1319 | struct rb_node *rb; |
| 1320 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1321 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame^] | 1322 | seq_printf(m, "\tseqno = %x [current %x, last %x], %dms ago\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1323 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame^] | 1324 | intel_engine_last_submit(engine), |
| 1325 | jiffies_to_msecs(jiffies - |
| 1326 | engine->hangcheck.action_timestamp)); |
| 1327 | seq_printf(m, "\twaiters? %s, fake irq active? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1328 | yesno(intel_engine_has_waiter(engine)), |
| 1329 | yesno(test_bit(engine->id, |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame^] | 1330 | &dev_priv->gpu_error.missed_irq_rings))); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1331 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1332 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1333 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 1334 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1335 | |
| 1336 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1337 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1338 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1339 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1340 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1341 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1342 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1343 | (long long)acthd[id]); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1344 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1345 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1346 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1347 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1348 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1349 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1350 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1351 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1352 | i915_instdone_info(dev_priv, m, |
| 1353 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1354 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1355 | } |
| 1356 | |
| 1357 | return 0; |
| 1358 | } |
| 1359 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1360 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1361 | { |
| 1362 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1363 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1364 | struct intel_engine_cs *engine; |
| 1365 | enum intel_engine_id id; |
| 1366 | |
| 1367 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1368 | |
| 1369 | for_each_engine(engine, dev_priv, id) { |
| 1370 | seq_printf(m, "%s = %u\n", engine->name, |
| 1371 | i915_reset_engine_count(error, engine)); |
| 1372 | } |
| 1373 | |
| 1374 | return 0; |
| 1375 | } |
| 1376 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1377 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1378 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1379 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1380 | u32 rgvmodectl, rstdbyctl; |
| 1381 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1382 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1383 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1384 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1385 | crstandvid = I915_READ16(CRSTANDVID); |
| 1386 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1387 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1388 | seq_printf(m, "Boost freq: %d\n", |
| 1389 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1390 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1391 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1392 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1393 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1394 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1395 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1396 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1397 | seq_printf(m, "Starting frequency: P%d\n", |
| 1398 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1399 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1400 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1401 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1402 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1403 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1404 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1405 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1406 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1407 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1408 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1409 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1410 | break; |
| 1411 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1412 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1413 | break; |
| 1414 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1415 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1416 | break; |
| 1417 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1418 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1419 | break; |
| 1420 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1421 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1422 | break; |
| 1423 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1424 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1425 | break; |
| 1426 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1427 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1428 | break; |
| 1429 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1430 | |
| 1431 | return 0; |
| 1432 | } |
| 1433 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1434 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1435 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1436 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1437 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1438 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1439 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1440 | seq_printf(m, "user.bypass_count = %u\n", |
| 1441 | i915->uncore.user_forcewake.count); |
| 1442 | |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1443 | for_each_fw_domain(fw_domain, i915, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1444 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1445 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1446 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1447 | |
| 1448 | return 0; |
| 1449 | } |
| 1450 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1451 | static void print_rc6_res(struct seq_file *m, |
| 1452 | const char *title, |
| 1453 | const i915_reg_t reg) |
| 1454 | { |
| 1455 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1456 | |
| 1457 | seq_printf(m, "%s %u (%llu us)\n", |
| 1458 | title, I915_READ(reg), |
| 1459 | intel_rc6_residency_us(dev_priv, reg)); |
| 1460 | } |
| 1461 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1462 | static int vlv_drpc_info(struct seq_file *m) |
| 1463 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1464 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1465 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1466 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1467 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1468 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1469 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1470 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1471 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1472 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1473 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1474 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1475 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1476 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1477 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1478 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1479 | 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] | 1480 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1481 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1482 | } |
| 1483 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1484 | static int gen6_drpc_info(struct seq_file *m) |
| 1485 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1486 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1487 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1488 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1489 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1490 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1491 | 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] | 1492 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1493 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
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 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1496 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1497 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1498 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1499 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1500 | mutex_lock(&dev_priv->pcu_lock); |
| 1501 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, |
| 1502 | &rc6vids); |
| 1503 | mutex_unlock(&dev_priv->pcu_lock); |
| 1504 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1505 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1506 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1507 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1508 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1509 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1510 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1511 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1512 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1513 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1514 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1515 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1516 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1517 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1518 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1519 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1520 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1521 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1522 | case GEN6_RC0: |
| 1523 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1524 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1525 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1526 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1527 | break; |
| 1528 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1529 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1530 | break; |
| 1531 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1532 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1533 | break; |
| 1534 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1535 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1536 | break; |
| 1537 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1538 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1539 | break; |
| 1540 | } |
| 1541 | |
| 1542 | seq_printf(m, "Core Power Down: %s\n", |
| 1543 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1544 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1545 | seq_printf(m, "Render Power Well: %s\n", |
| 1546 | (gen9_powergate_status & |
| 1547 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1548 | seq_printf(m, "Media Power Well: %s\n", |
| 1549 | (gen9_powergate_status & |
| 1550 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1551 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1552 | |
| 1553 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1554 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1555 | GEN6_GT_GFX_RC6_LOCKED); |
| 1556 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1557 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1558 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1559 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1560 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1561 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1562 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1563 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1564 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1565 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1566 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
| 1567 | } |
| 1568 | |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1569 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1570 | } |
| 1571 | |
| 1572 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1573 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1574 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1575 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1576 | int err = -ENODEV; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1577 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1578 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1579 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 1580 | err = vlv_drpc_info(m); |
| 1581 | else if (INTEL_GEN(dev_priv) >= 6) |
| 1582 | err = gen6_drpc_info(m); |
| 1583 | else |
| 1584 | err = ironlake_drpc_info(m); |
| 1585 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1586 | |
| 1587 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1588 | } |
| 1589 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1590 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1591 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1592 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1593 | |
| 1594 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1595 | dev_priv->fb_tracking.busy_bits); |
| 1596 | |
| 1597 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1598 | dev_priv->fb_tracking.flip_bits); |
| 1599 | |
| 1600 | return 0; |
| 1601 | } |
| 1602 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1603 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1604 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1605 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1606 | struct intel_fbc *fbc = &dev_priv->fbc; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1607 | intel_wakeref_t wakeref; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1608 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1609 | if (!HAS_FBC(dev_priv)) |
| 1610 | return -ENODEV; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1611 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1612 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1613 | mutex_lock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1614 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1615 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1616 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1617 | else |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1618 | seq_printf(m, "FBC disabled: %s\n", fbc->no_fbc_reason); |
| 1619 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1620 | if (intel_fbc_is_active(dev_priv)) { |
| 1621 | u32 mask; |
| 1622 | |
| 1623 | if (INTEL_GEN(dev_priv) >= 8) |
| 1624 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1625 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1626 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1627 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1628 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1629 | else if (IS_G4X(dev_priv)) |
| 1630 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1631 | else |
| 1632 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1633 | FBC_STAT_COMPRESSED); |
| 1634 | |
| 1635 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1636 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1637 | |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1638 | mutex_unlock(&fbc->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1639 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1640 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1641 | return 0; |
| 1642 | } |
| 1643 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1644 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1645 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1646 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1647 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1648 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1649 | return -ENODEV; |
| 1650 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1651 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1652 | |
| 1653 | return 0; |
| 1654 | } |
| 1655 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1656 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1657 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1658 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1659 | u32 reg; |
| 1660 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1661 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1662 | return -ENODEV; |
| 1663 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1664 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1665 | |
| 1666 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1667 | dev_priv->fbc.false_color = val; |
| 1668 | |
| 1669 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1670 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1671 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1672 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1673 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1674 | return 0; |
| 1675 | } |
| 1676 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1677 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1678 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1679 | "%llu\n"); |
| 1680 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1681 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1682 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1683 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1684 | intel_wakeref_t wakeref; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1685 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1686 | if (!HAS_IPS(dev_priv)) |
| 1687 | return -ENODEV; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1688 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1689 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1690 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1691 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1692 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1693 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1694 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1695 | seq_puts(m, "Currently: unknown\n"); |
| 1696 | } else { |
| 1697 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1698 | seq_puts(m, "Currently: enabled\n"); |
| 1699 | else |
| 1700 | seq_puts(m, "Currently: disabled\n"); |
| 1701 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1702 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1703 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1704 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1705 | return 0; |
| 1706 | } |
| 1707 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1708 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1709 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1710 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1711 | intel_wakeref_t wakeref; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1712 | bool sr_enabled = false; |
| 1713 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1714 | wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1715 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1716 | if (INTEL_GEN(dev_priv) >= 9) |
| 1717 | /* no global SR status; inspect per-plane WM */; |
| 1718 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1719 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1720 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1721 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1722 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1723 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1724 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1725 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1726 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1727 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1728 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1729 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1730 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1731 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1732 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1733 | |
| 1734 | return 0; |
| 1735 | } |
| 1736 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1737 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1738 | { |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1739 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1740 | intel_wakeref_t wakeref; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1741 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1742 | if (!IS_GEN(i915, 5)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1743 | return -ENODEV; |
| 1744 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1745 | with_intel_runtime_pm(i915, wakeref) { |
| 1746 | unsigned long temp, chipset, gfx; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1747 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1748 | temp = i915_mch_val(i915); |
| 1749 | chipset = i915_chipset_val(i915); |
| 1750 | gfx = i915_gfx_val(i915); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1751 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1752 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1753 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1754 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1755 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1756 | } |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1757 | |
| 1758 | return 0; |
| 1759 | } |
| 1760 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1761 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1762 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1763 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1764 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1765 | unsigned int max_gpu_freq, min_gpu_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1766 | intel_wakeref_t wakeref; |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1767 | int gpu_freq, ia_freq; |
| 1768 | int ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1769 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1770 | if (!HAS_LLC(dev_priv)) |
| 1771 | return -ENODEV; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1772 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1773 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1774 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1775 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1776 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1777 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1778 | |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1779 | min_gpu_freq = rps->min_freq; |
| 1780 | max_gpu_freq = rps->max_freq; |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1781 | if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1782 | /* Convert GT frequency to 50 HZ units */ |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1783 | min_gpu_freq /= GEN9_FREQ_SCALER; |
| 1784 | max_gpu_freq /= GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1785 | } |
| 1786 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1787 | 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] | 1788 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1789 | 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] | 1790 | ia_freq = gpu_freq; |
| 1791 | sandybridge_pcode_read(dev_priv, |
| 1792 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1793 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1794 | 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] | 1795 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1796 | (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1797 | INTEL_GEN(dev_priv) >= 10 ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1798 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1799 | ((ia_freq >> 0) & 0xff) * 100, |
| 1800 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1801 | } |
| 1802 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1803 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1804 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1805 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1806 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1807 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1808 | } |
| 1809 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1810 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1811 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1812 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1813 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1814 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1815 | int ret; |
| 1816 | |
| 1817 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1818 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1819 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1820 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1821 | if (opregion->header) |
| 1822 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1823 | |
| 1824 | mutex_unlock(&dev->struct_mutex); |
| 1825 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1826 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1827 | return 0; |
| 1828 | } |
| 1829 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1830 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1831 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1832 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1833 | |
| 1834 | if (opregion->vbt) |
| 1835 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1836 | |
| 1837 | return 0; |
| 1838 | } |
| 1839 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1840 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1841 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1842 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1843 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1844 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1845 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1846 | int ret; |
| 1847 | |
| 1848 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1849 | if (ret) |
| 1850 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1851 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1852 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1853 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1854 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1855 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1856 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1857 | fbdev_fb->base.width, |
| 1858 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1859 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1860 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1861 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1862 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1863 | describe_obj(m, intel_fb_obj(&fbdev_fb->base)); |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1864 | seq_putc(m, '\n'); |
| 1865 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1866 | #endif |
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_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1869 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1870 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1871 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1872 | continue; |
| 1873 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1874 | 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] | 1875 | fb->base.width, |
| 1876 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1877 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1878 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1879 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1880 | drm_framebuffer_read_refcount(&fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1881 | describe_obj(m, intel_fb_obj(&fb->base)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1882 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1883 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1884 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1885 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1886 | |
| 1887 | return 0; |
| 1888 | } |
| 1889 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1890 | 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] | 1891 | { |
Chris Wilson | ef5032a | 2018-03-07 13:42:24 +0000 | [diff] [blame] | 1892 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", |
| 1893 | ring->space, ring->head, ring->tail, ring->emit); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1894 | } |
| 1895 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1896 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1897 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1898 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1899 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1900 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1901 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1902 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1903 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1904 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1905 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1906 | if (ret) |
| 1907 | return ret; |
| 1908 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1909 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 288f1ce | 2018-09-04 16:31:17 +0100 | [diff] [blame] | 1910 | seq_puts(m, "HW context "); |
| 1911 | if (!list_empty(&ctx->hw_id_link)) |
| 1912 | seq_printf(m, "%x [pin %u]", ctx->hw_id, |
| 1913 | atomic_read(&ctx->hw_id_pin_count)); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1914 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1915 | struct task_struct *task; |
| 1916 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1917 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1918 | if (task) { |
| 1919 | seq_printf(m, "(%s [%d]) ", |
| 1920 | task->comm, task->pid); |
| 1921 | put_task_struct(task); |
| 1922 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1923 | } else if (IS_ERR(ctx->file_priv)) { |
| 1924 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1925 | } else { |
| 1926 | seq_puts(m, "(kernel) "); |
| 1927 | } |
| 1928 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1929 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1930 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1931 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1932 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 1933 | struct intel_context *ce = |
| 1934 | to_intel_context(ctx, engine); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1935 | |
| 1936 | seq_printf(m, "%s: ", engine->name); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1937 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1938 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1939 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1940 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1941 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1942 | } |
| 1943 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1944 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1945 | } |
| 1946 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1947 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1948 | |
| 1949 | return 0; |
| 1950 | } |
| 1951 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1952 | static const char *swizzle_string(unsigned swizzle) |
| 1953 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1954 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1955 | case I915_BIT_6_SWIZZLE_NONE: |
| 1956 | return "none"; |
| 1957 | case I915_BIT_6_SWIZZLE_9: |
| 1958 | return "bit9"; |
| 1959 | case I915_BIT_6_SWIZZLE_9_10: |
| 1960 | return "bit9/bit10"; |
| 1961 | case I915_BIT_6_SWIZZLE_9_11: |
| 1962 | return "bit9/bit11"; |
| 1963 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1964 | return "bit9/bit10/bit11"; |
| 1965 | case I915_BIT_6_SWIZZLE_9_17: |
| 1966 | return "bit9/bit17"; |
| 1967 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1968 | return "bit9/bit10/bit17"; |
| 1969 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1970 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1971 | } |
| 1972 | |
| 1973 | return "bug"; |
| 1974 | } |
| 1975 | |
| 1976 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1977 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1978 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1979 | intel_wakeref_t wakeref; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1980 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1981 | wakeref = intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1982 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1983 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1984 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1985 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1986 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1987 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 1988 | if (IS_GEN_RANGE(dev_priv, 3, 4)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1989 | seq_printf(m, "DDC = 0x%08x\n", |
| 1990 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1991 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 1992 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1993 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1994 | I915_READ16(C0DRB3)); |
| 1995 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1996 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1997 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1998 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1999 | I915_READ(MAD_DIMM_C0)); |
| 2000 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2001 | I915_READ(MAD_DIMM_C1)); |
| 2002 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2003 | I915_READ(MAD_DIMM_C2)); |
| 2004 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2005 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2006 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2007 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2008 | I915_READ(GAMTARBMODE)); |
| 2009 | else |
| 2010 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2011 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2012 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2013 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2014 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2015 | |
| 2016 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2017 | seq_puts(m, "L-shaped memory detected\n"); |
| 2018 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2019 | intel_runtime_pm_put(dev_priv, wakeref); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2020 | |
| 2021 | return 0; |
| 2022 | } |
| 2023 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2024 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2025 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2026 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2027 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2028 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2029 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2030 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2031 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2032 | |
| 2033 | return count; |
| 2034 | } |
| 2035 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2036 | static const char *rps_power_to_str(unsigned int power) |
| 2037 | { |
| 2038 | static const char * const strings[] = { |
| 2039 | [LOW_POWER] = "low power", |
| 2040 | [BETWEEN] = "mixed", |
| 2041 | [HIGH_POWER] = "high power", |
| 2042 | }; |
| 2043 | |
| 2044 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2045 | return "unknown"; |
| 2046 | |
| 2047 | return strings[power]; |
| 2048 | } |
| 2049 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2050 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2051 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2052 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2053 | struct drm_device *dev = &dev_priv->drm; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2054 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2055 | u32 act_freq = rps->cur_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2056 | intel_wakeref_t wakeref; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2057 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2058 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2059 | with_intel_runtime_pm_if_in_use(dev_priv, wakeref) { |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2060 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 2061 | mutex_lock(&dev_priv->pcu_lock); |
| 2062 | act_freq = vlv_punit_read(dev_priv, |
| 2063 | PUNIT_REG_GPU_FREQ_STS); |
| 2064 | act_freq = (act_freq >> 8) & 0xff; |
| 2065 | mutex_unlock(&dev_priv->pcu_lock); |
| 2066 | } else { |
| 2067 | act_freq = intel_get_cagf(dev_priv, |
| 2068 | I915_READ(GEN6_RPSTAT1)); |
| 2069 | } |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2070 | } |
| 2071 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2072 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2073 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2074 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2075 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2076 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2077 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2078 | seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2079 | seq_printf(m, "Frequency requested %d, actual %d\n", |
| 2080 | intel_gpu_freq(dev_priv, rps->cur_freq), |
| 2081 | intel_gpu_freq(dev_priv, act_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2082 | 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] | 2083 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2084 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2085 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2086 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2087 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2088 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2089 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2090 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2091 | |
| 2092 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2093 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2094 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2095 | struct task_struct *task; |
| 2096 | |
| 2097 | rcu_read_lock(); |
| 2098 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2099 | seq_printf(m, "%s [%d]: %d boosts\n", |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2100 | task ? task->comm : "<unknown>", |
| 2101 | task ? task->pid : -1, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2102 | atomic_read(&file_priv->rps_client.boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2103 | rcu_read_unlock(); |
| 2104 | } |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2105 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2106 | atomic_read(&rps->boosts)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2107 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2108 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2109 | if (INTEL_GEN(dev_priv) >= 6 && |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2110 | rps->enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2111 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2112 | u32 rpup, rpupei; |
| 2113 | u32 rpdown, rpdownei; |
| 2114 | |
| 2115 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2116 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2117 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2118 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2119 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2120 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2121 | |
| 2122 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2123 | rps_power_to_str(rps->power.mode)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2124 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2125 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2126 | rps->power.up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2127 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2128 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2129 | rps->power.down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2130 | } else { |
| 2131 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2132 | } |
| 2133 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2134 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2135 | } |
| 2136 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2137 | static int i915_llc(struct seq_file *m, void *data) |
| 2138 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2139 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2140 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2141 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2142 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2143 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2144 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2145 | |
| 2146 | return 0; |
| 2147 | } |
| 2148 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2149 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2150 | { |
| 2151 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2152 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2153 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2154 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2155 | if (!HAS_HUC(dev_priv)) |
| 2156 | return -ENODEV; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2157 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2158 | p = drm_seq_file_printer(m); |
| 2159 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2160 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2161 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2162 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2163 | |
| 2164 | return 0; |
| 2165 | } |
| 2166 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2167 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2168 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2169 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2170 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2171 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2172 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2173 | if (!HAS_GUC(dev_priv)) |
| 2174 | return -ENODEV; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2175 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2176 | p = drm_seq_file_printer(m); |
| 2177 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2178 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2179 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 2180 | u32 tmp = I915_READ(GUC_STATUS); |
| 2181 | u32 i; |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2182 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2183 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2184 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2185 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2186 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2187 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2188 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2189 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2190 | seq_puts(m, "\nScratch registers:\n"); |
| 2191 | for (i = 0; i < 16; i++) { |
| 2192 | seq_printf(m, "\t%2d: \t0x%x\n", |
| 2193 | i, I915_READ(SOFT_SCRATCH(i))); |
| 2194 | } |
| 2195 | } |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2196 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2197 | return 0; |
| 2198 | } |
| 2199 | |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2200 | static const char * |
| 2201 | stringify_guc_log_type(enum guc_log_buffer_type type) |
| 2202 | { |
| 2203 | switch (type) { |
| 2204 | case GUC_ISR_LOG_BUFFER: |
| 2205 | return "ISR"; |
| 2206 | case GUC_DPC_LOG_BUFFER: |
| 2207 | return "DPC"; |
| 2208 | case GUC_CRASH_DUMP_LOG_BUFFER: |
| 2209 | return "CRASH"; |
| 2210 | default: |
| 2211 | MISSING_CASE(type); |
| 2212 | } |
| 2213 | |
| 2214 | return ""; |
| 2215 | } |
| 2216 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2217 | static void i915_guc_log_info(struct seq_file *m, |
| 2218 | struct drm_i915_private *dev_priv) |
| 2219 | { |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2220 | struct intel_guc_log *log = &dev_priv->guc.log; |
| 2221 | enum guc_log_buffer_type type; |
| 2222 | |
| 2223 | if (!intel_guc_log_relay_enabled(log)) { |
| 2224 | seq_puts(m, "GuC log relay disabled\n"); |
| 2225 | return; |
| 2226 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2227 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2228 | seq_puts(m, "GuC logging stats:\n"); |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2229 | |
Michał Winiarski | 6a96be2 | 2018-03-19 10:53:42 +0100 | [diff] [blame] | 2230 | seq_printf(m, "\tRelay full count: %u\n", |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2231 | log->relay.full_count); |
| 2232 | |
| 2233 | for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { |
| 2234 | seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", |
| 2235 | stringify_guc_log_type(type), |
| 2236 | log->stats[type].flush, |
| 2237 | log->stats[type].sampled_overflow); |
| 2238 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2239 | } |
| 2240 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2241 | static void i915_guc_client_info(struct seq_file *m, |
| 2242 | struct drm_i915_private *dev_priv, |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2243 | struct intel_guc_client *client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2244 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2245 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2246 | enum intel_engine_id id; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 2247 | u64 tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2248 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2249 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2250 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2251 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2252 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2253 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2254 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2255 | u64 submissions = client->submissions[id]; |
| 2256 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2257 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2258 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2259 | } |
| 2260 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2261 | } |
| 2262 | |
| 2263 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2264 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2265 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2266 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2267 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2268 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2269 | return -ENODEV; |
| 2270 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2271 | i915_guc_log_info(m, dev_priv); |
| 2272 | |
| 2273 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2274 | return 0; |
| 2275 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2276 | GEM_BUG_ON(!guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2277 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2278 | seq_printf(m, "\nDoorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2279 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2280 | seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2281 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2282 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2283 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Chris Wilson | e78c917 | 2018-02-07 21:05:42 +0000 | [diff] [blame] | 2284 | if (guc->preempt_client) { |
| 2285 | seq_printf(m, "\nGuC preempt client @ %p:\n", |
| 2286 | guc->preempt_client); |
| 2287 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
| 2288 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2289 | |
| 2290 | /* Add more as required ... */ |
| 2291 | |
| 2292 | return 0; |
| 2293 | } |
| 2294 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2295 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2296 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2297 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2298 | const struct intel_guc *guc = &dev_priv->guc; |
| 2299 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2300 | struct intel_guc_client *client = guc->execbuf_client; |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2301 | unsigned int tmp; |
| 2302 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2303 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2304 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2305 | return -ENODEV; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2306 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2307 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2308 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2309 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2310 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2311 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2312 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2313 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2314 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2315 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2316 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2317 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2318 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2319 | desc->engines_used); |
| 2320 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2321 | desc->db_trigger_phy, |
| 2322 | desc->db_trigger_cpu, |
| 2323 | desc->db_trigger_uk); |
| 2324 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2325 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2326 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2327 | desc->wq_addr, desc->wq_size); |
| 2328 | seq_putc(m, '\n'); |
| 2329 | |
| 2330 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2331 | u32 guc_engine_id = engine->guc_id; |
| 2332 | struct guc_execlist_context *lrc = |
| 2333 | &desc->lrc[guc_engine_id]; |
| 2334 | |
| 2335 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2336 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2337 | lrc->context_desc); |
| 2338 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2339 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2340 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2341 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2342 | seq_putc(m, '\n'); |
| 2343 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2344 | } |
| 2345 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2346 | return 0; |
| 2347 | } |
| 2348 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2349 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2350 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2351 | struct drm_info_node *node = m->private; |
| 2352 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2353 | bool dump_load_err = !!node->info_ent->data; |
| 2354 | struct drm_i915_gem_object *obj = NULL; |
| 2355 | u32 *log; |
| 2356 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2357 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2358 | if (!HAS_GUC(dev_priv)) |
| 2359 | return -ENODEV; |
| 2360 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2361 | if (dump_load_err) |
| 2362 | obj = dev_priv->guc.load_err_log; |
| 2363 | else if (dev_priv->guc.log.vma) |
| 2364 | obj = dev_priv->guc.log.vma->obj; |
| 2365 | |
| 2366 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2367 | return 0; |
| 2368 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2369 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2370 | if (IS_ERR(log)) { |
| 2371 | DRM_DEBUG("Failed to pin object\n"); |
| 2372 | seq_puts(m, "(log data unaccessible)\n"); |
| 2373 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2374 | } |
| 2375 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2376 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2377 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2378 | *(log + i), *(log + i + 1), |
| 2379 | *(log + i + 2), *(log + i + 3)); |
| 2380 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2381 | seq_putc(m, '\n'); |
| 2382 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2383 | i915_gem_object_unpin_map(obj); |
| 2384 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2385 | return 0; |
| 2386 | } |
| 2387 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2388 | static int i915_guc_log_level_get(void *data, u64 *val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2389 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2390 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2391 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2392 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2393 | return -ENODEV; |
| 2394 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2395 | *val = intel_guc_log_get_level(&dev_priv->guc.log); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2396 | |
| 2397 | return 0; |
| 2398 | } |
| 2399 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2400 | static int i915_guc_log_level_set(void *data, u64 val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2401 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2402 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2403 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2404 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2405 | return -ENODEV; |
| 2406 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2407 | return intel_guc_log_set_level(&dev_priv->guc.log, val); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2408 | } |
| 2409 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2410 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, |
| 2411 | i915_guc_log_level_get, i915_guc_log_level_set, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2412 | "%lld\n"); |
| 2413 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2414 | static int i915_guc_log_relay_open(struct inode *inode, struct file *file) |
| 2415 | { |
| 2416 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2417 | |
| 2418 | if (!USES_GUC(dev_priv)) |
| 2419 | return -ENODEV; |
| 2420 | |
| 2421 | file->private_data = &dev_priv->guc.log; |
| 2422 | |
| 2423 | return intel_guc_log_relay_open(&dev_priv->guc.log); |
| 2424 | } |
| 2425 | |
| 2426 | static ssize_t |
| 2427 | i915_guc_log_relay_write(struct file *filp, |
| 2428 | const char __user *ubuf, |
| 2429 | size_t cnt, |
| 2430 | loff_t *ppos) |
| 2431 | { |
| 2432 | struct intel_guc_log *log = filp->private_data; |
| 2433 | |
| 2434 | intel_guc_log_relay_flush(log); |
| 2435 | |
| 2436 | return cnt; |
| 2437 | } |
| 2438 | |
| 2439 | static int i915_guc_log_relay_release(struct inode *inode, struct file *file) |
| 2440 | { |
| 2441 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2442 | |
| 2443 | intel_guc_log_relay_close(&dev_priv->guc.log); |
| 2444 | |
| 2445 | return 0; |
| 2446 | } |
| 2447 | |
| 2448 | static const struct file_operations i915_guc_log_relay_fops = { |
| 2449 | .owner = THIS_MODULE, |
| 2450 | .open = i915_guc_log_relay_open, |
| 2451 | .write = i915_guc_log_relay_write, |
| 2452 | .release = i915_guc_log_relay_release, |
| 2453 | }; |
| 2454 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2455 | static int i915_psr_sink_status_show(struct seq_file *m, void *data) |
| 2456 | { |
| 2457 | u8 val; |
| 2458 | static const char * const sink_status[] = { |
| 2459 | "inactive", |
| 2460 | "transition to active, capture and display", |
| 2461 | "active, display from RFB", |
| 2462 | "active, capture and display on sink device timings", |
| 2463 | "transition to inactive, capture and display, timing re-sync", |
| 2464 | "reserved", |
| 2465 | "reserved", |
| 2466 | "sink internal error", |
| 2467 | }; |
| 2468 | struct drm_connector *connector = m->private; |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2469 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2470 | struct intel_dp *intel_dp = |
| 2471 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2472 | int ret; |
| 2473 | |
| 2474 | if (!CAN_PSR(dev_priv)) { |
| 2475 | seq_puts(m, "PSR Unsupported\n"); |
| 2476 | return -ENODEV; |
| 2477 | } |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2478 | |
| 2479 | if (connector->status != connector_status_connected) |
| 2480 | return -ENODEV; |
| 2481 | |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2482 | ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val); |
| 2483 | |
| 2484 | if (ret == 1) { |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2485 | const char *str = "unknown"; |
| 2486 | |
| 2487 | val &= DP_PSR_SINK_STATE_MASK; |
| 2488 | if (val < ARRAY_SIZE(sink_status)) |
| 2489 | str = sink_status[val]; |
| 2490 | seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str); |
| 2491 | } else { |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2492 | return ret; |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2493 | } |
| 2494 | |
| 2495 | return 0; |
| 2496 | } |
| 2497 | DEFINE_SHOW_ATTRIBUTE(i915_psr_sink_status); |
| 2498 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2499 | static void |
| 2500 | 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] | 2501 | { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2502 | u32 val, status_val; |
| 2503 | const char *status = "unknown"; |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2504 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2505 | if (dev_priv->psr.psr2_enabled) { |
| 2506 | static const char * const live_status[] = { |
| 2507 | "IDLE", |
| 2508 | "CAPTURE", |
| 2509 | "CAPTURE_FS", |
| 2510 | "SLEEP", |
| 2511 | "BUFON_FW", |
| 2512 | "ML_UP", |
| 2513 | "SU_STANDBY", |
| 2514 | "FAST_SLEEP", |
| 2515 | "DEEP_SLEEP", |
| 2516 | "BUF_ON", |
| 2517 | "TG_ON" |
| 2518 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2519 | val = I915_READ(EDP_PSR2_STATUS); |
| 2520 | status_val = (val & EDP_PSR2_STATUS_STATE_MASK) >> |
| 2521 | EDP_PSR2_STATUS_STATE_SHIFT; |
| 2522 | if (status_val < ARRAY_SIZE(live_status)) |
| 2523 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2524 | } else { |
| 2525 | static const char * const live_status[] = { |
| 2526 | "IDLE", |
| 2527 | "SRDONACK", |
| 2528 | "SRDENT", |
| 2529 | "BUFOFF", |
| 2530 | "BUFON", |
| 2531 | "AUXACK", |
| 2532 | "SRDOFFACK", |
| 2533 | "SRDENT_ON", |
| 2534 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2535 | val = I915_READ(EDP_PSR_STATUS); |
| 2536 | status_val = (val & EDP_PSR_STATUS_STATE_MASK) >> |
| 2537 | EDP_PSR_STATUS_STATE_SHIFT; |
| 2538 | if (status_val < ARRAY_SIZE(live_status)) |
| 2539 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2540 | } |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2541 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2542 | seq_printf(m, "Source PSR status: %s [0x%08x]\n", status, val); |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2543 | } |
| 2544 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2545 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2546 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2547 | 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] | 2548 | struct i915_psr *psr = &dev_priv->psr; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2549 | intel_wakeref_t wakeref; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2550 | const char *status; |
| 2551 | bool enabled; |
| 2552 | u32 val; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2553 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2554 | if (!HAS_PSR(dev_priv)) |
| 2555 | return -ENODEV; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2556 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2557 | seq_printf(m, "Sink support: %s", yesno(psr->sink_support)); |
| 2558 | if (psr->dp) |
| 2559 | seq_printf(m, " [0x%02x]", psr->dp->psr_dpcd[0]); |
| 2560 | seq_puts(m, "\n"); |
| 2561 | |
| 2562 | if (!psr->sink_support) |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2563 | return 0; |
| 2564 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2565 | wakeref = intel_runtime_pm_get(dev_priv); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2566 | mutex_lock(&psr->lock); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2567 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2568 | if (psr->enabled) |
| 2569 | status = psr->psr2_enabled ? "PSR2 enabled" : "PSR1 enabled"; |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2570 | else |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2571 | status = "disabled"; |
| 2572 | seq_printf(m, "PSR mode: %s\n", status); |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2573 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2574 | if (!psr->enabled) |
| 2575 | goto unlock; |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2576 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2577 | if (psr->psr2_enabled) { |
| 2578 | val = I915_READ(EDP_PSR2_CTL); |
| 2579 | enabled = val & EDP_PSR2_ENABLE; |
| 2580 | } else { |
| 2581 | val = I915_READ(EDP_PSR_CTL); |
| 2582 | enabled = val & EDP_PSR_ENABLE; |
| 2583 | } |
| 2584 | seq_printf(m, "Source PSR ctl: %s [0x%08x]\n", |
| 2585 | enableddisabled(enabled), val); |
| 2586 | psr_source_status(dev_priv, m); |
| 2587 | seq_printf(m, "Busy frontbuffer bits: 0x%08x\n", |
| 2588 | psr->busy_frontbuffer_bits); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2589 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2590 | /* |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2591 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2592 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2593 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2594 | val = I915_READ(EDP_PSR_PERF_CNT) & EDP_PSR_PERF_CNT_MASK; |
| 2595 | seq_printf(m, "Performance counter: %u\n", val); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2596 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2597 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2598 | if (psr->debug & I915_PSR_DEBUG_IRQ) { |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2599 | seq_printf(m, "Last attempted entry at: %lld\n", |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2600 | psr->last_entry_attempt); |
| 2601 | seq_printf(m, "Last exit at: %lld\n", psr->last_exit); |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2602 | } |
| 2603 | |
José Roberto de Souza | a81f781 | 2019-01-17 12:55:48 -0800 | [diff] [blame] | 2604 | if (psr->psr2_enabled) { |
| 2605 | u32 su_frames_val[3]; |
| 2606 | int frame; |
| 2607 | |
| 2608 | /* |
| 2609 | * Reading all 3 registers before hand to minimize crossing a |
| 2610 | * frame boundary between register reads |
| 2611 | */ |
| 2612 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame += 3) |
| 2613 | su_frames_val[frame / 3] = I915_READ(PSR2_SU_STATUS(frame)); |
| 2614 | |
| 2615 | seq_puts(m, "Frame:\tPSR2 SU blocks:\n"); |
| 2616 | |
| 2617 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame++) { |
| 2618 | u32 su_blocks; |
| 2619 | |
| 2620 | su_blocks = su_frames_val[frame / 3] & |
| 2621 | PSR2_SU_STATUS_MASK(frame); |
| 2622 | su_blocks = su_blocks >> PSR2_SU_STATUS_SHIFT(frame); |
| 2623 | seq_printf(m, "%d\t%d\n", frame, su_blocks); |
| 2624 | } |
| 2625 | } |
| 2626 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2627 | unlock: |
| 2628 | mutex_unlock(&psr->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2629 | intel_runtime_pm_put(dev_priv, wakeref); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2630 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2631 | return 0; |
| 2632 | } |
| 2633 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2634 | static int |
| 2635 | i915_edp_psr_debug_set(void *data, u64 val) |
| 2636 | { |
| 2637 | struct drm_i915_private *dev_priv = data; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2638 | struct drm_modeset_acquire_ctx ctx; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2639 | intel_wakeref_t wakeref; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2640 | int ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2641 | |
| 2642 | if (!CAN_PSR(dev_priv)) |
| 2643 | return -ENODEV; |
| 2644 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2645 | DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2646 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2647 | wakeref = intel_runtime_pm_get(dev_priv); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2648 | |
| 2649 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 2650 | |
| 2651 | retry: |
| 2652 | ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val); |
| 2653 | if (ret == -EDEADLK) { |
| 2654 | ret = drm_modeset_backoff(&ctx); |
| 2655 | if (!ret) |
| 2656 | goto retry; |
| 2657 | } |
| 2658 | |
| 2659 | drm_modeset_drop_locks(&ctx); |
| 2660 | drm_modeset_acquire_fini(&ctx); |
| 2661 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2662 | intel_runtime_pm_put(dev_priv, wakeref); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2663 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2664 | return ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2665 | } |
| 2666 | |
| 2667 | static int |
| 2668 | i915_edp_psr_debug_get(void *data, u64 *val) |
| 2669 | { |
| 2670 | struct drm_i915_private *dev_priv = data; |
| 2671 | |
| 2672 | if (!CAN_PSR(dev_priv)) |
| 2673 | return -ENODEV; |
| 2674 | |
| 2675 | *val = READ_ONCE(dev_priv->psr.debug); |
| 2676 | return 0; |
| 2677 | } |
| 2678 | |
| 2679 | DEFINE_SIMPLE_ATTRIBUTE(i915_edp_psr_debug_fops, |
| 2680 | i915_edp_psr_debug_get, i915_edp_psr_debug_set, |
| 2681 | "%llu\n"); |
| 2682 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2683 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2684 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2685 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2686 | unsigned long long power; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2687 | intel_wakeref_t wakeref; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2688 | u32 units; |
| 2689 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2690 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2691 | return -ENODEV; |
| 2692 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2693 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2694 | return -ENODEV; |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2695 | |
| 2696 | units = (power & 0x1f00) >> 8; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2697 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2698 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2699 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2700 | power = (1000000 * power) >> units; /* convert to uJ */ |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2701 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2702 | |
| 2703 | return 0; |
| 2704 | } |
| 2705 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2706 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2707 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2708 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2709 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2710 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2711 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2712 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2713 | |
Chris Wilson | 25c896bd | 2019-01-14 14:21:25 +0000 | [diff] [blame] | 2714 | seq_printf(m, "Runtime power status: %s\n", |
| 2715 | enableddisabled(!dev_priv->power_domains.wakeref)); |
| 2716 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 2717 | seq_printf(m, "GPU idle: %s (epoch %u)\n", |
| 2718 | yesno(!dev_priv->gt.awake), dev_priv->gt.epoch); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2719 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2720 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2721 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2722 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2723 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2724 | #else |
| 2725 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2726 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2727 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2728 | pci_power_name(pdev->current_state), |
| 2729 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2730 | |
Chris Wilson | bd780f3 | 2019-01-14 14:21:09 +0000 | [diff] [blame] | 2731 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) { |
| 2732 | struct drm_printer p = drm_seq_file_printer(m); |
| 2733 | |
| 2734 | print_intel_runtime_pm_wakeref(dev_priv, &p); |
| 2735 | } |
| 2736 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2737 | return 0; |
| 2738 | } |
| 2739 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2740 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2741 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2742 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2743 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2744 | int i; |
| 2745 | |
| 2746 | mutex_lock(&power_domains->lock); |
| 2747 | |
| 2748 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2749 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2750 | struct i915_power_well *power_well; |
| 2751 | enum intel_display_power_domain power_domain; |
| 2752 | |
| 2753 | power_well = &power_domains->power_wells[i]; |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2754 | seq_printf(m, "%-25s %d\n", power_well->desc->name, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2755 | power_well->count); |
| 2756 | |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2757 | for_each_power_domain(power_domain, power_well->desc->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2758 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2759 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2760 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2761 | } |
| 2762 | |
| 2763 | mutex_unlock(&power_domains->lock); |
| 2764 | |
| 2765 | return 0; |
| 2766 | } |
| 2767 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2768 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2769 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2770 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2771 | intel_wakeref_t wakeref; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2772 | struct intel_csr *csr; |
| 2773 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2774 | if (!HAS_CSR(dev_priv)) |
| 2775 | return -ENODEV; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2776 | |
| 2777 | csr = &dev_priv->csr; |
| 2778 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2779 | wakeref = intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2780 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2781 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2782 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2783 | |
| 2784 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2785 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2786 | |
| 2787 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2788 | CSR_VERSION_MINOR(csr->version)); |
| 2789 | |
Imre Deak | 34b2f8d | 2018-10-31 22:02:20 +0200 | [diff] [blame] | 2790 | if (WARN_ON(INTEL_GEN(dev_priv) > 11)) |
| 2791 | goto out; |
| 2792 | |
| 2793 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2794 | I915_READ(IS_BROXTON(dev_priv) ? BXT_CSR_DC3_DC5_COUNT : |
| 2795 | SKL_CSR_DC3_DC5_COUNT)); |
| 2796 | if (!IS_GEN9_LP(dev_priv)) |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2797 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2798 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2799 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2800 | out: |
| 2801 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2802 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2803 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2804 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2805 | intel_runtime_pm_put(dev_priv, wakeref); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2806 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2807 | return 0; |
| 2808 | } |
| 2809 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2810 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2811 | struct drm_display_mode *mode) |
| 2812 | { |
| 2813 | int i; |
| 2814 | |
| 2815 | for (i = 0; i < tabs; i++) |
| 2816 | seq_putc(m, '\t'); |
| 2817 | |
Shayenne Moura | 4fb6bb8 | 2018-12-20 10:27:57 -0200 | [diff] [blame] | 2818 | seq_printf(m, DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2819 | } |
| 2820 | |
| 2821 | static void intel_encoder_info(struct seq_file *m, |
| 2822 | struct intel_crtc *intel_crtc, |
| 2823 | struct intel_encoder *intel_encoder) |
| 2824 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2825 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2826 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2827 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2828 | struct intel_connector *intel_connector; |
| 2829 | struct drm_encoder *encoder; |
| 2830 | |
| 2831 | encoder = &intel_encoder->base; |
| 2832 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2833 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2834 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2835 | struct drm_connector *connector = &intel_connector->base; |
| 2836 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2837 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2838 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2839 | drm_get_connector_status_name(connector->status)); |
| 2840 | if (connector->status == connector_status_connected) { |
| 2841 | struct drm_display_mode *mode = &crtc->mode; |
| 2842 | seq_printf(m, ", mode:\n"); |
| 2843 | intel_seq_print_mode(m, 2, mode); |
| 2844 | } else { |
| 2845 | seq_putc(m, '\n'); |
| 2846 | } |
| 2847 | } |
| 2848 | } |
| 2849 | |
| 2850 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2851 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2852 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2853 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2854 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2855 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2856 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2857 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2858 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2859 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2860 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2861 | fb->base.id, plane_state->src_x >> 16, |
| 2862 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2863 | else |
| 2864 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2865 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2866 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2867 | } |
| 2868 | |
| 2869 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2870 | { |
| 2871 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2872 | |
| 2873 | seq_printf(m, "\tfixed mode:\n"); |
| 2874 | intel_seq_print_mode(m, 2, mode); |
| 2875 | } |
| 2876 | |
| 2877 | static void intel_dp_info(struct seq_file *m, |
| 2878 | struct intel_connector *intel_connector) |
| 2879 | { |
| 2880 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2881 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2882 | |
| 2883 | 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] | 2884 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2885 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2886 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2887 | |
| 2888 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2889 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2890 | } |
| 2891 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2892 | static void intel_dp_mst_info(struct seq_file *m, |
| 2893 | struct intel_connector *intel_connector) |
| 2894 | { |
| 2895 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2896 | struct intel_dp_mst_encoder *intel_mst = |
| 2897 | enc_to_mst(&intel_encoder->base); |
| 2898 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2899 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2900 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2901 | intel_connector->port); |
| 2902 | |
| 2903 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2904 | } |
| 2905 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2906 | static void intel_hdmi_info(struct seq_file *m, |
| 2907 | struct intel_connector *intel_connector) |
| 2908 | { |
| 2909 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2910 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2911 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2912 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2913 | } |
| 2914 | |
| 2915 | static void intel_lvds_info(struct seq_file *m, |
| 2916 | struct intel_connector *intel_connector) |
| 2917 | { |
| 2918 | intel_panel_info(m, &intel_connector->panel); |
| 2919 | } |
| 2920 | |
| 2921 | static void intel_connector_info(struct seq_file *m, |
| 2922 | struct drm_connector *connector) |
| 2923 | { |
| 2924 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2925 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2926 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2927 | |
| 2928 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2929 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2930 | drm_get_connector_status_name(connector->status)); |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame] | 2931 | |
| 2932 | if (connector->status == connector_status_disconnected) |
| 2933 | return; |
| 2934 | |
| 2935 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2936 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2937 | connector->display_info.width_mm, |
| 2938 | connector->display_info.height_mm); |
| 2939 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2940 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2941 | seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2942 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 2943 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2944 | return; |
| 2945 | |
| 2946 | switch (connector->connector_type) { |
| 2947 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2948 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2949 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2950 | intel_dp_mst_info(m, intel_connector); |
| 2951 | else |
| 2952 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2953 | break; |
| 2954 | case DRM_MODE_CONNECTOR_LVDS: |
| 2955 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2956 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2957 | break; |
| 2958 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2959 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 2960 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2961 | intel_hdmi_info(m, intel_connector); |
| 2962 | break; |
| 2963 | default: |
| 2964 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2965 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2966 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2967 | seq_printf(m, "\tmodes:\n"); |
| 2968 | list_for_each_entry(mode, &connector->modes, head) |
| 2969 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2970 | } |
| 2971 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2972 | static const char *plane_type(enum drm_plane_type type) |
| 2973 | { |
| 2974 | switch (type) { |
| 2975 | case DRM_PLANE_TYPE_OVERLAY: |
| 2976 | return "OVL"; |
| 2977 | case DRM_PLANE_TYPE_PRIMARY: |
| 2978 | return "PRI"; |
| 2979 | case DRM_PLANE_TYPE_CURSOR: |
| 2980 | return "CUR"; |
| 2981 | /* |
| 2982 | * Deliberately omitting default: to generate compiler warnings |
| 2983 | * when a new drm_plane_type gets added. |
| 2984 | */ |
| 2985 | } |
| 2986 | |
| 2987 | return "unknown"; |
| 2988 | } |
| 2989 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2990 | static void plane_rotation(char *buf, size_t bufsize, unsigned int rotation) |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2991 | { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2992 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2993 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2994 | * will print them all to visualize if the values are misused |
| 2995 | */ |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2996 | snprintf(buf, bufsize, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2997 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2998 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 2999 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 3000 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 3001 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 3002 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 3003 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3004 | rotation); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3005 | } |
| 3006 | |
| 3007 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3008 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3009 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3010 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3011 | struct intel_plane *intel_plane; |
| 3012 | |
| 3013 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3014 | struct drm_plane_state *state; |
| 3015 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3016 | struct drm_format_name_buf format_name; |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3017 | char rot_str[48]; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3018 | |
| 3019 | if (!plane->state) { |
| 3020 | seq_puts(m, "plane->state is NULL!\n"); |
| 3021 | continue; |
| 3022 | } |
| 3023 | |
| 3024 | state = plane->state; |
| 3025 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3026 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3027 | drm_get_format_name(state->fb->format->format, |
| 3028 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3029 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3030 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3031 | } |
| 3032 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3033 | plane_rotation(rot_str, sizeof(rot_str), state->rotation); |
| 3034 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3035 | 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", |
| 3036 | plane->base.id, |
| 3037 | plane_type(intel_plane->base.type), |
| 3038 | state->crtc_x, state->crtc_y, |
| 3039 | state->crtc_w, state->crtc_h, |
| 3040 | (state->src_x >> 16), |
| 3041 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3042 | (state->src_y >> 16), |
| 3043 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3044 | (state->src_w >> 16), |
| 3045 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3046 | (state->src_h >> 16), |
| 3047 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3048 | format_name.str, |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3049 | rot_str); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3050 | } |
| 3051 | } |
| 3052 | |
| 3053 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3054 | { |
| 3055 | struct intel_crtc_state *pipe_config; |
| 3056 | int num_scalers = intel_crtc->num_scalers; |
| 3057 | int i; |
| 3058 | |
| 3059 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3060 | |
| 3061 | /* Not all platformas have a scaler */ |
| 3062 | if (num_scalers) { |
| 3063 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3064 | num_scalers, |
| 3065 | pipe_config->scaler_state.scaler_users, |
| 3066 | pipe_config->scaler_state.scaler_id); |
| 3067 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3068 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3069 | struct intel_scaler *sc = |
| 3070 | &pipe_config->scaler_state.scalers[i]; |
| 3071 | |
| 3072 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3073 | i, yesno(sc->in_use), sc->mode); |
| 3074 | } |
| 3075 | seq_puts(m, "\n"); |
| 3076 | } else { |
| 3077 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3078 | } |
| 3079 | } |
| 3080 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3081 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3082 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3083 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3084 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3085 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3086 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3087 | struct drm_connector_list_iter conn_iter; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3088 | intel_wakeref_t wakeref; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3089 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3090 | wakeref = intel_runtime_pm_get(dev_priv); |
| 3091 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3092 | seq_printf(m, "CRTC info\n"); |
| 3093 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3094 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3095 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3096 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3097 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3098 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3099 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3100 | 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] | 3101 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3102 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3103 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3104 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3105 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3106 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3107 | struct intel_plane *cursor = |
| 3108 | to_intel_plane(crtc->base.cursor); |
| 3109 | |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3110 | intel_crtc_info(m, crtc); |
| 3111 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3112 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3113 | yesno(cursor->base.state->visible), |
| 3114 | cursor->base.state->crtc_x, |
| 3115 | cursor->base.state->crtc_y, |
| 3116 | cursor->base.state->crtc_w, |
| 3117 | cursor->base.state->crtc_h, |
| 3118 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3119 | intel_scaler_info(m, crtc); |
| 3120 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3121 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3122 | |
| 3123 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3124 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3125 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3126 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3127 | } |
| 3128 | |
| 3129 | seq_printf(m, "\n"); |
| 3130 | seq_printf(m, "Connector info\n"); |
| 3131 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3132 | mutex_lock(&dev->mode_config.mutex); |
| 3133 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3134 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3135 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3136 | drm_connector_list_iter_end(&conn_iter); |
| 3137 | mutex_unlock(&dev->mode_config.mutex); |
| 3138 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3139 | intel_runtime_pm_put(dev_priv, wakeref); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3140 | |
| 3141 | return 0; |
| 3142 | } |
| 3143 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3144 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3145 | { |
| 3146 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3147 | struct intel_engine_cs *engine; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3148 | intel_wakeref_t wakeref; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3149 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3150 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3151 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3152 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3153 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 3154 | seq_printf(m, "GT awake? %s (epoch %u)\n", |
| 3155 | yesno(dev_priv->gt.awake), dev_priv->gt.epoch); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3156 | seq_printf(m, "Global active requests: %d\n", |
| 3157 | dev_priv->gt.active_requests); |
Lionel Landwerlin | f577a03 | 2017-11-13 23:34:53 +0000 | [diff] [blame] | 3158 | seq_printf(m, "CS timestamp frequency: %u kHz\n", |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3159 | RUNTIME_INFO(dev_priv)->cs_timestamp_frequency_khz); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3160 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3161 | p = drm_seq_file_printer(m); |
| 3162 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 0db18b1 | 2017-12-08 01:23:00 +0000 | [diff] [blame] | 3163 | intel_engine_dump(engine, &p, "%s\n", engine->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3164 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3165 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3166 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3167 | return 0; |
| 3168 | } |
| 3169 | |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3170 | static int i915_rcs_topology(struct seq_file *m, void *unused) |
| 3171 | { |
| 3172 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3173 | struct drm_printer p = drm_seq_file_printer(m); |
| 3174 | |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3175 | intel_device_info_dump_topology(&RUNTIME_INFO(dev_priv)->sseu, &p); |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3176 | |
| 3177 | return 0; |
| 3178 | } |
| 3179 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3180 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3181 | { |
| 3182 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3183 | |
| 3184 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3185 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3186 | |
| 3187 | return 0; |
| 3188 | } |
| 3189 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3190 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3191 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3192 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3193 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3194 | int i; |
| 3195 | |
| 3196 | drm_modeset_lock_all(dev); |
| 3197 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3198 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3199 | |
Lucas De Marchi | 72f775f | 2018-03-20 15:06:34 -0700 | [diff] [blame] | 3200 | 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] | 3201 | pll->info->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3202 | 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] | 3203 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3204 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3205 | 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] | 3206 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3207 | pll->state.hw_state.dpll_md); |
| 3208 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3209 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3210 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Paulo Zanoni | c27e917 | 2018-04-27 16:14:36 -0700 | [diff] [blame] | 3211 | seq_printf(m, " cfgcr0: 0x%08x\n", pll->state.hw_state.cfgcr0); |
| 3212 | seq_printf(m, " cfgcr1: 0x%08x\n", pll->state.hw_state.cfgcr1); |
| 3213 | seq_printf(m, " mg_refclkin_ctl: 0x%08x\n", |
| 3214 | pll->state.hw_state.mg_refclkin_ctl); |
| 3215 | seq_printf(m, " mg_clktop2_coreclkctl1: 0x%08x\n", |
| 3216 | pll->state.hw_state.mg_clktop2_coreclkctl1); |
| 3217 | seq_printf(m, " mg_clktop2_hsclkctl: 0x%08x\n", |
| 3218 | pll->state.hw_state.mg_clktop2_hsclkctl); |
| 3219 | seq_printf(m, " mg_pll_div0: 0x%08x\n", |
| 3220 | pll->state.hw_state.mg_pll_div0); |
| 3221 | seq_printf(m, " mg_pll_div1: 0x%08x\n", |
| 3222 | pll->state.hw_state.mg_pll_div1); |
| 3223 | seq_printf(m, " mg_pll_lf: 0x%08x\n", |
| 3224 | pll->state.hw_state.mg_pll_lf); |
| 3225 | seq_printf(m, " mg_pll_frac_lock: 0x%08x\n", |
| 3226 | pll->state.hw_state.mg_pll_frac_lock); |
| 3227 | seq_printf(m, " mg_pll_ssc: 0x%08x\n", |
| 3228 | pll->state.hw_state.mg_pll_ssc); |
| 3229 | seq_printf(m, " mg_pll_bias: 0x%08x\n", |
| 3230 | pll->state.hw_state.mg_pll_bias); |
| 3231 | seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", |
| 3232 | pll->state.hw_state.mg_pll_tdc_coldst_bias); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3233 | } |
| 3234 | drm_modeset_unlock_all(dev); |
| 3235 | |
| 3236 | return 0; |
| 3237 | } |
| 3238 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3239 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3240 | { |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3241 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3242 | const struct i915_wa_list *wal = &i915->engine[RCS]->ctx_wa_list; |
| 3243 | struct i915_wa *wa; |
| 3244 | unsigned int i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3245 | |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3246 | seq_printf(m, "Workarounds applied: %u\n", wal->count); |
| 3247 | for (i = 0, wa = wal->list; i < wal->count; i++, wa++) |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3248 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n", |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3249 | i915_mmio_reg_offset(wa->reg), wa->val, wa->mask); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3250 | |
| 3251 | return 0; |
| 3252 | } |
| 3253 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3254 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3255 | { |
| 3256 | struct drm_i915_private *dev_priv = m->private; |
| 3257 | |
| 3258 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3259 | yesno(dev_priv->ipc_enabled)); |
| 3260 | return 0; |
| 3261 | } |
| 3262 | |
| 3263 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3264 | { |
| 3265 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3266 | |
| 3267 | if (!HAS_IPC(dev_priv)) |
| 3268 | return -ENODEV; |
| 3269 | |
| 3270 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3271 | } |
| 3272 | |
| 3273 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3274 | size_t len, loff_t *offp) |
| 3275 | { |
| 3276 | struct seq_file *m = file->private_data; |
| 3277 | struct drm_i915_private *dev_priv = m->private; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3278 | intel_wakeref_t wakeref; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3279 | bool enable; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3280 | int ret; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3281 | |
| 3282 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3283 | if (ret < 0) |
| 3284 | return ret; |
| 3285 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3286 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3287 | if (!dev_priv->ipc_enabled && enable) |
| 3288 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3289 | dev_priv->wm.distrust_bios_wm = true; |
| 3290 | dev_priv->ipc_enabled = enable; |
| 3291 | intel_enable_ipc(dev_priv); |
| 3292 | } |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3293 | |
| 3294 | return len; |
| 3295 | } |
| 3296 | |
| 3297 | static const struct file_operations i915_ipc_status_fops = { |
| 3298 | .owner = THIS_MODULE, |
| 3299 | .open = i915_ipc_status_open, |
| 3300 | .read = seq_read, |
| 3301 | .llseek = seq_lseek, |
| 3302 | .release = single_release, |
| 3303 | .write = i915_ipc_status_write |
| 3304 | }; |
| 3305 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3306 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3307 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3308 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3309 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3310 | struct skl_ddb_entry *entry; |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3311 | struct intel_crtc *crtc; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3312 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3313 | if (INTEL_GEN(dev_priv) < 9) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 3314 | return -ENODEV; |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3315 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3316 | drm_modeset_lock_all(dev); |
| 3317 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3318 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3319 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3320 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
| 3321 | struct intel_crtc_state *crtc_state = |
| 3322 | to_intel_crtc_state(crtc->base.state); |
| 3323 | enum pipe pipe = crtc->pipe; |
| 3324 | enum plane_id plane_id; |
| 3325 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3326 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3327 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3328 | for_each_plane_id_on_crtc(crtc, plane_id) { |
| 3329 | entry = &crtc_state->wm.skl.plane_ddb_y[plane_id]; |
| 3330 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane_id + 1, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3331 | entry->start, entry->end, |
| 3332 | skl_ddb_entry_size(entry)); |
| 3333 | } |
| 3334 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3335 | entry = &crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3336 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3337 | entry->end, skl_ddb_entry_size(entry)); |
| 3338 | } |
| 3339 | |
| 3340 | drm_modeset_unlock_all(dev); |
| 3341 | |
| 3342 | return 0; |
| 3343 | } |
| 3344 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3345 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3346 | struct drm_device *dev, |
| 3347 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3348 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3349 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3350 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3351 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3352 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3353 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3354 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3355 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3356 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3357 | if (connector->state->crtc != &intel_crtc->base) |
| 3358 | continue; |
| 3359 | |
| 3360 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3361 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3362 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3363 | |
| 3364 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3365 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3366 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3367 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3368 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3369 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3370 | else |
| 3371 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3372 | |
| 3373 | seq_puts(m, "\n\n"); |
| 3374 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3375 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3376 | struct intel_panel *panel; |
| 3377 | |
| 3378 | mutex_lock(&drrs->mutex); |
| 3379 | /* DRRS Supported */ |
| 3380 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3381 | |
| 3382 | /* disable_drrs() will make drrs->dp NULL */ |
| 3383 | if (!drrs->dp) { |
C, Ramalingam | ce6e213 | 2017-11-20 09:53:47 +0530 | [diff] [blame] | 3384 | seq_puts(m, "Idleness DRRS: Disabled\n"); |
| 3385 | if (dev_priv->psr.enabled) |
| 3386 | seq_puts(m, |
| 3387 | "\tAs PSR is enabled, DRRS is not enabled\n"); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3388 | mutex_unlock(&drrs->mutex); |
| 3389 | return; |
| 3390 | } |
| 3391 | |
| 3392 | panel = &drrs->dp->attached_connector->panel; |
| 3393 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3394 | drrs->busy_frontbuffer_bits); |
| 3395 | |
| 3396 | seq_puts(m, "\n\t\t"); |
| 3397 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3398 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3399 | vrefresh = panel->fixed_mode->vrefresh; |
| 3400 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3401 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3402 | vrefresh = panel->downclock_mode->vrefresh; |
| 3403 | } else { |
| 3404 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3405 | drrs->refresh_rate_type); |
| 3406 | mutex_unlock(&drrs->mutex); |
| 3407 | return; |
| 3408 | } |
| 3409 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3410 | |
| 3411 | seq_puts(m, "\n\t\t"); |
| 3412 | mutex_unlock(&drrs->mutex); |
| 3413 | } else { |
| 3414 | /* DRRS not supported. Print the VBT parameter*/ |
| 3415 | seq_puts(m, "\tDRRS Supported : No"); |
| 3416 | } |
| 3417 | seq_puts(m, "\n"); |
| 3418 | } |
| 3419 | |
| 3420 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3421 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3422 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3423 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3424 | struct intel_crtc *intel_crtc; |
| 3425 | int active_crtc_cnt = 0; |
| 3426 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3427 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3428 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3429 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3430 | active_crtc_cnt++; |
| 3431 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3432 | |
| 3433 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3434 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3435 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3436 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3437 | |
| 3438 | if (!active_crtc_cnt) |
| 3439 | seq_puts(m, "No active crtc found\n"); |
| 3440 | |
| 3441 | return 0; |
| 3442 | } |
| 3443 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3444 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3445 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3446 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3447 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3448 | struct intel_encoder *intel_encoder; |
| 3449 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3450 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3451 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3452 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3453 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3454 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3455 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3456 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3457 | |
| 3458 | intel_encoder = intel_attached_encoder(connector); |
| 3459 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3460 | continue; |
| 3461 | |
| 3462 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3463 | if (!intel_dig_port->dp.can_mst) |
| 3464 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3465 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3466 | seq_printf(m, "MST Source Port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3467 | port_name(intel_dig_port->base.port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3468 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3469 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3470 | drm_connector_list_iter_end(&conn_iter); |
| 3471 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3472 | return 0; |
| 3473 | } |
| 3474 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3475 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3476 | const char __user *ubuf, |
| 3477 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3478 | { |
| 3479 | char *input_buffer; |
| 3480 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3481 | struct drm_device *dev; |
| 3482 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3483 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3484 | struct intel_dp *intel_dp; |
| 3485 | int val = 0; |
| 3486 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3487 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3488 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3489 | if (len == 0) |
| 3490 | return 0; |
| 3491 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3492 | input_buffer = memdup_user_nul(ubuf, len); |
| 3493 | if (IS_ERR(input_buffer)) |
| 3494 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3495 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3496 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3497 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3498 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3499 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3500 | struct intel_encoder *encoder; |
| 3501 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3502 | if (connector->connector_type != |
| 3503 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3504 | continue; |
| 3505 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3506 | encoder = to_intel_encoder(connector->encoder); |
| 3507 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3508 | continue; |
| 3509 | |
| 3510 | if (encoder && connector->status == connector_status_connected) { |
| 3511 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3512 | status = kstrtoint(input_buffer, 10, &val); |
| 3513 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3514 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3515 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3516 | /* To prevent erroneous activation of the compliance |
| 3517 | * testing code, only accept an actual value of 1 here |
| 3518 | */ |
| 3519 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3520 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3521 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3522 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3523 | } |
| 3524 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3525 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3526 | kfree(input_buffer); |
| 3527 | if (status < 0) |
| 3528 | return status; |
| 3529 | |
| 3530 | *offp += len; |
| 3531 | return len; |
| 3532 | } |
| 3533 | |
| 3534 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3535 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3536 | struct drm_i915_private *dev_priv = m->private; |
| 3537 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3538 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3539 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3540 | struct intel_dp *intel_dp; |
| 3541 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3542 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3543 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3544 | struct intel_encoder *encoder; |
| 3545 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3546 | if (connector->connector_type != |
| 3547 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3548 | continue; |
| 3549 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3550 | encoder = to_intel_encoder(connector->encoder); |
| 3551 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3552 | continue; |
| 3553 | |
| 3554 | if (encoder && connector->status == connector_status_connected) { |
| 3555 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3556 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3557 | seq_puts(m, "1"); |
| 3558 | else |
| 3559 | seq_puts(m, "0"); |
| 3560 | } else |
| 3561 | seq_puts(m, "0"); |
| 3562 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3563 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3564 | |
| 3565 | return 0; |
| 3566 | } |
| 3567 | |
| 3568 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3569 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3570 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3571 | return single_open(file, i915_displayport_test_active_show, |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3572 | inode->i_private); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3573 | } |
| 3574 | |
| 3575 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3576 | .owner = THIS_MODULE, |
| 3577 | .open = i915_displayport_test_active_open, |
| 3578 | .read = seq_read, |
| 3579 | .llseek = seq_lseek, |
| 3580 | .release = single_release, |
| 3581 | .write = i915_displayport_test_active_write |
| 3582 | }; |
| 3583 | |
| 3584 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3585 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3586 | struct drm_i915_private *dev_priv = m->private; |
| 3587 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3588 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3589 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3590 | struct intel_dp *intel_dp; |
| 3591 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3592 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3593 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3594 | struct intel_encoder *encoder; |
| 3595 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3596 | if (connector->connector_type != |
| 3597 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3598 | continue; |
| 3599 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3600 | encoder = to_intel_encoder(connector->encoder); |
| 3601 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3602 | continue; |
| 3603 | |
| 3604 | if (encoder && connector->status == connector_status_connected) { |
| 3605 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3606 | if (intel_dp->compliance.test_type == |
| 3607 | DP_TEST_LINK_EDID_READ) |
| 3608 | seq_printf(m, "%lx", |
| 3609 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3610 | else if (intel_dp->compliance.test_type == |
| 3611 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3612 | seq_printf(m, "hdisplay: %d\n", |
| 3613 | intel_dp->compliance.test_data.hdisplay); |
| 3614 | seq_printf(m, "vdisplay: %d\n", |
| 3615 | intel_dp->compliance.test_data.vdisplay); |
| 3616 | seq_printf(m, "bpc: %u\n", |
| 3617 | intel_dp->compliance.test_data.bpc); |
| 3618 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3619 | } else |
| 3620 | seq_puts(m, "0"); |
| 3621 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3622 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3623 | |
| 3624 | return 0; |
| 3625 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3626 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3627 | |
| 3628 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3629 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3630 | struct drm_i915_private *dev_priv = m->private; |
| 3631 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3632 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3633 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3634 | struct intel_dp *intel_dp; |
| 3635 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3636 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3637 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3638 | struct intel_encoder *encoder; |
| 3639 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3640 | if (connector->connector_type != |
| 3641 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3642 | continue; |
| 3643 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3644 | encoder = to_intel_encoder(connector->encoder); |
| 3645 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3646 | continue; |
| 3647 | |
| 3648 | if (encoder && connector->status == connector_status_connected) { |
| 3649 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3650 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3651 | } else |
| 3652 | seq_puts(m, "0"); |
| 3653 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3654 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3655 | |
| 3656 | return 0; |
| 3657 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3658 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3659 | |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3660 | 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] | 3661 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3662 | struct drm_i915_private *dev_priv = m->private; |
| 3663 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3664 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3665 | int num_levels; |
| 3666 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3667 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3668 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3669 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3670 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3671 | else if (IS_G4X(dev_priv)) |
| 3672 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3673 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3674 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3675 | |
| 3676 | drm_modeset_lock_all(dev); |
| 3677 | |
| 3678 | for (level = 0; level < num_levels; level++) { |
| 3679 | unsigned int latency = wm[level]; |
| 3680 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3681 | /* |
| 3682 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3683 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3684 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3685 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3686 | IS_VALLEYVIEW(dev_priv) || |
| 3687 | IS_CHERRYVIEW(dev_priv) || |
| 3688 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3689 | latency *= 10; |
| 3690 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3691 | latency *= 5; |
| 3692 | |
| 3693 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3694 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3695 | } |
| 3696 | |
| 3697 | drm_modeset_unlock_all(dev); |
| 3698 | } |
| 3699 | |
| 3700 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3701 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3702 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3703 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3704 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3705 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3706 | latencies = dev_priv->wm.skl_latency; |
| 3707 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3708 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3709 | |
| 3710 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3711 | |
| 3712 | return 0; |
| 3713 | } |
| 3714 | |
| 3715 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3716 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3717 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3718 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3719 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3720 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3721 | latencies = dev_priv->wm.skl_latency; |
| 3722 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3723 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3724 | |
| 3725 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3726 | |
| 3727 | return 0; |
| 3728 | } |
| 3729 | |
| 3730 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3731 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3732 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3733 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3734 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3735 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3736 | latencies = dev_priv->wm.skl_latency; |
| 3737 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3738 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3739 | |
| 3740 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3741 | |
| 3742 | return 0; |
| 3743 | } |
| 3744 | |
| 3745 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3746 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3747 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3748 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3749 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3750 | return -ENODEV; |
| 3751 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3752 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3753 | } |
| 3754 | |
| 3755 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3756 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3757 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3758 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3759 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3760 | return -ENODEV; |
| 3761 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3762 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3763 | } |
| 3764 | |
| 3765 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3766 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3767 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3768 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3769 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3770 | return -ENODEV; |
| 3771 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3772 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3773 | } |
| 3774 | |
| 3775 | 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] | 3776 | size_t len, loff_t *offp, u16 wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3777 | { |
| 3778 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3779 | struct drm_i915_private *dev_priv = m->private; |
| 3780 | struct drm_device *dev = &dev_priv->drm; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3781 | u16 new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3782 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3783 | int level; |
| 3784 | int ret; |
| 3785 | char tmp[32]; |
| 3786 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3787 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3788 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3789 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3790 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3791 | else if (IS_G4X(dev_priv)) |
| 3792 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3793 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3794 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3795 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3796 | if (len >= sizeof(tmp)) |
| 3797 | return -EINVAL; |
| 3798 | |
| 3799 | if (copy_from_user(tmp, ubuf, len)) |
| 3800 | return -EFAULT; |
| 3801 | |
| 3802 | tmp[len] = '\0'; |
| 3803 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3804 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3805 | &new[0], &new[1], &new[2], &new[3], |
| 3806 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3807 | if (ret != num_levels) |
| 3808 | return -EINVAL; |
| 3809 | |
| 3810 | drm_modeset_lock_all(dev); |
| 3811 | |
| 3812 | for (level = 0; level < num_levels; level++) |
| 3813 | wm[level] = new[level]; |
| 3814 | |
| 3815 | drm_modeset_unlock_all(dev); |
| 3816 | |
| 3817 | return len; |
| 3818 | } |
| 3819 | |
| 3820 | |
| 3821 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3822 | size_t len, loff_t *offp) |
| 3823 | { |
| 3824 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3825 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3826 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3827 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3828 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3829 | latencies = dev_priv->wm.skl_latency; |
| 3830 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3831 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3832 | |
| 3833 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3834 | } |
| 3835 | |
| 3836 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3837 | size_t len, loff_t *offp) |
| 3838 | { |
| 3839 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3840 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3841 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3842 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3843 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3844 | latencies = dev_priv->wm.skl_latency; |
| 3845 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3846 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3847 | |
| 3848 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3849 | } |
| 3850 | |
| 3851 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3852 | size_t len, loff_t *offp) |
| 3853 | { |
| 3854 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3855 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3856 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3857 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3858 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3859 | latencies = dev_priv->wm.skl_latency; |
| 3860 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3861 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3862 | |
| 3863 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3864 | } |
| 3865 | |
| 3866 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3867 | .owner = THIS_MODULE, |
| 3868 | .open = pri_wm_latency_open, |
| 3869 | .read = seq_read, |
| 3870 | .llseek = seq_lseek, |
| 3871 | .release = single_release, |
| 3872 | .write = pri_wm_latency_write |
| 3873 | }; |
| 3874 | |
| 3875 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3876 | .owner = THIS_MODULE, |
| 3877 | .open = spr_wm_latency_open, |
| 3878 | .read = seq_read, |
| 3879 | .llseek = seq_lseek, |
| 3880 | .release = single_release, |
| 3881 | .write = spr_wm_latency_write |
| 3882 | }; |
| 3883 | |
| 3884 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3885 | .owner = THIS_MODULE, |
| 3886 | .open = cur_wm_latency_open, |
| 3887 | .read = seq_read, |
| 3888 | .llseek = seq_lseek, |
| 3889 | .release = single_release, |
| 3890 | .write = cur_wm_latency_write |
| 3891 | }; |
| 3892 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3893 | static int |
| 3894 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3895 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3896 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3897 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 3898 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3899 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3900 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3901 | } |
| 3902 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3903 | static int |
| 3904 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3905 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3906 | struct drm_i915_private *i915 = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3907 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3908 | /* |
| 3909 | * There is no safeguard against this debugfs entry colliding |
| 3910 | * with the hangcheck calling same i915_handle_error() in |
| 3911 | * parallel, causing an explosion. For now we assume that the |
| 3912 | * test harness is responsible enough not to inject gpu hangs |
| 3913 | * while it is writing to 'i915_wedged' |
| 3914 | */ |
| 3915 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3916 | if (i915_reset_backoff(&i915->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3917 | return -EAGAIN; |
| 3918 | |
Chris Wilson | ce80075 | 2018-03-20 10:04:49 +0000 | [diff] [blame] | 3919 | i915_handle_error(i915, val, I915_ERROR_CAPTURE, |
| 3920 | "Manually set wedged engine mask = %llx", val); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3921 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3922 | } |
| 3923 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3924 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3925 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3926 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3927 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3928 | static int |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3929 | fault_irq_set(struct drm_i915_private *i915, |
| 3930 | unsigned long *irq, |
| 3931 | unsigned long val) |
| 3932 | { |
| 3933 | int err; |
| 3934 | |
| 3935 | err = mutex_lock_interruptible(&i915->drm.struct_mutex); |
| 3936 | if (err) |
| 3937 | return err; |
| 3938 | |
| 3939 | err = i915_gem_wait_for_idle(i915, |
| 3940 | I915_WAIT_LOCKED | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 3941 | I915_WAIT_INTERRUPTIBLE, |
| 3942 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3943 | if (err) |
| 3944 | goto err_unlock; |
| 3945 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3946 | *irq = val; |
| 3947 | mutex_unlock(&i915->drm.struct_mutex); |
| 3948 | |
| 3949 | /* Flush idle worker to disarm irq */ |
Chris Wilson | 7c26240 | 2017-10-06 11:40:38 +0100 | [diff] [blame] | 3950 | drain_delayed_work(&i915->gt.idle_work); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3951 | |
| 3952 | return 0; |
| 3953 | |
| 3954 | err_unlock: |
| 3955 | mutex_unlock(&i915->drm.struct_mutex); |
| 3956 | return err; |
| 3957 | } |
| 3958 | |
| 3959 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3960 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 3961 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3962 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3963 | |
| 3964 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 3965 | return 0; |
| 3966 | } |
| 3967 | |
| 3968 | static int |
| 3969 | i915_ring_missed_irq_set(void *data, u64 val) |
| 3970 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3971 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3972 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3973 | return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3974 | } |
| 3975 | |
| 3976 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 3977 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 3978 | "0x%08llx\n"); |
| 3979 | |
| 3980 | static int |
| 3981 | i915_ring_test_irq_get(void *data, u64 *val) |
| 3982 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3983 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3984 | |
| 3985 | *val = dev_priv->gpu_error.test_irq_rings; |
| 3986 | |
| 3987 | return 0; |
| 3988 | } |
| 3989 | |
| 3990 | static int |
| 3991 | i915_ring_test_irq_set(void *data, u64 val) |
| 3992 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3993 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3994 | |
Chris Wilson | 5f52172 | 2018-09-07 12:28:51 +0100 | [diff] [blame] | 3995 | /* GuC keeps the user interrupt permanently enabled for submission */ |
| 3996 | if (USES_GUC_SUBMISSION(i915)) |
| 3997 | return -ENODEV; |
| 3998 | |
| 3999 | /* |
| 4000 | * From icl, we can no longer individually mask interrupt generation |
| 4001 | * from each engine. |
| 4002 | */ |
| 4003 | if (INTEL_GEN(i915) >= 11) |
| 4004 | return -ENODEV; |
| 4005 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4006 | val &= INTEL_INFO(i915)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4007 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4008 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4009 | return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4010 | } |
| 4011 | |
| 4012 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4013 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4014 | "0x%08llx\n"); |
| 4015 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4016 | #define DROP_UNBOUND BIT(0) |
| 4017 | #define DROP_BOUND BIT(1) |
| 4018 | #define DROP_RETIRE BIT(2) |
| 4019 | #define DROP_ACTIVE BIT(3) |
| 4020 | #define DROP_FREED BIT(4) |
| 4021 | #define DROP_SHRINK_ALL BIT(5) |
| 4022 | #define DROP_IDLE BIT(6) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4023 | #define DROP_RESET_ACTIVE BIT(7) |
| 4024 | #define DROP_RESET_SEQNO BIT(8) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4025 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4026 | DROP_BOUND | \ |
| 4027 | DROP_RETIRE | \ |
| 4028 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4029 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4030 | DROP_SHRINK_ALL |\ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4031 | DROP_IDLE | \ |
| 4032 | DROP_RESET_ACTIVE | \ |
| 4033 | DROP_RESET_SEQNO) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4034 | static int |
| 4035 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4036 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4037 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4038 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4039 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4040 | } |
| 4041 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4042 | static int |
| 4043 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4044 | { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4045 | struct drm_i915_private *i915 = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4046 | intel_wakeref_t wakeref; |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4047 | int ret = 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4048 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4049 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 4050 | val, val & DROP_ALL); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4051 | wakeref = intel_runtime_pm_get(i915); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4052 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4053 | if (val & DROP_RESET_ACTIVE && !intel_engines_are_idle(i915)) |
| 4054 | i915_gem_set_wedged(i915); |
| 4055 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4056 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4057 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4058 | if (val & (DROP_ACTIVE | DROP_RETIRE | DROP_RESET_SEQNO)) { |
| 4059 | ret = mutex_lock_interruptible(&i915->drm.struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4060 | if (ret) |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 4061 | goto out; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4062 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4063 | if (val & DROP_ACTIVE) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4064 | ret = i915_gem_wait_for_idle(i915, |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4065 | I915_WAIT_INTERRUPTIBLE | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 4066 | I915_WAIT_LOCKED, |
| 4067 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4068 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4069 | if (val & DROP_RETIRE) |
| 4070 | i915_retire_requests(i915); |
| 4071 | |
| 4072 | mutex_unlock(&i915->drm.struct_mutex); |
| 4073 | } |
| 4074 | |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame^] | 4075 | if (val & DROP_RESET_ACTIVE && i915_terminally_wedged(&i915->gpu_error)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4076 | i915_handle_error(i915, ALL_ENGINES, 0, NULL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4077 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4078 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4079 | if (val & DROP_BOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4080 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4081 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4082 | if (val & DROP_UNBOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4083 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4084 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4085 | if (val & DROP_SHRINK_ALL) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4086 | i915_gem_shrink_all(i915); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4087 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4088 | |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 4089 | if (val & DROP_IDLE) { |
| 4090 | do { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4091 | if (READ_ONCE(i915->gt.active_requests)) |
| 4092 | flush_delayed_work(&i915->gt.retire_work); |
| 4093 | drain_delayed_work(&i915->gt.idle_work); |
| 4094 | } while (READ_ONCE(i915->gt.awake)); |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 4095 | } |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4096 | |
Chris Wilson | c9c70471 | 2018-02-19 22:06:31 +0000 | [diff] [blame] | 4097 | if (val & DROP_FREED) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4098 | i915_gem_drain_freed_objects(i915); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4099 | |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 4100 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4101 | intel_runtime_pm_put(i915, wakeref); |
Chris Wilson | 9d3eb2c | 2018-10-15 12:58:56 +0100 | [diff] [blame] | 4102 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4103 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4104 | } |
| 4105 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4106 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4107 | i915_drop_caches_get, i915_drop_caches_set, |
| 4108 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4109 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4110 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4111 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4112 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4113 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4114 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4115 | u32 snpcr = 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4116 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 4117 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4118 | return -ENODEV; |
| 4119 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4120 | with_intel_runtime_pm(dev_priv, wakeref) |
| 4121 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4122 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4123 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4124 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4125 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4126 | } |
| 4127 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4128 | static int |
| 4129 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4130 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4131 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4132 | intel_wakeref_t wakeref; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4133 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 4134 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4135 | return -ENODEV; |
| 4136 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4137 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4138 | return -EINVAL; |
| 4139 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4140 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4141 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4142 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4143 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4144 | /* Update the cache sharing policy here as well */ |
| 4145 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4146 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4147 | snpcr |= val << GEN6_MBC_SNPCR_SHIFT; |
| 4148 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4149 | } |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4150 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4151 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4152 | } |
| 4153 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4154 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4155 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4156 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4157 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4158 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4159 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4160 | { |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4161 | #define SS_MAX 2 |
| 4162 | const int ss_max = SS_MAX; |
| 4163 | u32 sig1[SS_MAX], sig2[SS_MAX]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4164 | int ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4165 | |
| 4166 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4167 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4168 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4169 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4170 | |
| 4171 | for (ss = 0; ss < ss_max; ss++) { |
| 4172 | unsigned int eu_cnt; |
| 4173 | |
| 4174 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4175 | /* skip disabled subslice */ |
| 4176 | continue; |
| 4177 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4178 | sseu->slice_mask = BIT(0); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4179 | sseu->subslice_mask[0] |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4180 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4181 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4182 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4183 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4184 | sseu->eu_total += eu_cnt; |
| 4185 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4186 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4187 | } |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4188 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4189 | } |
| 4190 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4191 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4192 | struct sseu_dev_info *sseu) |
| 4193 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4194 | #define SS_MAX 6 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4195 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4196 | 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] | 4197 | int s, ss; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4198 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4199 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4200 | /* |
| 4201 | * FIXME: Valid SS Mask respects the spec and read |
Alexandre Belloni | 3c64ea8 | 2018-11-20 16:14:15 +0100 | [diff] [blame] | 4202 | * only valid bits for those registers, excluding reserved |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4203 | * although this seems wrong because it would leave many |
| 4204 | * subslices without ACK. |
| 4205 | */ |
| 4206 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4207 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4208 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4209 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4210 | } |
| 4211 | |
| 4212 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4213 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4214 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4215 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4216 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4217 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4218 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4219 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4220 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4221 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4222 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4223 | /* skip disabled slice */ |
| 4224 | continue; |
| 4225 | |
| 4226 | sseu->slice_mask |= BIT(s); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4227 | sseu->subslice_mask[s] = info->sseu.subslice_mask[s]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4228 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4229 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4230 | unsigned int eu_cnt; |
| 4231 | |
| 4232 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4233 | /* skip disabled subslice */ |
| 4234 | continue; |
| 4235 | |
| 4236 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4237 | eu_mask[ss % 2]); |
| 4238 | sseu->eu_total += eu_cnt; |
| 4239 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4240 | sseu->eu_per_subslice, |
| 4241 | eu_cnt); |
| 4242 | } |
| 4243 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4244 | #undef SS_MAX |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4245 | } |
| 4246 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4247 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4248 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4249 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4250 | #define SS_MAX 3 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4251 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4252 | 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] | 4253 | int s, ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4254 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4255 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4256 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4257 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4258 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4259 | } |
| 4260 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4261 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4262 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4263 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4264 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4265 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4266 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4267 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4268 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4269 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4270 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4271 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4272 | /* skip disabled slice */ |
| 4273 | continue; |
| 4274 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4275 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4276 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4277 | if (IS_GEN9_BC(dev_priv)) |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4278 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4279 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4280 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4281 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4282 | unsigned int eu_cnt; |
| 4283 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4284 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4285 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4286 | /* skip disabled subslice */ |
| 4287 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4288 | |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4289 | sseu->subslice_mask[s] |= BIT(ss); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4290 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4291 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4292 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4293 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4294 | sseu->eu_total += eu_cnt; |
| 4295 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4296 | sseu->eu_per_subslice, |
| 4297 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4298 | } |
| 4299 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4300 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4301 | } |
| 4302 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4303 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4304 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4305 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4306 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4307 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4308 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4309 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4310 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4311 | if (sseu->slice_mask) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4312 | sseu->eu_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4313 | RUNTIME_INFO(dev_priv)->sseu.eu_per_subslice; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4314 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4315 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4316 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4317 | } |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4318 | sseu->eu_total = sseu->eu_per_subslice * |
| 4319 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4320 | |
| 4321 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4322 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4323 | u8 subslice_7eu = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4324 | RUNTIME_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4325 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4326 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4327 | } |
| 4328 | } |
| 4329 | } |
| 4330 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4331 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4332 | const struct sseu_dev_info *sseu) |
| 4333 | { |
| 4334 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4335 | const char *type = is_available_info ? "Available" : "Enabled"; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4336 | int s; |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4337 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4338 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4339 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4340 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4341 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4342 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4343 | sseu_subslice_total(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4344 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4345 | seq_printf(m, " %s Slice%i subslices: %u\n", type, |
| 4346 | s, hweight8(sseu->subslice_mask[s])); |
| 4347 | } |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4348 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4349 | sseu->eu_total); |
| 4350 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4351 | sseu->eu_per_subslice); |
| 4352 | |
| 4353 | if (!is_available_info) |
| 4354 | return; |
| 4355 | |
| 4356 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4357 | if (HAS_POOLED_EU(dev_priv)) |
| 4358 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4359 | |
| 4360 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4361 | yesno(sseu->has_slice_pg)); |
| 4362 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4363 | yesno(sseu->has_subslice_pg)); |
| 4364 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4365 | yesno(sseu->has_eu_pg)); |
| 4366 | } |
| 4367 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4368 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4369 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4370 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4371 | struct sseu_dev_info sseu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4372 | intel_wakeref_t wakeref; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4373 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4374 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4375 | return -ENODEV; |
| 4376 | |
| 4377 | seq_puts(m, "SSEU Device Info\n"); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4378 | i915_print_sseu_info(m, true, &RUNTIME_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4379 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4380 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4381 | memset(&sseu, 0, sizeof(sseu)); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4382 | sseu.max_slices = RUNTIME_INFO(dev_priv)->sseu.max_slices; |
| 4383 | sseu.max_subslices = RUNTIME_INFO(dev_priv)->sseu.max_subslices; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4384 | sseu.max_eus_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4385 | RUNTIME_INFO(dev_priv)->sseu.max_eus_per_subslice; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4386 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4387 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4388 | if (IS_CHERRYVIEW(dev_priv)) |
| 4389 | cherryview_sseu_device_status(dev_priv, &sseu); |
| 4390 | else if (IS_BROADWELL(dev_priv)) |
| 4391 | broadwell_sseu_device_status(dev_priv, &sseu); |
| 4392 | else if (IS_GEN(dev_priv, 9)) |
| 4393 | gen9_sseu_device_status(dev_priv, &sseu); |
| 4394 | else if (INTEL_GEN(dev_priv) >= 10) |
| 4395 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4396 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4397 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4398 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4399 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4400 | return 0; |
| 4401 | } |
| 4402 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4403 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4404 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4405 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4406 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4407 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4408 | return 0; |
| 4409 | |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4410 | file->private_data = (void *)(uintptr_t)intel_runtime_pm_get(i915); |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4411 | intel_uncore_forcewake_user_get(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4412 | |
| 4413 | return 0; |
| 4414 | } |
| 4415 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4416 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4417 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4418 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4419 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4420 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4421 | return 0; |
| 4422 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4423 | intel_uncore_forcewake_user_put(i915); |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4424 | intel_runtime_pm_put(i915, |
| 4425 | (intel_wakeref_t)(uintptr_t)file->private_data); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4426 | |
| 4427 | return 0; |
| 4428 | } |
| 4429 | |
| 4430 | static const struct file_operations i915_forcewake_fops = { |
| 4431 | .owner = THIS_MODULE, |
| 4432 | .open = i915_forcewake_open, |
| 4433 | .release = i915_forcewake_release, |
| 4434 | }; |
| 4435 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4436 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4437 | { |
| 4438 | struct drm_i915_private *dev_priv = m->private; |
| 4439 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4440 | |
Lyude Paul | 6fc5d78 | 2018-11-20 19:37:17 -0500 | [diff] [blame] | 4441 | /* Synchronize with everything first in case there's been an HPD |
| 4442 | * storm, but we haven't finished handling it in the kernel yet |
| 4443 | */ |
| 4444 | synchronize_irq(dev_priv->drm.irq); |
| 4445 | flush_work(&dev_priv->hotplug.dig_port_work); |
| 4446 | flush_work(&dev_priv->hotplug.hotplug_work); |
| 4447 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4448 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4449 | seq_printf(m, "Detected: %s\n", |
| 4450 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4451 | |
| 4452 | return 0; |
| 4453 | } |
| 4454 | |
| 4455 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4456 | const char __user *ubuf, size_t len, |
| 4457 | loff_t *offp) |
| 4458 | { |
| 4459 | struct seq_file *m = file->private_data; |
| 4460 | struct drm_i915_private *dev_priv = m->private; |
| 4461 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4462 | unsigned int new_threshold; |
| 4463 | int i; |
| 4464 | char *newline; |
| 4465 | char tmp[16]; |
| 4466 | |
| 4467 | if (len >= sizeof(tmp)) |
| 4468 | return -EINVAL; |
| 4469 | |
| 4470 | if (copy_from_user(tmp, ubuf, len)) |
| 4471 | return -EFAULT; |
| 4472 | |
| 4473 | tmp[len] = '\0'; |
| 4474 | |
| 4475 | /* Strip newline, if any */ |
| 4476 | newline = strchr(tmp, '\n'); |
| 4477 | if (newline) |
| 4478 | *newline = '\0'; |
| 4479 | |
| 4480 | if (strcmp(tmp, "reset") == 0) |
| 4481 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4482 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4483 | return -EINVAL; |
| 4484 | |
| 4485 | if (new_threshold > 0) |
| 4486 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4487 | new_threshold); |
| 4488 | else |
| 4489 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4490 | |
| 4491 | spin_lock_irq(&dev_priv->irq_lock); |
| 4492 | hotplug->hpd_storm_threshold = new_threshold; |
| 4493 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4494 | for_each_hpd_pin(i) |
| 4495 | hotplug->stats[i].count = 0; |
| 4496 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4497 | |
| 4498 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4499 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4500 | |
| 4501 | return len; |
| 4502 | } |
| 4503 | |
| 4504 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4505 | { |
| 4506 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4507 | } |
| 4508 | |
| 4509 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4510 | .owner = THIS_MODULE, |
| 4511 | .open = i915_hpd_storm_ctl_open, |
| 4512 | .read = seq_read, |
| 4513 | .llseek = seq_lseek, |
| 4514 | .release = single_release, |
| 4515 | .write = i915_hpd_storm_ctl_write |
| 4516 | }; |
| 4517 | |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4518 | static int i915_hpd_short_storm_ctl_show(struct seq_file *m, void *data) |
| 4519 | { |
| 4520 | struct drm_i915_private *dev_priv = m->private; |
| 4521 | |
| 4522 | seq_printf(m, "Enabled: %s\n", |
| 4523 | yesno(dev_priv->hotplug.hpd_short_storm_enabled)); |
| 4524 | |
| 4525 | return 0; |
| 4526 | } |
| 4527 | |
| 4528 | static int |
| 4529 | i915_hpd_short_storm_ctl_open(struct inode *inode, struct file *file) |
| 4530 | { |
| 4531 | return single_open(file, i915_hpd_short_storm_ctl_show, |
| 4532 | inode->i_private); |
| 4533 | } |
| 4534 | |
| 4535 | static ssize_t i915_hpd_short_storm_ctl_write(struct file *file, |
| 4536 | const char __user *ubuf, |
| 4537 | size_t len, loff_t *offp) |
| 4538 | { |
| 4539 | struct seq_file *m = file->private_data; |
| 4540 | struct drm_i915_private *dev_priv = m->private; |
| 4541 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4542 | char *newline; |
| 4543 | char tmp[16]; |
| 4544 | int i; |
| 4545 | bool new_state; |
| 4546 | |
| 4547 | if (len >= sizeof(tmp)) |
| 4548 | return -EINVAL; |
| 4549 | |
| 4550 | if (copy_from_user(tmp, ubuf, len)) |
| 4551 | return -EFAULT; |
| 4552 | |
| 4553 | tmp[len] = '\0'; |
| 4554 | |
| 4555 | /* Strip newline, if any */ |
| 4556 | newline = strchr(tmp, '\n'); |
| 4557 | if (newline) |
| 4558 | *newline = '\0'; |
| 4559 | |
| 4560 | /* Reset to the "default" state for this system */ |
| 4561 | if (strcmp(tmp, "reset") == 0) |
| 4562 | new_state = !HAS_DP_MST(dev_priv); |
| 4563 | else if (kstrtobool(tmp, &new_state) != 0) |
| 4564 | return -EINVAL; |
| 4565 | |
| 4566 | DRM_DEBUG_KMS("%sabling HPD short storm detection\n", |
| 4567 | new_state ? "En" : "Dis"); |
| 4568 | |
| 4569 | spin_lock_irq(&dev_priv->irq_lock); |
| 4570 | hotplug->hpd_short_storm_enabled = new_state; |
| 4571 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4572 | for_each_hpd_pin(i) |
| 4573 | hotplug->stats[i].count = 0; |
| 4574 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4575 | |
| 4576 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4577 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4578 | |
| 4579 | return len; |
| 4580 | } |
| 4581 | |
| 4582 | static const struct file_operations i915_hpd_short_storm_ctl_fops = { |
| 4583 | .owner = THIS_MODULE, |
| 4584 | .open = i915_hpd_short_storm_ctl_open, |
| 4585 | .read = seq_read, |
| 4586 | .llseek = seq_lseek, |
| 4587 | .release = single_release, |
| 4588 | .write = i915_hpd_short_storm_ctl_write, |
| 4589 | }; |
| 4590 | |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4591 | static int i915_drrs_ctl_set(void *data, u64 val) |
| 4592 | { |
| 4593 | struct drm_i915_private *dev_priv = data; |
| 4594 | struct drm_device *dev = &dev_priv->drm; |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4595 | struct intel_crtc *crtc; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4596 | |
| 4597 | if (INTEL_GEN(dev_priv) < 7) |
| 4598 | return -ENODEV; |
| 4599 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4600 | for_each_intel_crtc(dev, crtc) { |
| 4601 | struct drm_connector_list_iter conn_iter; |
| 4602 | struct intel_crtc_state *crtc_state; |
| 4603 | struct drm_connector *connector; |
| 4604 | struct drm_crtc_commit *commit; |
| 4605 | int ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4606 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4607 | ret = drm_modeset_lock_single_interruptible(&crtc->base.mutex); |
| 4608 | if (ret) |
| 4609 | return ret; |
| 4610 | |
| 4611 | crtc_state = to_intel_crtc_state(crtc->base.state); |
| 4612 | |
| 4613 | if (!crtc_state->base.active || |
| 4614 | !crtc_state->has_drrs) |
| 4615 | goto out; |
| 4616 | |
| 4617 | commit = crtc_state->base.commit; |
| 4618 | if (commit) { |
| 4619 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4620 | if (ret) |
| 4621 | goto out; |
| 4622 | } |
| 4623 | |
| 4624 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 4625 | drm_for_each_connector_iter(connector, &conn_iter) { |
| 4626 | struct intel_encoder *encoder; |
| 4627 | struct intel_dp *intel_dp; |
| 4628 | |
| 4629 | if (!(crtc_state->base.connector_mask & |
| 4630 | drm_connector_mask(connector))) |
| 4631 | continue; |
| 4632 | |
| 4633 | encoder = intel_attached_encoder(connector); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4634 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 4635 | continue; |
| 4636 | |
| 4637 | DRM_DEBUG_DRIVER("Manually %sabling DRRS. %llu\n", |
| 4638 | val ? "en" : "dis", val); |
| 4639 | |
| 4640 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 4641 | if (val) |
| 4642 | intel_edp_drrs_enable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4643 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4644 | else |
| 4645 | intel_edp_drrs_disable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4646 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4647 | } |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4648 | drm_connector_list_iter_end(&conn_iter); |
| 4649 | |
| 4650 | out: |
| 4651 | drm_modeset_unlock(&crtc->base.mutex); |
| 4652 | if (ret) |
| 4653 | return ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4654 | } |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4655 | |
| 4656 | return 0; |
| 4657 | } |
| 4658 | |
| 4659 | DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); |
| 4660 | |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4661 | static ssize_t |
| 4662 | i915_fifo_underrun_reset_write(struct file *filp, |
| 4663 | const char __user *ubuf, |
| 4664 | size_t cnt, loff_t *ppos) |
| 4665 | { |
| 4666 | struct drm_i915_private *dev_priv = filp->private_data; |
| 4667 | struct intel_crtc *intel_crtc; |
| 4668 | struct drm_device *dev = &dev_priv->drm; |
| 4669 | int ret; |
| 4670 | bool reset; |
| 4671 | |
| 4672 | ret = kstrtobool_from_user(ubuf, cnt, &reset); |
| 4673 | if (ret) |
| 4674 | return ret; |
| 4675 | |
| 4676 | if (!reset) |
| 4677 | return cnt; |
| 4678 | |
| 4679 | for_each_intel_crtc(dev, intel_crtc) { |
| 4680 | struct drm_crtc_commit *commit; |
| 4681 | struct intel_crtc_state *crtc_state; |
| 4682 | |
| 4683 | ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); |
| 4684 | if (ret) |
| 4685 | return ret; |
| 4686 | |
| 4687 | crtc_state = to_intel_crtc_state(intel_crtc->base.state); |
| 4688 | commit = crtc_state->base.commit; |
| 4689 | if (commit) { |
| 4690 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4691 | if (!ret) |
| 4692 | ret = wait_for_completion_interruptible(&commit->flip_done); |
| 4693 | } |
| 4694 | |
| 4695 | if (!ret && crtc_state->base.active) { |
| 4696 | DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", |
| 4697 | pipe_name(intel_crtc->pipe)); |
| 4698 | |
| 4699 | intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); |
| 4700 | } |
| 4701 | |
| 4702 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 4703 | |
| 4704 | if (ret) |
| 4705 | return ret; |
| 4706 | } |
| 4707 | |
| 4708 | ret = intel_fbc_reset_underrun(dev_priv); |
| 4709 | if (ret) |
| 4710 | return ret; |
| 4711 | |
| 4712 | return cnt; |
| 4713 | } |
| 4714 | |
| 4715 | static const struct file_operations i915_fifo_underrun_reset_ops = { |
| 4716 | .owner = THIS_MODULE, |
| 4717 | .open = simple_open, |
| 4718 | .write = i915_fifo_underrun_reset_write, |
| 4719 | .llseek = default_llseek, |
| 4720 | }; |
| 4721 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4722 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4723 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4724 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4725 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4726 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4727 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4728 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4729 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4730 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4731 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4732 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4733 | {"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] | 4734 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4735 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4736 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4737 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4738 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4739 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4740 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4741 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4742 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4743 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4744 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4745 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4746 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4747 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4748 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4749 | {"i915_context_status", i915_context_status, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4750 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4751 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4752 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4753 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4754 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4755 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4756 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4757 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4758 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4759 | {"i915_engine_info", i915_engine_info, 0}, |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 4760 | {"i915_rcs_topology", i915_rcs_topology, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4761 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4762 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4763 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4764 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4765 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4766 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4767 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4768 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4769 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4770 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4771 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4772 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4773 | const char *name; |
| 4774 | const struct file_operations *fops; |
| 4775 | } i915_debugfs_files[] = { |
| 4776 | {"i915_wedged", &i915_wedged_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4777 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4778 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4779 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4780 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4781 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4782 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4783 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4784 | #endif |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4785 | {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4786 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4787 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4788 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4789 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4790 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4791 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4792 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 4793 | {"i915_guc_log_level", &i915_guc_log_level_fops}, |
| 4794 | {"i915_guc_log_relay", &i915_guc_log_relay_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4795 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4796 | {"i915_hpd_short_storm_ctl", &i915_hpd_short_storm_ctl_fops}, |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4797 | {"i915_ipc_status", &i915_ipc_status_fops}, |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4798 | {"i915_drrs_ctl", &i915_drrs_ctl_fops}, |
| 4799 | {"i915_edp_psr_debug", &i915_edp_psr_debug_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4800 | }; |
| 4801 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4802 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4803 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4804 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4805 | struct dentry *ent; |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 4806 | int i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4807 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4808 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4809 | minor->debugfs_root, to_i915(minor->dev), |
| 4810 | &i915_forcewake_fops); |
| 4811 | if (!ent) |
| 4812 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4813 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4814 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4815 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4816 | S_IRUGO | S_IWUSR, |
| 4817 | minor->debugfs_root, |
| 4818 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4819 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4820 | if (!ent) |
| 4821 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4822 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4823 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4824 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4825 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4826 | minor->debugfs_root, minor); |
| 4827 | } |
| 4828 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4829 | struct dpcd_block { |
| 4830 | /* DPCD dump start address. */ |
| 4831 | unsigned int offset; |
| 4832 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4833 | unsigned int end; |
| 4834 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4835 | size_t size; |
| 4836 | /* Only valid for eDP. */ |
| 4837 | bool edp; |
| 4838 | }; |
| 4839 | |
| 4840 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4841 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4842 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4843 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4844 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4845 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4846 | { .offset = DP_SET_POWER }, |
| 4847 | { .offset = DP_EDP_DPCD_REV }, |
| 4848 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4849 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4850 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4851 | }; |
| 4852 | |
| 4853 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4854 | { |
| 4855 | struct drm_connector *connector = m->private; |
| 4856 | struct intel_dp *intel_dp = |
| 4857 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 4858 | u8 buf[16]; |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4859 | ssize_t err; |
| 4860 | int i; |
| 4861 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4862 | if (connector->status != connector_status_connected) |
| 4863 | return -ENODEV; |
| 4864 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4865 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4866 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4867 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4868 | |
| 4869 | if (b->edp && |
| 4870 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4871 | continue; |
| 4872 | |
| 4873 | /* low tech for now */ |
| 4874 | if (WARN_ON(size > sizeof(buf))) |
| 4875 | continue; |
| 4876 | |
| 4877 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
Chris Wilson | 65404c8 | 2018-10-10 09:17:06 +0100 | [diff] [blame] | 4878 | if (err < 0) |
| 4879 | seq_printf(m, "%04x: ERROR %d\n", b->offset, (int)err); |
| 4880 | else |
| 4881 | seq_printf(m, "%04x: %*ph\n", b->offset, (int)err, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4882 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4883 | |
| 4884 | return 0; |
| 4885 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4886 | DEFINE_SHOW_ATTRIBUTE(i915_dpcd); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4887 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4888 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4889 | { |
| 4890 | struct drm_connector *connector = m->private; |
| 4891 | struct intel_dp *intel_dp = |
| 4892 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4893 | |
| 4894 | if (connector->status != connector_status_connected) |
| 4895 | return -ENODEV; |
| 4896 | |
| 4897 | seq_printf(m, "Panel power up delay: %d\n", |
| 4898 | intel_dp->panel_power_up_delay); |
| 4899 | seq_printf(m, "Panel power down delay: %d\n", |
| 4900 | intel_dp->panel_power_down_delay); |
| 4901 | seq_printf(m, "Backlight on delay: %d\n", |
| 4902 | intel_dp->backlight_on_delay); |
| 4903 | seq_printf(m, "Backlight off delay: %d\n", |
| 4904 | intel_dp->backlight_off_delay); |
| 4905 | |
| 4906 | return 0; |
| 4907 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4908 | DEFINE_SHOW_ATTRIBUTE(i915_panel); |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4909 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4910 | static int i915_hdcp_sink_capability_show(struct seq_file *m, void *data) |
| 4911 | { |
| 4912 | struct drm_connector *connector = m->private; |
| 4913 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 4914 | |
| 4915 | if (connector->status != connector_status_connected) |
| 4916 | return -ENODEV; |
| 4917 | |
| 4918 | /* HDCP is supported by connector */ |
Ramalingam C | d3dacc7 | 2018-10-29 15:15:46 +0530 | [diff] [blame] | 4919 | if (!intel_connector->hdcp.shim) |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4920 | return -EINVAL; |
| 4921 | |
| 4922 | seq_printf(m, "%s:%d HDCP version: ", connector->name, |
| 4923 | connector->base.id); |
| 4924 | seq_printf(m, "%s ", !intel_hdcp_capable(intel_connector) ? |
| 4925 | "None" : "HDCP1.4"); |
| 4926 | seq_puts(m, "\n"); |
| 4927 | |
| 4928 | return 0; |
| 4929 | } |
| 4930 | DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability); |
| 4931 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4932 | static int i915_dsc_fec_support_show(struct seq_file *m, void *data) |
| 4933 | { |
| 4934 | struct drm_connector *connector = m->private; |
| 4935 | struct drm_device *dev = connector->dev; |
| 4936 | struct drm_crtc *crtc; |
| 4937 | struct intel_dp *intel_dp; |
| 4938 | struct drm_modeset_acquire_ctx ctx; |
| 4939 | struct intel_crtc_state *crtc_state = NULL; |
| 4940 | int ret = 0; |
| 4941 | bool try_again = false; |
| 4942 | |
| 4943 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 4944 | |
| 4945 | do { |
Manasi Navare | 6afe892 | 2018-12-19 15:51:20 -0800 | [diff] [blame] | 4946 | try_again = false; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4947 | ret = drm_modeset_lock(&dev->mode_config.connection_mutex, |
| 4948 | &ctx); |
| 4949 | if (ret) { |
| 4950 | ret = -EINTR; |
| 4951 | break; |
| 4952 | } |
| 4953 | crtc = connector->state->crtc; |
| 4954 | if (connector->status != connector_status_connected || !crtc) { |
| 4955 | ret = -ENODEV; |
| 4956 | break; |
| 4957 | } |
| 4958 | ret = drm_modeset_lock(&crtc->mutex, &ctx); |
| 4959 | if (ret == -EDEADLK) { |
| 4960 | ret = drm_modeset_backoff(&ctx); |
| 4961 | if (!ret) { |
| 4962 | try_again = true; |
| 4963 | continue; |
| 4964 | } |
| 4965 | break; |
| 4966 | } else if (ret) { |
| 4967 | break; |
| 4968 | } |
| 4969 | intel_dp = enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4970 | crtc_state = to_intel_crtc_state(crtc->state); |
| 4971 | seq_printf(m, "DSC_Enabled: %s\n", |
| 4972 | yesno(crtc_state->dsc_params.compression_enable)); |
Radhakrishna Sripada | fed8569 | 2019-01-09 13:14:14 -0800 | [diff] [blame] | 4973 | seq_printf(m, "DSC_Sink_Support: %s\n", |
| 4974 | yesno(drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd))); |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4975 | if (!intel_dp_is_edp(intel_dp)) |
| 4976 | seq_printf(m, "FEC_Sink_Support: %s\n", |
| 4977 | yesno(drm_dp_sink_supports_fec(intel_dp->fec_capable))); |
| 4978 | } while (try_again); |
| 4979 | |
| 4980 | drm_modeset_drop_locks(&ctx); |
| 4981 | drm_modeset_acquire_fini(&ctx); |
| 4982 | |
| 4983 | return ret; |
| 4984 | } |
| 4985 | |
| 4986 | static ssize_t i915_dsc_fec_support_write(struct file *file, |
| 4987 | const char __user *ubuf, |
| 4988 | size_t len, loff_t *offp) |
| 4989 | { |
| 4990 | bool dsc_enable = false; |
| 4991 | int ret; |
| 4992 | struct drm_connector *connector = |
| 4993 | ((struct seq_file *)file->private_data)->private; |
| 4994 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
| 4995 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 4996 | |
| 4997 | if (len == 0) |
| 4998 | return 0; |
| 4999 | |
| 5000 | DRM_DEBUG_DRIVER("Copied %zu bytes from user to force DSC\n", |
| 5001 | len); |
| 5002 | |
| 5003 | ret = kstrtobool_from_user(ubuf, len, &dsc_enable); |
| 5004 | if (ret < 0) |
| 5005 | return ret; |
| 5006 | |
| 5007 | DRM_DEBUG_DRIVER("Got %s for DSC Enable\n", |
| 5008 | (dsc_enable) ? "true" : "false"); |
| 5009 | intel_dp->force_dsc_en = dsc_enable; |
| 5010 | |
| 5011 | *offp += len; |
| 5012 | return len; |
| 5013 | } |
| 5014 | |
| 5015 | static int i915_dsc_fec_support_open(struct inode *inode, |
| 5016 | struct file *file) |
| 5017 | { |
| 5018 | return single_open(file, i915_dsc_fec_support_show, |
| 5019 | inode->i_private); |
| 5020 | } |
| 5021 | |
| 5022 | static const struct file_operations i915_dsc_fec_support_fops = { |
| 5023 | .owner = THIS_MODULE, |
| 5024 | .open = i915_dsc_fec_support_open, |
| 5025 | .read = seq_read, |
| 5026 | .llseek = seq_lseek, |
| 5027 | .release = single_release, |
| 5028 | .write = i915_dsc_fec_support_write |
| 5029 | }; |
| 5030 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5031 | /** |
| 5032 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5033 | * @connector: pointer to a registered drm_connector |
| 5034 | * |
| 5035 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5036 | * drm_debugfs_connector_remove(). |
| 5037 | * |
| 5038 | * Returns 0 on success, negative error codes on error. |
| 5039 | */ |
| 5040 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5041 | { |
| 5042 | struct dentry *root = connector->debugfs_entry; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 5043 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5044 | |
| 5045 | /* The connector must have been registered beforehands. */ |
| 5046 | if (!root) |
| 5047 | return -ENODEV; |
| 5048 | |
| 5049 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5050 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5051 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5052 | connector, &i915_dpcd_fops); |
| 5053 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 5054 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5055 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5056 | connector, &i915_panel_fops); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 5057 | debugfs_create_file("i915_psr_sink_status", S_IRUGO, root, |
| 5058 | connector, &i915_psr_sink_status_fops); |
| 5059 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5060 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 5061 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5062 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || |
| 5063 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { |
| 5064 | debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, |
| 5065 | connector, &i915_hdcp_sink_capability_fops); |
| 5066 | } |
| 5067 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 5068 | if (INTEL_GEN(dev_priv) >= 10 && |
| 5069 | (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5070 | connector->connector_type == DRM_MODE_CONNECTOR_eDP)) |
| 5071 | debugfs_create_file("i915_dsc_fec_support", S_IRUGO, root, |
| 5072 | connector, &i915_dsc_fec_support_fops); |
| 5073 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5074 | return 0; |
| 5075 | } |