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 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 35 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 36 | { |
| 37 | return to_i915(node->minor->dev); |
| 38 | } |
| 39 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 40 | static int i915_capabilities(struct seq_file *m, void *data) |
| 41 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 42 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 43 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 44 | struct drm_printer p = drm_seq_file_printer(m); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 45 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 46 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 47 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 48 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 49 | |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 50 | intel_device_info_dump_flags(info, &p); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 51 | intel_device_info_dump_runtime(RUNTIME_INFO(dev_priv), &p); |
Chris Wilson | 3fed180 | 2018-02-07 21:05:43 +0000 | [diff] [blame] | 52 | intel_driver_caps_print(&dev_priv->caps, &p); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 53 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 54 | kernel_param_lock(THIS_MODULE); |
Michal Wajdeczko | acfb997 | 2017-12-19 11:43:46 +0000 | [diff] [blame] | 55 | i915_params_dump(&i915_modparams, &p); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 56 | kernel_param_unlock(THIS_MODULE); |
| 57 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 58 | return 0; |
| 59 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 60 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 61 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 62 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 63 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 66 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 67 | { |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 68 | return obj->pin_global ? 'p' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 69 | } |
| 70 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 71 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 72 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 73 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 74 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 75 | case I915_TILING_NONE: return ' '; |
| 76 | case I915_TILING_X: return 'X'; |
| 77 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 78 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 81 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 82 | { |
Chris Wilson | a65adaf | 2017-10-09 09:43:57 +0100 | [diff] [blame] | 83 | return obj->userfault_count ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 84 | } |
| 85 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 86 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 87 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 88 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 91 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 92 | { |
| 93 | u64 size = 0; |
| 94 | struct i915_vma *vma; |
| 95 | |
Chris Wilson | e2189dd | 2017-12-07 21:14:07 +0000 | [diff] [blame] | 96 | for_each_ggtt_vma(vma, obj) { |
| 97 | if (drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 98 | size += vma->node.size; |
| 99 | } |
| 100 | |
| 101 | return size; |
| 102 | } |
| 103 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 104 | static const char * |
| 105 | stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len) |
| 106 | { |
| 107 | size_t x = 0; |
| 108 | |
| 109 | switch (page_sizes) { |
| 110 | case 0: |
| 111 | return ""; |
| 112 | case I915_GTT_PAGE_SIZE_4K: |
| 113 | return "4K"; |
| 114 | case I915_GTT_PAGE_SIZE_64K: |
| 115 | return "64K"; |
| 116 | case I915_GTT_PAGE_SIZE_2M: |
| 117 | return "2M"; |
| 118 | default: |
| 119 | if (!buf) |
| 120 | return "M"; |
| 121 | |
| 122 | if (page_sizes & I915_GTT_PAGE_SIZE_2M) |
| 123 | x += snprintf(buf + x, len - x, "2M, "); |
| 124 | if (page_sizes & I915_GTT_PAGE_SIZE_64K) |
| 125 | x += snprintf(buf + x, len - x, "64K, "); |
| 126 | if (page_sizes & I915_GTT_PAGE_SIZE_4K) |
| 127 | x += snprintf(buf + x, len - x, "4K, "); |
| 128 | buf[x-2] = '\0'; |
| 129 | |
| 130 | return buf; |
| 131 | } |
| 132 | } |
| 133 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 134 | static void |
| 135 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 136 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 137 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 138 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 139 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 140 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 141 | int pin_count = 0; |
| 142 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 143 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 144 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 145 | 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] | 146 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 147 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 148 | get_pin_flag(obj), |
| 149 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 150 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 151 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 152 | obj->base.size / 1024, |
Christian König | c0a51fd | 2018-02-16 13:43:38 +0100 | [diff] [blame] | 153 | obj->read_domains, |
| 154 | obj->write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 155 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 156 | obj->mm.dirty ? " dirty" : "", |
| 157 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 158 | if (obj->base.name) |
| 159 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 160 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 161 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 162 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 163 | } |
| 164 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 165 | if (obj->pin_global) |
| 166 | seq_printf(m, " (global)"); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 167 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 168 | if (!drm_mm_node_allocated(&vma->node)) |
| 169 | continue; |
| 170 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 171 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx, pages: %s", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 172 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 173 | vma->node.start, vma->node.size, |
| 174 | stringify_page_sizes(vma->page_sizes.gtt, NULL, 0)); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 175 | if (i915_vma_is_ggtt(vma)) { |
| 176 | switch (vma->ggtt_view.type) { |
| 177 | case I915_GGTT_VIEW_NORMAL: |
| 178 | seq_puts(m, ", normal"); |
| 179 | break; |
| 180 | |
| 181 | case I915_GGTT_VIEW_PARTIAL: |
| 182 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 183 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 184 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 185 | break; |
| 186 | |
| 187 | case I915_GGTT_VIEW_ROTATED: |
| 188 | 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] | 189 | vma->ggtt_view.rotated.plane[0].width, |
| 190 | vma->ggtt_view.rotated.plane[0].height, |
| 191 | vma->ggtt_view.rotated.plane[0].stride, |
| 192 | vma->ggtt_view.rotated.plane[0].offset, |
| 193 | vma->ggtt_view.rotated.plane[1].width, |
| 194 | vma->ggtt_view.rotated.plane[1].height, |
| 195 | vma->ggtt_view.rotated.plane[1].stride, |
| 196 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 197 | break; |
| 198 | |
| 199 | default: |
| 200 | MISSING_CASE(vma->ggtt_view.type); |
| 201 | break; |
| 202 | } |
| 203 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 204 | if (vma->fence) |
| 205 | seq_printf(m, " , fence: %d%s", |
| 206 | vma->fence->id, |
| 207 | i915_gem_active_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 208 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 209 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 210 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 211 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 212 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 213 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 214 | if (engine) |
| 215 | seq_printf(m, " (%s)", engine->name); |
| 216 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 217 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 218 | if (frontbuffer_bits) |
| 219 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 222 | static int obj_rank_by_stolen(const void *A, const void *B) |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 223 | { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 224 | const struct drm_i915_gem_object *a = |
| 225 | *(const struct drm_i915_gem_object **)A; |
| 226 | const struct drm_i915_gem_object *b = |
| 227 | *(const struct drm_i915_gem_object **)B; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 228 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 229 | if (a->stolen->start < b->stolen->start) |
| 230 | return -1; |
| 231 | if (a->stolen->start > b->stolen->start) |
| 232 | return 1; |
| 233 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 237 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 238 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 239 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 240 | struct drm_i915_gem_object **objects; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 241 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 242 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 243 | unsigned long total, count, n; |
| 244 | int ret; |
| 245 | |
| 246 | total = READ_ONCE(dev_priv->mm.object_count); |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 247 | objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 248 | if (!objects) |
| 249 | return -ENOMEM; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 250 | |
| 251 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 252 | if (ret) |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 253 | goto out; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 254 | |
| 255 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 256 | |
| 257 | spin_lock(&dev_priv->mm.obj_lock); |
| 258 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 259 | if (count == total) |
| 260 | break; |
| 261 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 262 | if (obj->stolen == NULL) |
| 263 | continue; |
| 264 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 265 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 266 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 267 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 268 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 269 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 270 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 271 | if (count == total) |
| 272 | break; |
| 273 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 274 | if (obj->stolen == NULL) |
| 275 | continue; |
| 276 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 277 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 278 | total_obj_size += obj->base.size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 279 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 280 | spin_unlock(&dev_priv->mm.obj_lock); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 281 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 282 | sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL); |
| 283 | |
| 284 | seq_puts(m, "Stolen:\n"); |
| 285 | for (n = 0; n < count; n++) { |
| 286 | seq_puts(m, " "); |
| 287 | describe_obj(m, objects[n]); |
| 288 | seq_putc(m, '\n'); |
| 289 | } |
| 290 | seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 291 | count, total_obj_size, total_gtt_size); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 292 | |
| 293 | mutex_unlock(&dev->struct_mutex); |
| 294 | out: |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 295 | kvfree(objects); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 296 | return ret; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 297 | } |
| 298 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 299 | struct file_stats { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 300 | struct i915_address_space *vm; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 301 | unsigned long count; |
| 302 | u64 total, unbound; |
| 303 | u64 global, shared; |
| 304 | u64 active, inactive; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 305 | u64 closed; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | static int per_file_stats(int id, void *ptr, void *data) |
| 309 | { |
| 310 | struct drm_i915_gem_object *obj = ptr; |
| 311 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 312 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 313 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 314 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 315 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 316 | stats->count++; |
| 317 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 318 | if (!obj->bind_count) |
| 319 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 320 | if (obj->base.name || obj->base.dma_buf) |
| 321 | stats->shared += obj->base.size; |
| 322 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 323 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 324 | if (!drm_mm_node_allocated(&vma->node)) |
| 325 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 326 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 327 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 328 | stats->global += vma->node.size; |
| 329 | } else { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 330 | if (vma->vm != stats->vm) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 331 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 332 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 333 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 334 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 335 | stats->active += vma->node.size; |
| 336 | else |
| 337 | stats->inactive += vma->node.size; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 338 | |
| 339 | if (i915_vma_is_closed(vma)) |
| 340 | stats->closed += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | return 0; |
| 344 | } |
| 345 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 346 | #define print_file_stats(m, name, stats) do { \ |
| 347 | if (stats.count) \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 348 | 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] | 349 | name, \ |
| 350 | stats.count, \ |
| 351 | stats.total, \ |
| 352 | stats.active, \ |
| 353 | stats.inactive, \ |
| 354 | stats.global, \ |
| 355 | stats.shared, \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 356 | stats.unbound, \ |
| 357 | stats.closed); \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 358 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 359 | |
| 360 | static void print_batch_pool_stats(struct seq_file *m, |
| 361 | struct drm_i915_private *dev_priv) |
| 362 | { |
| 363 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 364 | struct intel_engine_cs *engine; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 365 | struct file_stats stats = {}; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 366 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 367 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 368 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 369 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 370 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 371 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 372 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 373 | batch_pool_link) |
| 374 | per_file_stats(0, obj, &stats); |
| 375 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 376 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 377 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 378 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 379 | } |
| 380 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 381 | static void print_context_stats(struct seq_file *m, |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 382 | struct drm_i915_private *i915) |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 383 | { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 384 | struct file_stats kstats = {}; |
| 385 | struct i915_gem_context *ctx; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 386 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 387 | list_for_each_entry(ctx, &i915->contexts.list, link) { |
| 388 | struct intel_engine_cs *engine; |
| 389 | enum intel_engine_id id; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 390 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 391 | for_each_engine(engine, i915, id) { |
| 392 | struct intel_context *ce = to_intel_context(ctx, engine); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 393 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 394 | if (ce->state) |
| 395 | per_file_stats(0, ce->state->obj, &kstats); |
| 396 | if (ce->ring) |
| 397 | per_file_stats(0, ce->ring->vma->obj, &kstats); |
| 398 | } |
| 399 | |
| 400 | if (!IS_ERR_OR_NULL(ctx->file_priv)) { |
| 401 | struct file_stats stats = { .vm = &ctx->ppgtt->vm, }; |
| 402 | struct drm_file *file = ctx->file_priv->file; |
| 403 | struct task_struct *task; |
| 404 | char name[80]; |
| 405 | |
| 406 | spin_lock(&file->table_lock); |
| 407 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
| 408 | spin_unlock(&file->table_lock); |
| 409 | |
| 410 | rcu_read_lock(); |
| 411 | task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID); |
| 412 | snprintf(name, sizeof(name), "%s/%d", |
| 413 | task ? task->comm : "<unknown>", |
| 414 | ctx->user_handle); |
| 415 | rcu_read_unlock(); |
| 416 | |
| 417 | print_file_stats(m, name, stats); |
| 418 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 419 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 420 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 421 | print_file_stats(m, "[k]contexts", kstats); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 422 | } |
| 423 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 424 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 425 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 426 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 427 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 428 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 429 | u32 count, mapped_count, purgeable_count, dpy_count, huge_count; |
| 430 | u64 size, mapped_size, purgeable_size, dpy_size, huge_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 431 | struct drm_i915_gem_object *obj; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 432 | unsigned int page_sizes = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 433 | char buf[80]; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 434 | int ret; |
| 435 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 436 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 437 | dev_priv->mm.object_count, |
| 438 | dev_priv->mm.object_memory); |
| 439 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 440 | size = count = 0; |
| 441 | mapped_size = mapped_count = 0; |
| 442 | purgeable_size = purgeable_count = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 443 | huge_size = huge_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 444 | |
| 445 | spin_lock(&dev_priv->mm.obj_lock); |
| 446 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 447 | size += obj->base.size; |
| 448 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 449 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 450 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 451 | purgeable_size += obj->base.size; |
| 452 | ++purgeable_count; |
| 453 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 454 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 455 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 456 | mapped_count++; |
| 457 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 458 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 459 | |
| 460 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 461 | huge_count++; |
| 462 | huge_size += obj->base.size; |
| 463 | page_sizes |= obj->mm.page_sizes.sg; |
| 464 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 465 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 466 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 467 | |
| 468 | size = count = dpy_size = dpy_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 469 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 470 | size += obj->base.size; |
| 471 | ++count; |
| 472 | |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 473 | if (obj->pin_global) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 474 | dpy_size += obj->base.size; |
| 475 | ++dpy_count; |
| 476 | } |
| 477 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 478 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 479 | purgeable_size += obj->base.size; |
| 480 | ++purgeable_count; |
| 481 | } |
| 482 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 483 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 484 | mapped_count++; |
| 485 | mapped_size += obj->base.size; |
| 486 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 487 | |
| 488 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 489 | huge_count++; |
| 490 | huge_size += obj->base.size; |
| 491 | page_sizes |= obj->mm.page_sizes.sg; |
| 492 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 493 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 494 | spin_unlock(&dev_priv->mm.obj_lock); |
| 495 | |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 496 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 497 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 498 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 499 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 500 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 501 | mapped_count, mapped_size); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 502 | seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n", |
| 503 | huge_count, |
| 504 | stringify_page_sizes(page_sizes, buf, sizeof(buf)), |
| 505 | huge_size); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 506 | seq_printf(m, "%u display objects (globally pinned), %llu bytes\n", |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 507 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 508 | |
Matthew Auld | b7128ef | 2017-12-11 15:18:22 +0000 | [diff] [blame] | 509 | seq_printf(m, "%llu [%pa] gtt total\n", |
Chris Wilson | 82ad644 | 2018-06-05 16:37:58 +0100 | [diff] [blame] | 510 | ggtt->vm.total, &ggtt->mappable_end); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 511 | seq_printf(m, "Supported page sizes: %s\n", |
| 512 | stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes, |
| 513 | buf, sizeof(buf))); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 514 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 515 | seq_putc(m, '\n'); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 516 | |
| 517 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 518 | if (ret) |
| 519 | return ret; |
| 520 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 521 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 522 | print_context_stats(m, dev_priv); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 523 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 524 | |
| 525 | return 0; |
| 526 | } |
| 527 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 528 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 529 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 530 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 531 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 532 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 533 | struct drm_i915_gem_object **objects; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 534 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 535 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 536 | unsigned long nobject, n; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 537 | int count, ret; |
| 538 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 539 | nobject = READ_ONCE(dev_priv->mm.object_count); |
| 540 | objects = kvmalloc_array(nobject, sizeof(*objects), GFP_KERNEL); |
| 541 | if (!objects) |
| 542 | return -ENOMEM; |
| 543 | |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 544 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 545 | if (ret) |
| 546 | return ret; |
| 547 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 548 | count = 0; |
| 549 | spin_lock(&dev_priv->mm.obj_lock); |
| 550 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
| 551 | objects[count++] = obj; |
| 552 | if (count == nobject) |
| 553 | break; |
| 554 | } |
| 555 | spin_unlock(&dev_priv->mm.obj_lock); |
| 556 | |
| 557 | total_obj_size = total_gtt_size = 0; |
| 558 | for (n = 0; n < count; n++) { |
| 559 | obj = objects[n]; |
| 560 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 561 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 562 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 563 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 564 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 565 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | mutex_unlock(&dev->struct_mutex); |
| 569 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 570 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 571 | count, total_obj_size, total_gtt_size); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 572 | kvfree(objects); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 573 | |
| 574 | return 0; |
| 575 | } |
| 576 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 577 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 578 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 579 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 580 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 581 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 582 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 583 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 584 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 585 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 586 | |
| 587 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 588 | if (ret) |
| 589 | return ret; |
| 590 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 591 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 592 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 593 | int count; |
| 594 | |
| 595 | count = 0; |
| 596 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 597 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 598 | batch_pool_link) |
| 599 | count++; |
| 600 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 601 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 602 | |
| 603 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 604 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 605 | batch_pool_link) { |
| 606 | seq_puts(m, " "); |
| 607 | describe_obj(m, obj); |
| 608 | seq_putc(m, '\n'); |
| 609 | } |
| 610 | |
| 611 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 612 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 613 | } |
| 614 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 615 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 616 | |
| 617 | mutex_unlock(&dev->struct_mutex); |
| 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 622 | static void gen8_display_interrupt_info(struct seq_file *m) |
| 623 | { |
| 624 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 625 | int pipe; |
| 626 | |
| 627 | for_each_pipe(dev_priv, pipe) { |
| 628 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 629 | intel_wakeref_t wakeref; |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 630 | |
| 631 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 632 | wakeref = intel_display_power_get_if_enabled(dev_priv, |
| 633 | power_domain); |
| 634 | if (!wakeref) { |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 635 | seq_printf(m, "Pipe %c power disabled\n", |
| 636 | pipe_name(pipe)); |
| 637 | continue; |
| 638 | } |
| 639 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
| 640 | pipe_name(pipe), |
| 641 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
| 642 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
| 643 | pipe_name(pipe), |
| 644 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
| 645 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
| 646 | pipe_name(pipe), |
| 647 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
| 648 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 649 | intel_display_power_put(dev_priv, power_domain, wakeref); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 653 | I915_READ(GEN8_DE_PORT_IMR)); |
| 654 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 655 | I915_READ(GEN8_DE_PORT_IIR)); |
| 656 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 657 | I915_READ(GEN8_DE_PORT_IER)); |
| 658 | |
| 659 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 660 | I915_READ(GEN8_DE_MISC_IMR)); |
| 661 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 662 | I915_READ(GEN8_DE_MISC_IIR)); |
| 663 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 664 | I915_READ(GEN8_DE_MISC_IER)); |
| 665 | |
| 666 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 667 | I915_READ(GEN8_PCU_IMR)); |
| 668 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 669 | I915_READ(GEN8_PCU_IIR)); |
| 670 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 671 | I915_READ(GEN8_PCU_IER)); |
| 672 | } |
| 673 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 674 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 675 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 676 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 677 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 678 | enum intel_engine_id id; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 679 | intel_wakeref_t wakeref; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 680 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 681 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 682 | wakeref = intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 683 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 684 | if (IS_CHERRYVIEW(dev_priv)) { |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 685 | intel_wakeref_t pref; |
| 686 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 687 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 688 | I915_READ(GEN8_MASTER_IRQ)); |
| 689 | |
| 690 | seq_printf(m, "Display IER:\t%08x\n", |
| 691 | I915_READ(VLV_IER)); |
| 692 | seq_printf(m, "Display IIR:\t%08x\n", |
| 693 | I915_READ(VLV_IIR)); |
| 694 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 695 | I915_READ(VLV_IIR_RW)); |
| 696 | seq_printf(m, "Display IMR:\t%08x\n", |
| 697 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 698 | for_each_pipe(dev_priv, pipe) { |
| 699 | enum intel_display_power_domain power_domain; |
| 700 | |
| 701 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 702 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 703 | power_domain); |
| 704 | if (!pref) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 705 | seq_printf(m, "Pipe %c power disabled\n", |
| 706 | pipe_name(pipe)); |
| 707 | continue; |
| 708 | } |
| 709 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 710 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 711 | pipe_name(pipe), |
| 712 | I915_READ(PIPESTAT(pipe))); |
| 713 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 714 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 715 | } |
| 716 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 717 | pref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 718 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 719 | I915_READ(PORT_HOTPLUG_EN)); |
| 720 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 721 | I915_READ(VLV_DPFLIPSTAT)); |
| 722 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 723 | I915_READ(DPINVGTT)); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 724 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, pref); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 725 | |
| 726 | for (i = 0; i < 4; i++) { |
| 727 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 728 | i, I915_READ(GEN8_GT_IMR(i))); |
| 729 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 730 | i, I915_READ(GEN8_GT_IIR(i))); |
| 731 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 732 | i, I915_READ(GEN8_GT_IER(i))); |
| 733 | } |
| 734 | |
| 735 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 736 | I915_READ(GEN8_PCU_IMR)); |
| 737 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 738 | I915_READ(GEN8_PCU_IIR)); |
| 739 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 740 | I915_READ(GEN8_PCU_IER)); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 741 | } else if (INTEL_GEN(dev_priv) >= 11) { |
| 742 | seq_printf(m, "Master Interrupt Control: %08x\n", |
| 743 | I915_READ(GEN11_GFX_MSTR_IRQ)); |
| 744 | |
| 745 | seq_printf(m, "Render/Copy Intr Enable: %08x\n", |
| 746 | I915_READ(GEN11_RENDER_COPY_INTR_ENABLE)); |
| 747 | seq_printf(m, "VCS/VECS Intr Enable: %08x\n", |
| 748 | I915_READ(GEN11_VCS_VECS_INTR_ENABLE)); |
| 749 | seq_printf(m, "GUC/SG Intr Enable:\t %08x\n", |
| 750 | I915_READ(GEN11_GUC_SG_INTR_ENABLE)); |
| 751 | seq_printf(m, "GPM/WGBOXPERF Intr Enable: %08x\n", |
| 752 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE)); |
| 753 | seq_printf(m, "Crypto Intr Enable:\t %08x\n", |
| 754 | I915_READ(GEN11_CRYPTO_RSVD_INTR_ENABLE)); |
| 755 | seq_printf(m, "GUnit/CSME Intr Enable:\t %08x\n", |
| 756 | I915_READ(GEN11_GUNIT_CSME_INTR_ENABLE)); |
| 757 | |
| 758 | seq_printf(m, "Display Interrupt Control:\t%08x\n", |
| 759 | I915_READ(GEN11_DISPLAY_INT_CTL)); |
| 760 | |
| 761 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 762 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 763 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 764 | I915_READ(GEN8_MASTER_IRQ)); |
| 765 | |
| 766 | for (i = 0; i < 4; i++) { |
| 767 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 768 | i, I915_READ(GEN8_GT_IMR(i))); |
| 769 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 770 | i, I915_READ(GEN8_GT_IIR(i))); |
| 771 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 772 | i, I915_READ(GEN8_GT_IER(i))); |
| 773 | } |
| 774 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 775 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 776 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 777 | seq_printf(m, "Display IER:\t%08x\n", |
| 778 | I915_READ(VLV_IER)); |
| 779 | seq_printf(m, "Display IIR:\t%08x\n", |
| 780 | I915_READ(VLV_IIR)); |
| 781 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 782 | I915_READ(VLV_IIR_RW)); |
| 783 | seq_printf(m, "Display IMR:\t%08x\n", |
| 784 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 785 | for_each_pipe(dev_priv, pipe) { |
| 786 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 787 | intel_wakeref_t pref; |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 788 | |
| 789 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 790 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 791 | power_domain); |
| 792 | if (!pref) { |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 793 | seq_printf(m, "Pipe %c power disabled\n", |
| 794 | pipe_name(pipe)); |
| 795 | continue; |
| 796 | } |
| 797 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 798 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 799 | pipe_name(pipe), |
| 800 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 801 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 802 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 803 | |
| 804 | seq_printf(m, "Master IER:\t%08x\n", |
| 805 | I915_READ(VLV_MASTER_IER)); |
| 806 | |
| 807 | seq_printf(m, "Render IER:\t%08x\n", |
| 808 | I915_READ(GTIER)); |
| 809 | seq_printf(m, "Render IIR:\t%08x\n", |
| 810 | I915_READ(GTIIR)); |
| 811 | seq_printf(m, "Render IMR:\t%08x\n", |
| 812 | I915_READ(GTIMR)); |
| 813 | |
| 814 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 815 | I915_READ(GEN6_PMIER)); |
| 816 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 817 | I915_READ(GEN6_PMIIR)); |
| 818 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 819 | I915_READ(GEN6_PMIMR)); |
| 820 | |
| 821 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 822 | I915_READ(PORT_HOTPLUG_EN)); |
| 823 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 824 | I915_READ(VLV_DPFLIPSTAT)); |
| 825 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 826 | I915_READ(DPINVGTT)); |
| 827 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 828 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 829 | seq_printf(m, "Interrupt enable: %08x\n", |
| 830 | I915_READ(IER)); |
| 831 | seq_printf(m, "Interrupt identity: %08x\n", |
| 832 | I915_READ(IIR)); |
| 833 | seq_printf(m, "Interrupt mask: %08x\n", |
| 834 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 835 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 836 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 837 | pipe_name(pipe), |
| 838 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 839 | } else { |
| 840 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 841 | I915_READ(DEIER)); |
| 842 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 843 | I915_READ(DEIIR)); |
| 844 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 845 | I915_READ(DEIMR)); |
| 846 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 847 | I915_READ(SDEIER)); |
| 848 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 849 | I915_READ(SDEIIR)); |
| 850 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 851 | I915_READ(SDEIMR)); |
| 852 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 853 | I915_READ(GTIER)); |
| 854 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 855 | I915_READ(GTIIR)); |
| 856 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 857 | I915_READ(GTIMR)); |
| 858 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 859 | |
| 860 | if (INTEL_GEN(dev_priv) >= 11) { |
| 861 | seq_printf(m, "RCS Intr Mask:\t %08x\n", |
| 862 | I915_READ(GEN11_RCS0_RSVD_INTR_MASK)); |
| 863 | seq_printf(m, "BCS Intr Mask:\t %08x\n", |
| 864 | I915_READ(GEN11_BCS_RSVD_INTR_MASK)); |
| 865 | seq_printf(m, "VCS0/VCS1 Intr Mask:\t %08x\n", |
| 866 | I915_READ(GEN11_VCS0_VCS1_INTR_MASK)); |
| 867 | seq_printf(m, "VCS2/VCS3 Intr Mask:\t %08x\n", |
| 868 | I915_READ(GEN11_VCS2_VCS3_INTR_MASK)); |
| 869 | seq_printf(m, "VECS0/VECS1 Intr Mask:\t %08x\n", |
| 870 | I915_READ(GEN11_VECS0_VECS1_INTR_MASK)); |
| 871 | seq_printf(m, "GUC/SG Intr Mask:\t %08x\n", |
| 872 | I915_READ(GEN11_GUC_SG_INTR_MASK)); |
| 873 | seq_printf(m, "GPM/WGBOXPERF Intr Mask: %08x\n", |
| 874 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK)); |
| 875 | seq_printf(m, "Crypto Intr Mask:\t %08x\n", |
| 876 | I915_READ(GEN11_CRYPTO_RSVD_INTR_MASK)); |
| 877 | seq_printf(m, "Gunit/CSME Intr Mask:\t %08x\n", |
| 878 | I915_READ(GEN11_GUNIT_CSME_INTR_MASK)); |
| 879 | |
| 880 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | d5acadf | 2017-12-09 10:44:18 +0000 | [diff] [blame] | 881 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 882 | seq_printf(m, |
| 883 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 884 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 885 | } |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 886 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 887 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 888 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 889 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 890 | return 0; |
| 891 | } |
| 892 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 893 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 894 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 895 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 896 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 897 | int i, ret; |
| 898 | |
| 899 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 900 | if (ret) |
| 901 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 902 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 903 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 904 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 905 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 906 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 907 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 908 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 909 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 910 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 911 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 912 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 913 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 914 | } |
| 915 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 916 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 917 | return 0; |
| 918 | } |
| 919 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 920 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 921 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 922 | size_t count, loff_t *pos) |
| 923 | { |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 924 | struct i915_gpu_state *error; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 925 | ssize_t ret; |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 926 | void *buf; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 927 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 928 | error = file->private_data; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 929 | if (!error) |
| 930 | return 0; |
| 931 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 932 | /* Bounce buffer required because of kernfs __user API convenience. */ |
| 933 | buf = kmalloc(count, GFP_KERNEL); |
| 934 | if (!buf) |
| 935 | return -ENOMEM; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 936 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 937 | ret = i915_gpu_state_copy_to_buffer(error, buf, *pos, count); |
| 938 | if (ret <= 0) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 939 | goto out; |
| 940 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 941 | if (!copy_to_user(ubuf, buf, ret)) |
| 942 | *pos += ret; |
| 943 | else |
| 944 | ret = -EFAULT; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 945 | |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 946 | out: |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 947 | kfree(buf); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 948 | return ret; |
| 949 | } |
| 950 | |
| 951 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 952 | { |
| 953 | i915_gpu_state_put(file->private_data); |
| 954 | return 0; |
| 955 | } |
| 956 | |
| 957 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 958 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 959 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 960 | struct i915_gpu_state *gpu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 961 | intel_wakeref_t wakeref; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 962 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 963 | gpu = NULL; |
| 964 | with_intel_runtime_pm(i915, wakeref) |
| 965 | gpu = i915_capture_gpu_state(i915); |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 966 | if (IS_ERR(gpu)) |
| 967 | return PTR_ERR(gpu); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 968 | |
| 969 | file->private_data = gpu; |
| 970 | return 0; |
| 971 | } |
| 972 | |
| 973 | static const struct file_operations i915_gpu_info_fops = { |
| 974 | .owner = THIS_MODULE, |
| 975 | .open = i915_gpu_info_open, |
| 976 | .read = gpu_state_read, |
| 977 | .llseek = default_llseek, |
| 978 | .release = gpu_state_release, |
| 979 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 980 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 981 | static ssize_t |
| 982 | i915_error_state_write(struct file *filp, |
| 983 | const char __user *ubuf, |
| 984 | size_t cnt, |
| 985 | loff_t *ppos) |
| 986 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 987 | struct i915_gpu_state *error = filp->private_data; |
| 988 | |
| 989 | if (!error) |
| 990 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 991 | |
| 992 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 993 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 994 | |
| 995 | return cnt; |
| 996 | } |
| 997 | |
| 998 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 999 | { |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 1000 | struct i915_gpu_state *error; |
| 1001 | |
| 1002 | error = i915_first_error_state(inode->i_private); |
| 1003 | if (IS_ERR(error)) |
| 1004 | return PTR_ERR(error); |
| 1005 | |
| 1006 | file->private_data = error; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1007 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1008 | } |
| 1009 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1010 | static const struct file_operations i915_error_state_fops = { |
| 1011 | .owner = THIS_MODULE, |
| 1012 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1013 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1014 | .write = i915_error_state_write, |
| 1015 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1016 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1017 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1018 | #endif |
| 1019 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1020 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1021 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1022 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1023 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1024 | intel_wakeref_t wakeref; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1025 | int ret = 0; |
| 1026 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1027 | wakeref = intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1028 | |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 1029 | if (IS_GEN(dev_priv, 5)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1030 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1031 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1032 | |
| 1033 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1034 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1035 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1036 | MEMSTAT_VID_SHIFT); |
| 1037 | seq_printf(m, "Current P-state: %d\n", |
| 1038 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1039 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1040 | u32 rpmodectl, freq_sts; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1041 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1042 | mutex_lock(&dev_priv->pcu_lock); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1043 | |
| 1044 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1045 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1046 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1047 | seq_printf(m, "HW control enabled: %s\n", |
| 1048 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1049 | seq_printf(m, "SW control enabled: %s\n", |
| 1050 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1051 | GEN6_RP_MEDIA_SW_MODE)); |
| 1052 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1053 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1054 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1055 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1056 | |
| 1057 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1058 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1059 | |
| 1060 | seq_printf(m, "current GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1061 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1062 | |
| 1063 | seq_printf(m, "max GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1064 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1065 | |
| 1066 | seq_printf(m, "min GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1067 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1068 | |
| 1069 | seq_printf(m, "idle GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1070 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1071 | |
| 1072 | seq_printf(m, |
| 1073 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1074 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1075 | mutex_unlock(&dev_priv->pcu_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1076 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1077 | u32 rp_state_limits; |
| 1078 | u32 gt_perf_status; |
| 1079 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1080 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1081 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1082 | u32 rpupei, rpcurup, rpprevup; |
| 1083 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1084 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1085 | int max_freq; |
| 1086 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1087 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1088 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1089 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1090 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1091 | } else { |
| 1092 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1093 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1094 | } |
| 1095 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1096 | /* RPSTAT1 is in the GT power well */ |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1097 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1098 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1099 | reqf = I915_READ(GEN6_RPNSWREQ); |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1100 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1101 | reqf >>= 23; |
| 1102 | else { |
| 1103 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1104 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1105 | reqf >>= 24; |
| 1106 | else |
| 1107 | reqf >>= 25; |
| 1108 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1109 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1110 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1111 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1112 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1113 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1114 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1115 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1116 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1117 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1118 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1119 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1120 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1121 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Tvrtko Ursulin | c84b270 | 2017-11-21 18:18:44 +0000 | [diff] [blame] | 1122 | cagf = intel_gpu_freq(dev_priv, |
| 1123 | intel_get_cagf(dev_priv, rpstat)); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1124 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1125 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1126 | |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1127 | if (INTEL_GEN(dev_priv) >= 11) { |
| 1128 | pm_ier = I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE); |
| 1129 | pm_imr = I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK); |
| 1130 | /* |
| 1131 | * The equivalent to the PM ISR & IIR cannot be read |
| 1132 | * without affecting the current state of the system |
| 1133 | */ |
| 1134 | pm_isr = 0; |
| 1135 | pm_iir = 0; |
| 1136 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1137 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1138 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1139 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1140 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1141 | } else { |
| 1142 | pm_ier = I915_READ(GEN6_PMIER); |
| 1143 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1144 | pm_isr = I915_READ(GEN6_PMISR); |
| 1145 | pm_iir = I915_READ(GEN6_PMIIR); |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1146 | } |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1147 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1148 | |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1149 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1150 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1151 | seq_printf(m, "HW control enabled: %s\n", |
| 1152 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1153 | seq_printf(m, "SW control enabled: %s\n", |
| 1154 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1155 | GEN6_RP_MEDIA_SW_MODE)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1156 | |
| 1157 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x, MASK=0x%08x\n", |
| 1158 | pm_ier, pm_imr, pm_mask); |
| 1159 | if (INTEL_GEN(dev_priv) <= 10) |
| 1160 | seq_printf(m, "PM ISR=0x%08x IIR=0x%08x\n", |
| 1161 | pm_isr, pm_iir); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1162 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1163 | rps->pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1164 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1165 | seq_printf(m, "Render p-state ratio: %d\n", |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1166 | (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1167 | seq_printf(m, "Render p-state VID: %d\n", |
| 1168 | gt_perf_status & 0xff); |
| 1169 | seq_printf(m, "Render p-state limit: %d\n", |
| 1170 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1171 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1172 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1173 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1174 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1175 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1176 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1177 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1178 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1179 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1180 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1181 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1182 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1183 | seq_printf(m, "Up threshold: %d%%\n", |
| 1184 | rps->power.up_threshold); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1185 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1186 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1187 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1188 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1189 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1190 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1191 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1192 | seq_printf(m, "Down threshold: %d%%\n", |
| 1193 | rps->power.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1194 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1195 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1196 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1197 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1198 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1199 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1200 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1201 | |
| 1202 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1203 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1204 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1205 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1206 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1207 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1208 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1209 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1210 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1211 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1212 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1213 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1214 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1215 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1216 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1217 | seq_printf(m, "Current freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1218 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1219 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1220 | seq_printf(m, "Idle freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1221 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1222 | seq_printf(m, "Min freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1223 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1224 | seq_printf(m, "Boost freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1225 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1226 | seq_printf(m, "Max freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1227 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1228 | seq_printf(m, |
| 1229 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1230 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1231 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1232 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1233 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1234 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1235 | 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] | 1236 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1237 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1238 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1239 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1240 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1241 | } |
| 1242 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1243 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1244 | struct seq_file *m, |
| 1245 | struct intel_instdone *instdone) |
| 1246 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1247 | int slice; |
| 1248 | int subslice; |
| 1249 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1250 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1251 | instdone->instdone); |
| 1252 | |
| 1253 | if (INTEL_GEN(dev_priv) <= 3) |
| 1254 | return; |
| 1255 | |
| 1256 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1257 | instdone->slice_common); |
| 1258 | |
| 1259 | if (INTEL_GEN(dev_priv) <= 6) |
| 1260 | return; |
| 1261 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1262 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1263 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1264 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1265 | |
| 1266 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1267 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1268 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1269 | } |
| 1270 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1271 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1272 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1273 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1274 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1275 | u64 acthd[I915_NUM_ENGINES]; |
| 1276 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1277 | struct intel_instdone instdone; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1278 | intel_wakeref_t wakeref; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1279 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1280 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1281 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1282 | seq_puts(m, "Wedged\n"); |
| 1283 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
| 1284 | seq_puts(m, "Reset in progress: struct_mutex backoff\n"); |
| 1285 | if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags)) |
| 1286 | seq_puts(m, "Reset in progress: reset handoff to waiter\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 | 52d7f16 | 2018-04-30 14:15:00 +0100 | [diff] [blame] | 1322 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1323 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | 52d7f16 | 2018-04-30 14:15:00 +0100 | [diff] [blame] | 1324 | intel_engine_last_submit(engine)); |
Chris Wilson | 1fd00c0f | 2018-06-02 11:48:53 +0100 | [diff] [blame] | 1325 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s, wedged? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1326 | yesno(intel_engine_has_waiter(engine)), |
| 1327 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1328 | &dev_priv->gpu_error.missed_irq_rings)), |
Chris Wilson | 1fd00c0f | 2018-06-02 11:48:53 +0100 | [diff] [blame] | 1329 | yesno(engine->hangcheck.stalled), |
| 1330 | yesno(engine->hangcheck.wedged)); |
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 | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1344 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1345 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1346 | engine->hangcheck.action, |
| 1347 | jiffies_to_msecs(jiffies - |
| 1348 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1349 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1350 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1351 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1352 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1353 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1354 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1355 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1356 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1357 | i915_instdone_info(dev_priv, m, |
| 1358 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1359 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | return 0; |
| 1363 | } |
| 1364 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1365 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1366 | { |
| 1367 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1368 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1369 | struct intel_engine_cs *engine; |
| 1370 | enum intel_engine_id id; |
| 1371 | |
| 1372 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1373 | |
| 1374 | for_each_engine(engine, dev_priv, id) { |
| 1375 | seq_printf(m, "%s = %u\n", engine->name, |
| 1376 | i915_reset_engine_count(error, engine)); |
| 1377 | } |
| 1378 | |
| 1379 | return 0; |
| 1380 | } |
| 1381 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1382 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1383 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1384 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1385 | u32 rgvmodectl, rstdbyctl; |
| 1386 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1387 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1388 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1389 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1390 | crstandvid = I915_READ16(CRSTANDVID); |
| 1391 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1392 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1393 | seq_printf(m, "Boost freq: %d\n", |
| 1394 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1395 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1396 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1397 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1398 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1399 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1400 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1401 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1402 | seq_printf(m, "Starting frequency: P%d\n", |
| 1403 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1404 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1405 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1406 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1407 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1408 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1409 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1410 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1411 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1412 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1413 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1414 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1415 | break; |
| 1416 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1417 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1418 | break; |
| 1419 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1420 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1421 | break; |
| 1422 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1423 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1424 | break; |
| 1425 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1426 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1427 | break; |
| 1428 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1429 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1430 | break; |
| 1431 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1432 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1433 | break; |
| 1434 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1435 | |
| 1436 | return 0; |
| 1437 | } |
| 1438 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1439 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1440 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1441 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1442 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1443 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1444 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1445 | seq_printf(m, "user.bypass_count = %u\n", |
| 1446 | i915->uncore.user_forcewake.count); |
| 1447 | |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1448 | for_each_fw_domain(fw_domain, i915, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1449 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1450 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1451 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1452 | |
| 1453 | return 0; |
| 1454 | } |
| 1455 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1456 | static void print_rc6_res(struct seq_file *m, |
| 1457 | const char *title, |
| 1458 | const i915_reg_t reg) |
| 1459 | { |
| 1460 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1461 | |
| 1462 | seq_printf(m, "%s %u (%llu us)\n", |
| 1463 | title, I915_READ(reg), |
| 1464 | intel_rc6_residency_us(dev_priv, reg)); |
| 1465 | } |
| 1466 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1467 | static int vlv_drpc_info(struct seq_file *m) |
| 1468 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1469 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1470 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1471 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1472 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1473 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1474 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1475 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1476 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1477 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1478 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1479 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1480 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1481 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1482 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1483 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1484 | 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] | 1485 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1486 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1487 | } |
| 1488 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1489 | static int gen6_drpc_info(struct seq_file *m) |
| 1490 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1491 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1492 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1493 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1494 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1495 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1496 | 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] | 1497 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1498 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1499 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1500 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1501 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1502 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1503 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1504 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1505 | mutex_lock(&dev_priv->pcu_lock); |
| 1506 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, |
| 1507 | &rc6vids); |
| 1508 | mutex_unlock(&dev_priv->pcu_lock); |
| 1509 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1510 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1511 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1512 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1513 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1514 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1515 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1516 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1517 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1518 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1519 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1520 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1521 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1522 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1523 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1524 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1525 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1526 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1527 | case GEN6_RC0: |
| 1528 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1529 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1530 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1531 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1532 | break; |
| 1533 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1534 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1535 | break; |
| 1536 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1537 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1538 | break; |
| 1539 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1540 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1541 | break; |
| 1542 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1543 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1544 | break; |
| 1545 | } |
| 1546 | |
| 1547 | seq_printf(m, "Core Power Down: %s\n", |
| 1548 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1549 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1550 | seq_printf(m, "Render Power Well: %s\n", |
| 1551 | (gen9_powergate_status & |
| 1552 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1553 | seq_printf(m, "Media Power Well: %s\n", |
| 1554 | (gen9_powergate_status & |
| 1555 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1556 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1557 | |
| 1558 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1559 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1560 | GEN6_GT_GFX_RC6_LOCKED); |
| 1561 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1562 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1563 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1564 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1565 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1566 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1567 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1568 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1569 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1570 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1571 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
| 1572 | } |
| 1573 | |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1574 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1575 | } |
| 1576 | |
| 1577 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1578 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1579 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1580 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1581 | int err = -ENODEV; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1582 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1583 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1584 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 1585 | err = vlv_drpc_info(m); |
| 1586 | else if (INTEL_GEN(dev_priv) >= 6) |
| 1587 | err = gen6_drpc_info(m); |
| 1588 | else |
| 1589 | err = ironlake_drpc_info(m); |
| 1590 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1591 | |
| 1592 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1593 | } |
| 1594 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1595 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1596 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1597 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1598 | |
| 1599 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1600 | dev_priv->fb_tracking.busy_bits); |
| 1601 | |
| 1602 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1603 | dev_priv->fb_tracking.flip_bits); |
| 1604 | |
| 1605 | return 0; |
| 1606 | } |
| 1607 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1608 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1609 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1610 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1611 | struct intel_fbc *fbc = &dev_priv->fbc; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1612 | intel_wakeref_t wakeref; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1613 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1614 | if (!HAS_FBC(dev_priv)) |
| 1615 | return -ENODEV; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1616 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1617 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1618 | mutex_lock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1619 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1620 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1621 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1622 | else |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1623 | seq_printf(m, "FBC disabled: %s\n", fbc->no_fbc_reason); |
| 1624 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1625 | if (intel_fbc_is_active(dev_priv)) { |
| 1626 | u32 mask; |
| 1627 | |
| 1628 | if (INTEL_GEN(dev_priv) >= 8) |
| 1629 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1630 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1631 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1632 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1633 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1634 | else if (IS_G4X(dev_priv)) |
| 1635 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1636 | else |
| 1637 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1638 | FBC_STAT_COMPRESSED); |
| 1639 | |
| 1640 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1641 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1642 | |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1643 | mutex_unlock(&fbc->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1644 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1645 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1646 | return 0; |
| 1647 | } |
| 1648 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1649 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1650 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1651 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1652 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1653 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1654 | return -ENODEV; |
| 1655 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1656 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1657 | |
| 1658 | return 0; |
| 1659 | } |
| 1660 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1661 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1662 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1663 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1664 | u32 reg; |
| 1665 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1666 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1667 | return -ENODEV; |
| 1668 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1669 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1670 | |
| 1671 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1672 | dev_priv->fbc.false_color = val; |
| 1673 | |
| 1674 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1675 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1676 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1677 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1678 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1679 | return 0; |
| 1680 | } |
| 1681 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1682 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1683 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1684 | "%llu\n"); |
| 1685 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1686 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1687 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1688 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1689 | intel_wakeref_t wakeref; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1690 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1691 | if (!HAS_IPS(dev_priv)) |
| 1692 | return -ENODEV; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1693 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1694 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1695 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1696 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1697 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1698 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1699 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1700 | seq_puts(m, "Currently: unknown\n"); |
| 1701 | } else { |
| 1702 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1703 | seq_puts(m, "Currently: enabled\n"); |
| 1704 | else |
| 1705 | seq_puts(m, "Currently: disabled\n"); |
| 1706 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1707 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1708 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1709 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1710 | return 0; |
| 1711 | } |
| 1712 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1713 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1714 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1715 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1716 | intel_wakeref_t wakeref; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1717 | bool sr_enabled = false; |
| 1718 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1719 | wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1720 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1721 | if (INTEL_GEN(dev_priv) >= 9) |
| 1722 | /* no global SR status; inspect per-plane WM */; |
| 1723 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1724 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1725 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1726 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1727 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1728 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1729 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1730 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1731 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1732 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1733 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1734 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1735 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1736 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1737 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1738 | |
| 1739 | return 0; |
| 1740 | } |
| 1741 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1742 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1743 | { |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame^] | 1744 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1745 | intel_wakeref_t wakeref; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1746 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame^] | 1747 | if (!IS_GEN(i915, 5)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1748 | return -ENODEV; |
| 1749 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame^] | 1750 | with_intel_runtime_pm(i915, wakeref) { |
| 1751 | unsigned long temp, chipset, gfx; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1752 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame^] | 1753 | temp = i915_mch_val(i915); |
| 1754 | chipset = i915_chipset_val(i915); |
| 1755 | gfx = i915_gfx_val(i915); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1756 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame^] | 1757 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1758 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1759 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1760 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1761 | } |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1762 | |
| 1763 | return 0; |
| 1764 | } |
| 1765 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1766 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1767 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1768 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1769 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1770 | unsigned int max_gpu_freq, min_gpu_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1771 | intel_wakeref_t wakeref; |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1772 | int gpu_freq, ia_freq; |
| 1773 | int ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1774 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1775 | if (!HAS_LLC(dev_priv)) |
| 1776 | return -ENODEV; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1777 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1778 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1779 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1780 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1781 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1782 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1783 | |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1784 | min_gpu_freq = rps->min_freq; |
| 1785 | max_gpu_freq = rps->max_freq; |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1786 | if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1787 | /* Convert GT frequency to 50 HZ units */ |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1788 | min_gpu_freq /= GEN9_FREQ_SCALER; |
| 1789 | max_gpu_freq /= GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1790 | } |
| 1791 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1792 | 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] | 1793 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1794 | 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] | 1795 | ia_freq = gpu_freq; |
| 1796 | sandybridge_pcode_read(dev_priv, |
| 1797 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1798 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1799 | 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] | 1800 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1801 | (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1802 | INTEL_GEN(dev_priv) >= 10 ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1803 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1804 | ((ia_freq >> 0) & 0xff) * 100, |
| 1805 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1806 | } |
| 1807 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1808 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1809 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1810 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1811 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1812 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1813 | } |
| 1814 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1815 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1816 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1817 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1818 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1819 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1820 | int ret; |
| 1821 | |
| 1822 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1823 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1824 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1825 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1826 | if (opregion->header) |
| 1827 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1828 | |
| 1829 | mutex_unlock(&dev->struct_mutex); |
| 1830 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1831 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1832 | return 0; |
| 1833 | } |
| 1834 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1835 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1836 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1837 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1838 | |
| 1839 | if (opregion->vbt) |
| 1840 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1841 | |
| 1842 | return 0; |
| 1843 | } |
| 1844 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1845 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1846 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1847 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1848 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1849 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1850 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1851 | int ret; |
| 1852 | |
| 1853 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1854 | if (ret) |
| 1855 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1856 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1857 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1858 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1859 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1860 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1861 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1862 | fbdev_fb->base.width, |
| 1863 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1864 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1865 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1866 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1867 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1868 | describe_obj(m, intel_fb_obj(&fbdev_fb->base)); |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1869 | seq_putc(m, '\n'); |
| 1870 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1871 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1872 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1873 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1874 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1875 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1876 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1877 | continue; |
| 1878 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1879 | 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] | 1880 | fb->base.width, |
| 1881 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1882 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1883 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1884 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1885 | drm_framebuffer_read_refcount(&fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1886 | describe_obj(m, intel_fb_obj(&fb->base)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1887 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1888 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1889 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1890 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1891 | |
| 1892 | return 0; |
| 1893 | } |
| 1894 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1895 | 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] | 1896 | { |
Chris Wilson | ef5032a | 2018-03-07 13:42:24 +0000 | [diff] [blame] | 1897 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", |
| 1898 | ring->space, ring->head, ring->tail, ring->emit); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1899 | } |
| 1900 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1901 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1902 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1903 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1904 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1905 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1906 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1907 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1908 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1909 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1910 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1911 | if (ret) |
| 1912 | return ret; |
| 1913 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1914 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 288f1ce | 2018-09-04 16:31:17 +0100 | [diff] [blame] | 1915 | seq_puts(m, "HW context "); |
| 1916 | if (!list_empty(&ctx->hw_id_link)) |
| 1917 | seq_printf(m, "%x [pin %u]", ctx->hw_id, |
| 1918 | atomic_read(&ctx->hw_id_pin_count)); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1919 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1920 | struct task_struct *task; |
| 1921 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1922 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1923 | if (task) { |
| 1924 | seq_printf(m, "(%s [%d]) ", |
| 1925 | task->comm, task->pid); |
| 1926 | put_task_struct(task); |
| 1927 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1928 | } else if (IS_ERR(ctx->file_priv)) { |
| 1929 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1930 | } else { |
| 1931 | seq_puts(m, "(kernel) "); |
| 1932 | } |
| 1933 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1934 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1935 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1936 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1937 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 1938 | struct intel_context *ce = |
| 1939 | to_intel_context(ctx, engine); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1940 | |
| 1941 | seq_printf(m, "%s: ", engine->name); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1942 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1943 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1944 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1945 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1946 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1947 | } |
| 1948 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1949 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1950 | } |
| 1951 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1952 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1953 | |
| 1954 | return 0; |
| 1955 | } |
| 1956 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1957 | static const char *swizzle_string(unsigned swizzle) |
| 1958 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1959 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1960 | case I915_BIT_6_SWIZZLE_NONE: |
| 1961 | return "none"; |
| 1962 | case I915_BIT_6_SWIZZLE_9: |
| 1963 | return "bit9"; |
| 1964 | case I915_BIT_6_SWIZZLE_9_10: |
| 1965 | return "bit9/bit10"; |
| 1966 | case I915_BIT_6_SWIZZLE_9_11: |
| 1967 | return "bit9/bit11"; |
| 1968 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1969 | return "bit9/bit10/bit11"; |
| 1970 | case I915_BIT_6_SWIZZLE_9_17: |
| 1971 | return "bit9/bit17"; |
| 1972 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1973 | return "bit9/bit10/bit17"; |
| 1974 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1975 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1976 | } |
| 1977 | |
| 1978 | return "bug"; |
| 1979 | } |
| 1980 | |
| 1981 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1982 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1983 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1984 | intel_wakeref_t wakeref; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1985 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1986 | wakeref = intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1987 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1988 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1989 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1990 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1991 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1992 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 1993 | if (IS_GEN_RANGE(dev_priv, 3, 4)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1994 | seq_printf(m, "DDC = 0x%08x\n", |
| 1995 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1996 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 1997 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1998 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1999 | I915_READ16(C0DRB3)); |
| 2000 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2001 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2002 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2003 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2004 | I915_READ(MAD_DIMM_C0)); |
| 2005 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2006 | I915_READ(MAD_DIMM_C1)); |
| 2007 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2008 | I915_READ(MAD_DIMM_C2)); |
| 2009 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2010 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2011 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2012 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2013 | I915_READ(GAMTARBMODE)); |
| 2014 | else |
| 2015 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2016 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2017 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2018 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2019 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2020 | |
| 2021 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2022 | seq_puts(m, "L-shaped memory detected\n"); |
| 2023 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2024 | intel_runtime_pm_put(dev_priv, wakeref); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2025 | |
| 2026 | return 0; |
| 2027 | } |
| 2028 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2029 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2030 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2031 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2032 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2033 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2034 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2035 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2036 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2037 | |
| 2038 | return count; |
| 2039 | } |
| 2040 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2041 | static const char *rps_power_to_str(unsigned int power) |
| 2042 | { |
| 2043 | static const char * const strings[] = { |
| 2044 | [LOW_POWER] = "low power", |
| 2045 | [BETWEEN] = "mixed", |
| 2046 | [HIGH_POWER] = "high power", |
| 2047 | }; |
| 2048 | |
| 2049 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2050 | return "unknown"; |
| 2051 | |
| 2052 | return strings[power]; |
| 2053 | } |
| 2054 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2055 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2056 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2057 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2058 | struct drm_device *dev = &dev_priv->drm; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2059 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2060 | u32 act_freq = rps->cur_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2061 | intel_wakeref_t wakeref; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2062 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2063 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2064 | with_intel_runtime_pm_if_in_use(dev_priv, wakeref) { |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2065 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 2066 | mutex_lock(&dev_priv->pcu_lock); |
| 2067 | act_freq = vlv_punit_read(dev_priv, |
| 2068 | PUNIT_REG_GPU_FREQ_STS); |
| 2069 | act_freq = (act_freq >> 8) & 0xff; |
| 2070 | mutex_unlock(&dev_priv->pcu_lock); |
| 2071 | } else { |
| 2072 | act_freq = intel_get_cagf(dev_priv, |
| 2073 | I915_READ(GEN6_RPSTAT1)); |
| 2074 | } |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2075 | } |
| 2076 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2077 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2078 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2079 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2080 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2081 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2082 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2083 | seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2084 | seq_printf(m, "Frequency requested %d, actual %d\n", |
| 2085 | intel_gpu_freq(dev_priv, rps->cur_freq), |
| 2086 | intel_gpu_freq(dev_priv, act_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2087 | 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] | 2088 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2089 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2090 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2091 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2092 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2093 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2094 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2095 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2096 | |
| 2097 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2098 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2099 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2100 | struct task_struct *task; |
| 2101 | |
| 2102 | rcu_read_lock(); |
| 2103 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2104 | seq_printf(m, "%s [%d]: %d boosts\n", |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2105 | task ? task->comm : "<unknown>", |
| 2106 | task ? task->pid : -1, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2107 | atomic_read(&file_priv->rps_client.boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2108 | rcu_read_unlock(); |
| 2109 | } |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2110 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2111 | atomic_read(&rps->boosts)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2112 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2113 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2114 | if (INTEL_GEN(dev_priv) >= 6 && |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2115 | rps->enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2116 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2117 | u32 rpup, rpupei; |
| 2118 | u32 rpdown, rpdownei; |
| 2119 | |
| 2120 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2121 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2122 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2123 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2124 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2125 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2126 | |
| 2127 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2128 | rps_power_to_str(rps->power.mode)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2129 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2130 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2131 | rps->power.up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2132 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2133 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2134 | rps->power.down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2135 | } else { |
| 2136 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2137 | } |
| 2138 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2139 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2140 | } |
| 2141 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2142 | static int i915_llc(struct seq_file *m, void *data) |
| 2143 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2144 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2145 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2146 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2147 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2148 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2149 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2150 | |
| 2151 | return 0; |
| 2152 | } |
| 2153 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2154 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2155 | { |
| 2156 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2157 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2158 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2159 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2160 | if (!HAS_HUC(dev_priv)) |
| 2161 | return -ENODEV; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2162 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2163 | p = drm_seq_file_printer(m); |
| 2164 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2165 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2166 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2167 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2168 | |
| 2169 | return 0; |
| 2170 | } |
| 2171 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2172 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2173 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2174 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2175 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2176 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2177 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2178 | if (!HAS_GUC(dev_priv)) |
| 2179 | return -ENODEV; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2180 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2181 | p = drm_seq_file_printer(m); |
| 2182 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2183 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2184 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 2185 | u32 tmp = I915_READ(GUC_STATUS); |
| 2186 | u32 i; |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2187 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2188 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2189 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2190 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2191 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2192 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2193 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2194 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2195 | seq_puts(m, "\nScratch registers:\n"); |
| 2196 | for (i = 0; i < 16; i++) { |
| 2197 | seq_printf(m, "\t%2d: \t0x%x\n", |
| 2198 | i, I915_READ(SOFT_SCRATCH(i))); |
| 2199 | } |
| 2200 | } |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2201 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2202 | return 0; |
| 2203 | } |
| 2204 | |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2205 | static const char * |
| 2206 | stringify_guc_log_type(enum guc_log_buffer_type type) |
| 2207 | { |
| 2208 | switch (type) { |
| 2209 | case GUC_ISR_LOG_BUFFER: |
| 2210 | return "ISR"; |
| 2211 | case GUC_DPC_LOG_BUFFER: |
| 2212 | return "DPC"; |
| 2213 | case GUC_CRASH_DUMP_LOG_BUFFER: |
| 2214 | return "CRASH"; |
| 2215 | default: |
| 2216 | MISSING_CASE(type); |
| 2217 | } |
| 2218 | |
| 2219 | return ""; |
| 2220 | } |
| 2221 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2222 | static void i915_guc_log_info(struct seq_file *m, |
| 2223 | struct drm_i915_private *dev_priv) |
| 2224 | { |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2225 | struct intel_guc_log *log = &dev_priv->guc.log; |
| 2226 | enum guc_log_buffer_type type; |
| 2227 | |
| 2228 | if (!intel_guc_log_relay_enabled(log)) { |
| 2229 | seq_puts(m, "GuC log relay disabled\n"); |
| 2230 | return; |
| 2231 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2232 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2233 | seq_puts(m, "GuC logging stats:\n"); |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2234 | |
Michał Winiarski | 6a96be2 | 2018-03-19 10:53:42 +0100 | [diff] [blame] | 2235 | seq_printf(m, "\tRelay full count: %u\n", |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2236 | log->relay.full_count); |
| 2237 | |
| 2238 | for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { |
| 2239 | seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", |
| 2240 | stringify_guc_log_type(type), |
| 2241 | log->stats[type].flush, |
| 2242 | log->stats[type].sampled_overflow); |
| 2243 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2244 | } |
| 2245 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2246 | static void i915_guc_client_info(struct seq_file *m, |
| 2247 | struct drm_i915_private *dev_priv, |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2248 | struct intel_guc_client *client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2249 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2250 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2251 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2252 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2253 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2254 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2255 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2256 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2257 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2258 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2259 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2260 | u64 submissions = client->submissions[id]; |
| 2261 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2262 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2263 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2264 | } |
| 2265 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2266 | } |
| 2267 | |
| 2268 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2269 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2270 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2271 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2272 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2273 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2274 | return -ENODEV; |
| 2275 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2276 | i915_guc_log_info(m, dev_priv); |
| 2277 | |
| 2278 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2279 | return 0; |
| 2280 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2281 | GEM_BUG_ON(!guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2282 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2283 | seq_printf(m, "\nDoorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2284 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2285 | seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2286 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2287 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2288 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Chris Wilson | e78c917 | 2018-02-07 21:05:42 +0000 | [diff] [blame] | 2289 | if (guc->preempt_client) { |
| 2290 | seq_printf(m, "\nGuC preempt client @ %p:\n", |
| 2291 | guc->preempt_client); |
| 2292 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
| 2293 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2294 | |
| 2295 | /* Add more as required ... */ |
| 2296 | |
| 2297 | return 0; |
| 2298 | } |
| 2299 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2300 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2301 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2302 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2303 | const struct intel_guc *guc = &dev_priv->guc; |
| 2304 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2305 | struct intel_guc_client *client = guc->execbuf_client; |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2306 | unsigned int tmp; |
| 2307 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2308 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2309 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2310 | return -ENODEV; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2311 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2312 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2313 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2314 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2315 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2316 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2317 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2318 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2319 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2320 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2321 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2322 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2323 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2324 | desc->engines_used); |
| 2325 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2326 | desc->db_trigger_phy, |
| 2327 | desc->db_trigger_cpu, |
| 2328 | desc->db_trigger_uk); |
| 2329 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2330 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2331 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2332 | desc->wq_addr, desc->wq_size); |
| 2333 | seq_putc(m, '\n'); |
| 2334 | |
| 2335 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2336 | u32 guc_engine_id = engine->guc_id; |
| 2337 | struct guc_execlist_context *lrc = |
| 2338 | &desc->lrc[guc_engine_id]; |
| 2339 | |
| 2340 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2341 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2342 | lrc->context_desc); |
| 2343 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2344 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2345 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2346 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2347 | seq_putc(m, '\n'); |
| 2348 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2349 | } |
| 2350 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2351 | return 0; |
| 2352 | } |
| 2353 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2354 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2355 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2356 | struct drm_info_node *node = m->private; |
| 2357 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2358 | bool dump_load_err = !!node->info_ent->data; |
| 2359 | struct drm_i915_gem_object *obj = NULL; |
| 2360 | u32 *log; |
| 2361 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2362 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2363 | if (!HAS_GUC(dev_priv)) |
| 2364 | return -ENODEV; |
| 2365 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2366 | if (dump_load_err) |
| 2367 | obj = dev_priv->guc.load_err_log; |
| 2368 | else if (dev_priv->guc.log.vma) |
| 2369 | obj = dev_priv->guc.log.vma->obj; |
| 2370 | |
| 2371 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2372 | return 0; |
| 2373 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2374 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2375 | if (IS_ERR(log)) { |
| 2376 | DRM_DEBUG("Failed to pin object\n"); |
| 2377 | seq_puts(m, "(log data unaccessible)\n"); |
| 2378 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2379 | } |
| 2380 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2381 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2382 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2383 | *(log + i), *(log + i + 1), |
| 2384 | *(log + i + 2), *(log + i + 3)); |
| 2385 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2386 | seq_putc(m, '\n'); |
| 2387 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2388 | i915_gem_object_unpin_map(obj); |
| 2389 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2390 | return 0; |
| 2391 | } |
| 2392 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2393 | static int i915_guc_log_level_get(void *data, u64 *val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2394 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2395 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2396 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2397 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2398 | return -ENODEV; |
| 2399 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2400 | *val = intel_guc_log_get_level(&dev_priv->guc.log); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2401 | |
| 2402 | return 0; |
| 2403 | } |
| 2404 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2405 | static int i915_guc_log_level_set(void *data, u64 val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2406 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2407 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2408 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2409 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2410 | return -ENODEV; |
| 2411 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2412 | return intel_guc_log_set_level(&dev_priv->guc.log, val); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2413 | } |
| 2414 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2415 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, |
| 2416 | i915_guc_log_level_get, i915_guc_log_level_set, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2417 | "%lld\n"); |
| 2418 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2419 | static int i915_guc_log_relay_open(struct inode *inode, struct file *file) |
| 2420 | { |
| 2421 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2422 | |
| 2423 | if (!USES_GUC(dev_priv)) |
| 2424 | return -ENODEV; |
| 2425 | |
| 2426 | file->private_data = &dev_priv->guc.log; |
| 2427 | |
| 2428 | return intel_guc_log_relay_open(&dev_priv->guc.log); |
| 2429 | } |
| 2430 | |
| 2431 | static ssize_t |
| 2432 | i915_guc_log_relay_write(struct file *filp, |
| 2433 | const char __user *ubuf, |
| 2434 | size_t cnt, |
| 2435 | loff_t *ppos) |
| 2436 | { |
| 2437 | struct intel_guc_log *log = filp->private_data; |
| 2438 | |
| 2439 | intel_guc_log_relay_flush(log); |
| 2440 | |
| 2441 | return cnt; |
| 2442 | } |
| 2443 | |
| 2444 | static int i915_guc_log_relay_release(struct inode *inode, struct file *file) |
| 2445 | { |
| 2446 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2447 | |
| 2448 | intel_guc_log_relay_close(&dev_priv->guc.log); |
| 2449 | |
| 2450 | return 0; |
| 2451 | } |
| 2452 | |
| 2453 | static const struct file_operations i915_guc_log_relay_fops = { |
| 2454 | .owner = THIS_MODULE, |
| 2455 | .open = i915_guc_log_relay_open, |
| 2456 | .write = i915_guc_log_relay_write, |
| 2457 | .release = i915_guc_log_relay_release, |
| 2458 | }; |
| 2459 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2460 | static int i915_psr_sink_status_show(struct seq_file *m, void *data) |
| 2461 | { |
| 2462 | u8 val; |
| 2463 | static const char * const sink_status[] = { |
| 2464 | "inactive", |
| 2465 | "transition to active, capture and display", |
| 2466 | "active, display from RFB", |
| 2467 | "active, capture and display on sink device timings", |
| 2468 | "transition to inactive, capture and display, timing re-sync", |
| 2469 | "reserved", |
| 2470 | "reserved", |
| 2471 | "sink internal error", |
| 2472 | }; |
| 2473 | struct drm_connector *connector = m->private; |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2474 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2475 | struct intel_dp *intel_dp = |
| 2476 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2477 | int ret; |
| 2478 | |
| 2479 | if (!CAN_PSR(dev_priv)) { |
| 2480 | seq_puts(m, "PSR Unsupported\n"); |
| 2481 | return -ENODEV; |
| 2482 | } |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2483 | |
| 2484 | if (connector->status != connector_status_connected) |
| 2485 | return -ENODEV; |
| 2486 | |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2487 | ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val); |
| 2488 | |
| 2489 | if (ret == 1) { |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2490 | const char *str = "unknown"; |
| 2491 | |
| 2492 | val &= DP_PSR_SINK_STATE_MASK; |
| 2493 | if (val < ARRAY_SIZE(sink_status)) |
| 2494 | str = sink_status[val]; |
| 2495 | seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str); |
| 2496 | } else { |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2497 | return ret; |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2498 | } |
| 2499 | |
| 2500 | return 0; |
| 2501 | } |
| 2502 | DEFINE_SHOW_ATTRIBUTE(i915_psr_sink_status); |
| 2503 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2504 | static void |
| 2505 | 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] | 2506 | { |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2507 | u32 val, psr_status; |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2508 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2509 | if (dev_priv->psr.psr2_enabled) { |
| 2510 | static const char * const live_status[] = { |
| 2511 | "IDLE", |
| 2512 | "CAPTURE", |
| 2513 | "CAPTURE_FS", |
| 2514 | "SLEEP", |
| 2515 | "BUFON_FW", |
| 2516 | "ML_UP", |
| 2517 | "SU_STANDBY", |
| 2518 | "FAST_SLEEP", |
| 2519 | "DEEP_SLEEP", |
| 2520 | "BUF_ON", |
| 2521 | "TG_ON" |
| 2522 | }; |
| 2523 | psr_status = I915_READ(EDP_PSR2_STATUS); |
| 2524 | val = (psr_status & EDP_PSR2_STATUS_STATE_MASK) >> |
| 2525 | EDP_PSR2_STATUS_STATE_SHIFT; |
| 2526 | if (val < ARRAY_SIZE(live_status)) { |
| 2527 | seq_printf(m, "Source PSR status: 0x%x [%s]\n", |
| 2528 | psr_status, live_status[val]); |
| 2529 | return; |
| 2530 | } |
| 2531 | } else { |
| 2532 | static const char * const live_status[] = { |
| 2533 | "IDLE", |
| 2534 | "SRDONACK", |
| 2535 | "SRDENT", |
| 2536 | "BUFOFF", |
| 2537 | "BUFON", |
| 2538 | "AUXACK", |
| 2539 | "SRDOFFACK", |
| 2540 | "SRDENT_ON", |
| 2541 | }; |
| 2542 | psr_status = I915_READ(EDP_PSR_STATUS); |
| 2543 | val = (psr_status & EDP_PSR_STATUS_STATE_MASK) >> |
| 2544 | EDP_PSR_STATUS_STATE_SHIFT; |
| 2545 | if (val < ARRAY_SIZE(live_status)) { |
| 2546 | seq_printf(m, "Source PSR status: 0x%x [%s]\n", |
| 2547 | psr_status, live_status[val]); |
| 2548 | return; |
| 2549 | } |
| 2550 | } |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2551 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2552 | seq_printf(m, "Source PSR status: 0x%x [%s]\n", psr_status, "unknown"); |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2553 | } |
| 2554 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2555 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2556 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2557 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2558 | intel_wakeref_t wakeref; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2559 | u32 psrperf = 0; |
| 2560 | bool enabled = false; |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2561 | bool sink_support; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2562 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2563 | if (!HAS_PSR(dev_priv)) |
| 2564 | return -ENODEV; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2565 | |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2566 | sink_support = dev_priv->psr.sink_support; |
| 2567 | seq_printf(m, "Sink_Support: %s\n", yesno(sink_support)); |
| 2568 | if (!sink_support) |
| 2569 | return 0; |
| 2570 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2571 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2572 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2573 | mutex_lock(&dev_priv->psr.lock); |
Azhar Shaikh | 0577ab4 | 2018-08-22 10:23:48 -0700 | [diff] [blame] | 2574 | seq_printf(m, "PSR mode: %s\n", |
| 2575 | dev_priv->psr.psr2_enabled ? "PSR2" : "PSR1"); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2576 | seq_printf(m, "Enabled: %s\n", yesno(dev_priv->psr.enabled)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2577 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2578 | dev_priv->psr.busy_frontbuffer_bits); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2579 | |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2580 | if (dev_priv->psr.psr2_enabled) |
| 2581 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2582 | else |
| 2583 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2584 | |
| 2585 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2586 | yesno(dev_priv->psr.link_standby)); |
| 2587 | |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2588 | seq_printf(m, "HW Enabled & Active bit: %s\n", yesno(enabled)); |
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)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2594 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2595 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2596 | |
| 2597 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2598 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2599 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2600 | psr_source_status(dev_priv, m); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2601 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2602 | |
Dhinakaran Pandiyan | 9844d4b | 2018-08-21 15:11:55 -0700 | [diff] [blame] | 2603 | if (READ_ONCE(dev_priv->psr.debug) & I915_PSR_DEBUG_IRQ) { |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2604 | seq_printf(m, "Last attempted entry at: %lld\n", |
| 2605 | dev_priv->psr.last_entry_attempt); |
| 2606 | seq_printf(m, "Last exit at: %lld\n", |
| 2607 | dev_priv->psr.last_exit); |
| 2608 | } |
| 2609 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2610 | intel_runtime_pm_put(dev_priv, wakeref); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2611 | return 0; |
| 2612 | } |
| 2613 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2614 | static int |
| 2615 | i915_edp_psr_debug_set(void *data, u64 val) |
| 2616 | { |
| 2617 | struct drm_i915_private *dev_priv = data; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2618 | struct drm_modeset_acquire_ctx ctx; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2619 | intel_wakeref_t wakeref; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2620 | int ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2621 | |
| 2622 | if (!CAN_PSR(dev_priv)) |
| 2623 | return -ENODEV; |
| 2624 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2625 | DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2626 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2627 | wakeref = intel_runtime_pm_get(dev_priv); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2628 | |
| 2629 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 2630 | |
| 2631 | retry: |
| 2632 | ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val); |
| 2633 | if (ret == -EDEADLK) { |
| 2634 | ret = drm_modeset_backoff(&ctx); |
| 2635 | if (!ret) |
| 2636 | goto retry; |
| 2637 | } |
| 2638 | |
| 2639 | drm_modeset_drop_locks(&ctx); |
| 2640 | drm_modeset_acquire_fini(&ctx); |
| 2641 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2642 | intel_runtime_pm_put(dev_priv, wakeref); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2643 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2644 | return ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2645 | } |
| 2646 | |
| 2647 | static int |
| 2648 | i915_edp_psr_debug_get(void *data, u64 *val) |
| 2649 | { |
| 2650 | struct drm_i915_private *dev_priv = data; |
| 2651 | |
| 2652 | if (!CAN_PSR(dev_priv)) |
| 2653 | return -ENODEV; |
| 2654 | |
| 2655 | *val = READ_ONCE(dev_priv->psr.debug); |
| 2656 | return 0; |
| 2657 | } |
| 2658 | |
| 2659 | DEFINE_SIMPLE_ATTRIBUTE(i915_edp_psr_debug_fops, |
| 2660 | i915_edp_psr_debug_get, i915_edp_psr_debug_set, |
| 2661 | "%llu\n"); |
| 2662 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2663 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2664 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2665 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2666 | unsigned long long power; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2667 | intel_wakeref_t wakeref; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2668 | u32 units; |
| 2669 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2670 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2671 | return -ENODEV; |
| 2672 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2673 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2674 | return -ENODEV; |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2675 | |
| 2676 | units = (power & 0x1f00) >> 8; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2677 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2678 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2679 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2680 | power = (1000000 * power) >> units; /* convert to uJ */ |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2681 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2682 | |
| 2683 | return 0; |
| 2684 | } |
| 2685 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2686 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2687 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2688 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2689 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2690 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2691 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2692 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2693 | |
Chris Wilson | 25c896bd | 2019-01-14 14:21:25 +0000 | [diff] [blame] | 2694 | seq_printf(m, "Runtime power status: %s\n", |
| 2695 | enableddisabled(!dev_priv->power_domains.wakeref)); |
| 2696 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 2697 | seq_printf(m, "GPU idle: %s (epoch %u)\n", |
| 2698 | yesno(!dev_priv->gt.awake), dev_priv->gt.epoch); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2699 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2700 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2701 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2702 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2703 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2704 | #else |
| 2705 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2706 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2707 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2708 | pci_power_name(pdev->current_state), |
| 2709 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2710 | |
Chris Wilson | bd780f3 | 2019-01-14 14:21:09 +0000 | [diff] [blame] | 2711 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) { |
| 2712 | struct drm_printer p = drm_seq_file_printer(m); |
| 2713 | |
| 2714 | print_intel_runtime_pm_wakeref(dev_priv, &p); |
| 2715 | } |
| 2716 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2717 | return 0; |
| 2718 | } |
| 2719 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2720 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2721 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2722 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2723 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2724 | int i; |
| 2725 | |
| 2726 | mutex_lock(&power_domains->lock); |
| 2727 | |
| 2728 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2729 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2730 | struct i915_power_well *power_well; |
| 2731 | enum intel_display_power_domain power_domain; |
| 2732 | |
| 2733 | power_well = &power_domains->power_wells[i]; |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2734 | seq_printf(m, "%-25s %d\n", power_well->desc->name, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2735 | power_well->count); |
| 2736 | |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2737 | for_each_power_domain(power_domain, power_well->desc->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2738 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2739 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2740 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2741 | } |
| 2742 | |
| 2743 | mutex_unlock(&power_domains->lock); |
| 2744 | |
| 2745 | return 0; |
| 2746 | } |
| 2747 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2748 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2749 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2750 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2751 | intel_wakeref_t wakeref; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2752 | struct intel_csr *csr; |
| 2753 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2754 | if (!HAS_CSR(dev_priv)) |
| 2755 | return -ENODEV; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2756 | |
| 2757 | csr = &dev_priv->csr; |
| 2758 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2759 | wakeref = intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2760 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2761 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2762 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2763 | |
| 2764 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2765 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2766 | |
| 2767 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2768 | CSR_VERSION_MINOR(csr->version)); |
| 2769 | |
Imre Deak | 34b2f8d | 2018-10-31 22:02:20 +0200 | [diff] [blame] | 2770 | if (WARN_ON(INTEL_GEN(dev_priv) > 11)) |
| 2771 | goto out; |
| 2772 | |
| 2773 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2774 | I915_READ(IS_BROXTON(dev_priv) ? BXT_CSR_DC3_DC5_COUNT : |
| 2775 | SKL_CSR_DC3_DC5_COUNT)); |
| 2776 | if (!IS_GEN9_LP(dev_priv)) |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2777 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2778 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2779 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2780 | out: |
| 2781 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2782 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2783 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2784 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2785 | intel_runtime_pm_put(dev_priv, wakeref); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2786 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2787 | return 0; |
| 2788 | } |
| 2789 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2790 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2791 | struct drm_display_mode *mode) |
| 2792 | { |
| 2793 | int i; |
| 2794 | |
| 2795 | for (i = 0; i < tabs; i++) |
| 2796 | seq_putc(m, '\t'); |
| 2797 | |
| 2798 | seq_printf(m, "id %d:\"%s\" freq %d clock %d hdisp %d hss %d hse %d htot %d vdisp %d vss %d vse %d vtot %d type 0x%x flags 0x%x\n", |
| 2799 | mode->base.id, mode->name, |
| 2800 | mode->vrefresh, mode->clock, |
| 2801 | mode->hdisplay, mode->hsync_start, |
| 2802 | mode->hsync_end, mode->htotal, |
| 2803 | mode->vdisplay, mode->vsync_start, |
| 2804 | mode->vsync_end, mode->vtotal, |
| 2805 | mode->type, mode->flags); |
| 2806 | } |
| 2807 | |
| 2808 | static void intel_encoder_info(struct seq_file *m, |
| 2809 | struct intel_crtc *intel_crtc, |
| 2810 | struct intel_encoder *intel_encoder) |
| 2811 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2812 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2813 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2814 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2815 | struct intel_connector *intel_connector; |
| 2816 | struct drm_encoder *encoder; |
| 2817 | |
| 2818 | encoder = &intel_encoder->base; |
| 2819 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2820 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2821 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2822 | struct drm_connector *connector = &intel_connector->base; |
| 2823 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2824 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2825 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2826 | drm_get_connector_status_name(connector->status)); |
| 2827 | if (connector->status == connector_status_connected) { |
| 2828 | struct drm_display_mode *mode = &crtc->mode; |
| 2829 | seq_printf(m, ", mode:\n"); |
| 2830 | intel_seq_print_mode(m, 2, mode); |
| 2831 | } else { |
| 2832 | seq_putc(m, '\n'); |
| 2833 | } |
| 2834 | } |
| 2835 | } |
| 2836 | |
| 2837 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2838 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2839 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2840 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2841 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2842 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2843 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2844 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2845 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2846 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2847 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2848 | fb->base.id, plane_state->src_x >> 16, |
| 2849 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2850 | else |
| 2851 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2852 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2853 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2854 | } |
| 2855 | |
| 2856 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2857 | { |
| 2858 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2859 | |
| 2860 | seq_printf(m, "\tfixed mode:\n"); |
| 2861 | intel_seq_print_mode(m, 2, mode); |
| 2862 | } |
| 2863 | |
| 2864 | static void intel_dp_info(struct seq_file *m, |
| 2865 | struct intel_connector *intel_connector) |
| 2866 | { |
| 2867 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2868 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2869 | |
| 2870 | 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] | 2871 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2872 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2873 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2874 | |
| 2875 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2876 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2877 | } |
| 2878 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2879 | static void intel_dp_mst_info(struct seq_file *m, |
| 2880 | struct intel_connector *intel_connector) |
| 2881 | { |
| 2882 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2883 | struct intel_dp_mst_encoder *intel_mst = |
| 2884 | enc_to_mst(&intel_encoder->base); |
| 2885 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2886 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2887 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2888 | intel_connector->port); |
| 2889 | |
| 2890 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2891 | } |
| 2892 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2893 | static void intel_hdmi_info(struct seq_file *m, |
| 2894 | struct intel_connector *intel_connector) |
| 2895 | { |
| 2896 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2897 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2898 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2899 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2900 | } |
| 2901 | |
| 2902 | static void intel_lvds_info(struct seq_file *m, |
| 2903 | struct intel_connector *intel_connector) |
| 2904 | { |
| 2905 | intel_panel_info(m, &intel_connector->panel); |
| 2906 | } |
| 2907 | |
| 2908 | static void intel_connector_info(struct seq_file *m, |
| 2909 | struct drm_connector *connector) |
| 2910 | { |
| 2911 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2912 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2913 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2914 | |
| 2915 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2916 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2917 | drm_get_connector_status_name(connector->status)); |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame] | 2918 | |
| 2919 | if (connector->status == connector_status_disconnected) |
| 2920 | return; |
| 2921 | |
| 2922 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2923 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2924 | connector->display_info.width_mm, |
| 2925 | connector->display_info.height_mm); |
| 2926 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2927 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2928 | seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2929 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 2930 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2931 | return; |
| 2932 | |
| 2933 | switch (connector->connector_type) { |
| 2934 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2935 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2936 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2937 | intel_dp_mst_info(m, intel_connector); |
| 2938 | else |
| 2939 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2940 | break; |
| 2941 | case DRM_MODE_CONNECTOR_LVDS: |
| 2942 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2943 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2944 | break; |
| 2945 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2946 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 2947 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2948 | intel_hdmi_info(m, intel_connector); |
| 2949 | break; |
| 2950 | default: |
| 2951 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2952 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2953 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2954 | seq_printf(m, "\tmodes:\n"); |
| 2955 | list_for_each_entry(mode, &connector->modes, head) |
| 2956 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2957 | } |
| 2958 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2959 | static const char *plane_type(enum drm_plane_type type) |
| 2960 | { |
| 2961 | switch (type) { |
| 2962 | case DRM_PLANE_TYPE_OVERLAY: |
| 2963 | return "OVL"; |
| 2964 | case DRM_PLANE_TYPE_PRIMARY: |
| 2965 | return "PRI"; |
| 2966 | case DRM_PLANE_TYPE_CURSOR: |
| 2967 | return "CUR"; |
| 2968 | /* |
| 2969 | * Deliberately omitting default: to generate compiler warnings |
| 2970 | * when a new drm_plane_type gets added. |
| 2971 | */ |
| 2972 | } |
| 2973 | |
| 2974 | return "unknown"; |
| 2975 | } |
| 2976 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2977 | static void plane_rotation(char *buf, size_t bufsize, unsigned int rotation) |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2978 | { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2979 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2980 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2981 | * will print them all to visualize if the values are misused |
| 2982 | */ |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2983 | snprintf(buf, bufsize, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2984 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2985 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 2986 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 2987 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 2988 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 2989 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 2990 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2991 | rotation); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2992 | } |
| 2993 | |
| 2994 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2995 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2996 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2997 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2998 | struct intel_plane *intel_plane; |
| 2999 | |
| 3000 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3001 | struct drm_plane_state *state; |
| 3002 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3003 | struct drm_format_name_buf format_name; |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3004 | char rot_str[48]; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3005 | |
| 3006 | if (!plane->state) { |
| 3007 | seq_puts(m, "plane->state is NULL!\n"); |
| 3008 | continue; |
| 3009 | } |
| 3010 | |
| 3011 | state = plane->state; |
| 3012 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3013 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3014 | drm_get_format_name(state->fb->format->format, |
| 3015 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3016 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3017 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3018 | } |
| 3019 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3020 | plane_rotation(rot_str, sizeof(rot_str), state->rotation); |
| 3021 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3022 | 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", |
| 3023 | plane->base.id, |
| 3024 | plane_type(intel_plane->base.type), |
| 3025 | state->crtc_x, state->crtc_y, |
| 3026 | state->crtc_w, state->crtc_h, |
| 3027 | (state->src_x >> 16), |
| 3028 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3029 | (state->src_y >> 16), |
| 3030 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3031 | (state->src_w >> 16), |
| 3032 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3033 | (state->src_h >> 16), |
| 3034 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3035 | format_name.str, |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 3036 | rot_str); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3037 | } |
| 3038 | } |
| 3039 | |
| 3040 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3041 | { |
| 3042 | struct intel_crtc_state *pipe_config; |
| 3043 | int num_scalers = intel_crtc->num_scalers; |
| 3044 | int i; |
| 3045 | |
| 3046 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3047 | |
| 3048 | /* Not all platformas have a scaler */ |
| 3049 | if (num_scalers) { |
| 3050 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3051 | num_scalers, |
| 3052 | pipe_config->scaler_state.scaler_users, |
| 3053 | pipe_config->scaler_state.scaler_id); |
| 3054 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3055 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3056 | struct intel_scaler *sc = |
| 3057 | &pipe_config->scaler_state.scalers[i]; |
| 3058 | |
| 3059 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3060 | i, yesno(sc->in_use), sc->mode); |
| 3061 | } |
| 3062 | seq_puts(m, "\n"); |
| 3063 | } else { |
| 3064 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3065 | } |
| 3066 | } |
| 3067 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3068 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3069 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3070 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3071 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3072 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3073 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3074 | struct drm_connector_list_iter conn_iter; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3075 | intel_wakeref_t wakeref; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3076 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3077 | wakeref = intel_runtime_pm_get(dev_priv); |
| 3078 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3079 | seq_printf(m, "CRTC info\n"); |
| 3080 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3081 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3082 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3083 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3084 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3085 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3086 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3087 | 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] | 3088 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3089 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3090 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3091 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3092 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3093 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3094 | struct intel_plane *cursor = |
| 3095 | to_intel_plane(crtc->base.cursor); |
| 3096 | |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3097 | intel_crtc_info(m, crtc); |
| 3098 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3099 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3100 | yesno(cursor->base.state->visible), |
| 3101 | cursor->base.state->crtc_x, |
| 3102 | cursor->base.state->crtc_y, |
| 3103 | cursor->base.state->crtc_w, |
| 3104 | cursor->base.state->crtc_h, |
| 3105 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3106 | intel_scaler_info(m, crtc); |
| 3107 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3108 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3109 | |
| 3110 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3111 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3112 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3113 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3114 | } |
| 3115 | |
| 3116 | seq_printf(m, "\n"); |
| 3117 | seq_printf(m, "Connector info\n"); |
| 3118 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3119 | mutex_lock(&dev->mode_config.mutex); |
| 3120 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3121 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3122 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3123 | drm_connector_list_iter_end(&conn_iter); |
| 3124 | mutex_unlock(&dev->mode_config.mutex); |
| 3125 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3126 | intel_runtime_pm_put(dev_priv, wakeref); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3127 | |
| 3128 | return 0; |
| 3129 | } |
| 3130 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3131 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3132 | { |
| 3133 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3134 | struct intel_engine_cs *engine; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3135 | intel_wakeref_t wakeref; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3136 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3137 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3138 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3139 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3140 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 3141 | seq_printf(m, "GT awake? %s (epoch %u)\n", |
| 3142 | yesno(dev_priv->gt.awake), dev_priv->gt.epoch); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3143 | seq_printf(m, "Global active requests: %d\n", |
| 3144 | dev_priv->gt.active_requests); |
Lionel Landwerlin | f577a03 | 2017-11-13 23:34:53 +0000 | [diff] [blame] | 3145 | seq_printf(m, "CS timestamp frequency: %u kHz\n", |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3146 | RUNTIME_INFO(dev_priv)->cs_timestamp_frequency_khz); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3147 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3148 | p = drm_seq_file_printer(m); |
| 3149 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 0db18b1 | 2017-12-08 01:23:00 +0000 | [diff] [blame] | 3150 | intel_engine_dump(engine, &p, "%s\n", engine->name); |
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 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3153 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3154 | return 0; |
| 3155 | } |
| 3156 | |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3157 | static int i915_rcs_topology(struct seq_file *m, void *unused) |
| 3158 | { |
| 3159 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3160 | struct drm_printer p = drm_seq_file_printer(m); |
| 3161 | |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3162 | intel_device_info_dump_topology(&RUNTIME_INFO(dev_priv)->sseu, &p); |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3163 | |
| 3164 | return 0; |
| 3165 | } |
| 3166 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3167 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3168 | { |
| 3169 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3170 | |
| 3171 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3172 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3173 | |
| 3174 | return 0; |
| 3175 | } |
| 3176 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3177 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3178 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3179 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3180 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3181 | int i; |
| 3182 | |
| 3183 | drm_modeset_lock_all(dev); |
| 3184 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3185 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3186 | |
Lucas De Marchi | 72f775f | 2018-03-20 15:06:34 -0700 | [diff] [blame] | 3187 | 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] | 3188 | pll->info->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3189 | 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] | 3190 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3191 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3192 | 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] | 3193 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3194 | pll->state.hw_state.dpll_md); |
| 3195 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3196 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3197 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Paulo Zanoni | c27e917 | 2018-04-27 16:14:36 -0700 | [diff] [blame] | 3198 | seq_printf(m, " cfgcr0: 0x%08x\n", pll->state.hw_state.cfgcr0); |
| 3199 | seq_printf(m, " cfgcr1: 0x%08x\n", pll->state.hw_state.cfgcr1); |
| 3200 | seq_printf(m, " mg_refclkin_ctl: 0x%08x\n", |
| 3201 | pll->state.hw_state.mg_refclkin_ctl); |
| 3202 | seq_printf(m, " mg_clktop2_coreclkctl1: 0x%08x\n", |
| 3203 | pll->state.hw_state.mg_clktop2_coreclkctl1); |
| 3204 | seq_printf(m, " mg_clktop2_hsclkctl: 0x%08x\n", |
| 3205 | pll->state.hw_state.mg_clktop2_hsclkctl); |
| 3206 | seq_printf(m, " mg_pll_div0: 0x%08x\n", |
| 3207 | pll->state.hw_state.mg_pll_div0); |
| 3208 | seq_printf(m, " mg_pll_div1: 0x%08x\n", |
| 3209 | pll->state.hw_state.mg_pll_div1); |
| 3210 | seq_printf(m, " mg_pll_lf: 0x%08x\n", |
| 3211 | pll->state.hw_state.mg_pll_lf); |
| 3212 | seq_printf(m, " mg_pll_frac_lock: 0x%08x\n", |
| 3213 | pll->state.hw_state.mg_pll_frac_lock); |
| 3214 | seq_printf(m, " mg_pll_ssc: 0x%08x\n", |
| 3215 | pll->state.hw_state.mg_pll_ssc); |
| 3216 | seq_printf(m, " mg_pll_bias: 0x%08x\n", |
| 3217 | pll->state.hw_state.mg_pll_bias); |
| 3218 | seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", |
| 3219 | pll->state.hw_state.mg_pll_tdc_coldst_bias); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3220 | } |
| 3221 | drm_modeset_unlock_all(dev); |
| 3222 | |
| 3223 | return 0; |
| 3224 | } |
| 3225 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3226 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3227 | { |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3228 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3229 | const struct i915_wa_list *wal = &i915->engine[RCS]->ctx_wa_list; |
| 3230 | struct i915_wa *wa; |
| 3231 | unsigned int i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3232 | |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3233 | seq_printf(m, "Workarounds applied: %u\n", wal->count); |
| 3234 | for (i = 0, wa = wal->list; i < wal->count; i++, wa++) |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3235 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n", |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3236 | i915_mmio_reg_offset(wa->reg), wa->val, wa->mask); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3237 | |
| 3238 | return 0; |
| 3239 | } |
| 3240 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3241 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3242 | { |
| 3243 | struct drm_i915_private *dev_priv = m->private; |
| 3244 | |
| 3245 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3246 | yesno(dev_priv->ipc_enabled)); |
| 3247 | return 0; |
| 3248 | } |
| 3249 | |
| 3250 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3251 | { |
| 3252 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3253 | |
| 3254 | if (!HAS_IPC(dev_priv)) |
| 3255 | return -ENODEV; |
| 3256 | |
| 3257 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3258 | } |
| 3259 | |
| 3260 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3261 | size_t len, loff_t *offp) |
| 3262 | { |
| 3263 | struct seq_file *m = file->private_data; |
| 3264 | struct drm_i915_private *dev_priv = m->private; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3265 | intel_wakeref_t wakeref; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3266 | bool enable; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3267 | int ret; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3268 | |
| 3269 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3270 | if (ret < 0) |
| 3271 | return ret; |
| 3272 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3273 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3274 | if (!dev_priv->ipc_enabled && enable) |
| 3275 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3276 | dev_priv->wm.distrust_bios_wm = true; |
| 3277 | dev_priv->ipc_enabled = enable; |
| 3278 | intel_enable_ipc(dev_priv); |
| 3279 | } |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3280 | |
| 3281 | return len; |
| 3282 | } |
| 3283 | |
| 3284 | static const struct file_operations i915_ipc_status_fops = { |
| 3285 | .owner = THIS_MODULE, |
| 3286 | .open = i915_ipc_status_open, |
| 3287 | .read = seq_read, |
| 3288 | .llseek = seq_lseek, |
| 3289 | .release = single_release, |
| 3290 | .write = i915_ipc_status_write |
| 3291 | }; |
| 3292 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3293 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3294 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3295 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3296 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3297 | struct skl_ddb_entry *entry; |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3298 | struct intel_crtc *crtc; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3299 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3300 | if (INTEL_GEN(dev_priv) < 9) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 3301 | return -ENODEV; |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3302 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3303 | drm_modeset_lock_all(dev); |
| 3304 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3305 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3306 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3307 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
| 3308 | struct intel_crtc_state *crtc_state = |
| 3309 | to_intel_crtc_state(crtc->base.state); |
| 3310 | enum pipe pipe = crtc->pipe; |
| 3311 | enum plane_id plane_id; |
| 3312 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3313 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3314 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3315 | for_each_plane_id_on_crtc(crtc, plane_id) { |
| 3316 | entry = &crtc_state->wm.skl.plane_ddb_y[plane_id]; |
| 3317 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane_id + 1, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3318 | entry->start, entry->end, |
| 3319 | skl_ddb_entry_size(entry)); |
| 3320 | } |
| 3321 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3322 | entry = &crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3323 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3324 | entry->end, skl_ddb_entry_size(entry)); |
| 3325 | } |
| 3326 | |
| 3327 | drm_modeset_unlock_all(dev); |
| 3328 | |
| 3329 | return 0; |
| 3330 | } |
| 3331 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3332 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3333 | struct drm_device *dev, |
| 3334 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3335 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3336 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3337 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3338 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3339 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3340 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3341 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3342 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3343 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3344 | if (connector->state->crtc != &intel_crtc->base) |
| 3345 | continue; |
| 3346 | |
| 3347 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3348 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3349 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3350 | |
| 3351 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3352 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3353 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3354 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3355 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3356 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3357 | else |
| 3358 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3359 | |
| 3360 | seq_puts(m, "\n\n"); |
| 3361 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3362 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3363 | struct intel_panel *panel; |
| 3364 | |
| 3365 | mutex_lock(&drrs->mutex); |
| 3366 | /* DRRS Supported */ |
| 3367 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3368 | |
| 3369 | /* disable_drrs() will make drrs->dp NULL */ |
| 3370 | if (!drrs->dp) { |
C, Ramalingam | ce6e213 | 2017-11-20 09:53:47 +0530 | [diff] [blame] | 3371 | seq_puts(m, "Idleness DRRS: Disabled\n"); |
| 3372 | if (dev_priv->psr.enabled) |
| 3373 | seq_puts(m, |
| 3374 | "\tAs PSR is enabled, DRRS is not enabled\n"); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3375 | mutex_unlock(&drrs->mutex); |
| 3376 | return; |
| 3377 | } |
| 3378 | |
| 3379 | panel = &drrs->dp->attached_connector->panel; |
| 3380 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3381 | drrs->busy_frontbuffer_bits); |
| 3382 | |
| 3383 | seq_puts(m, "\n\t\t"); |
| 3384 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3385 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3386 | vrefresh = panel->fixed_mode->vrefresh; |
| 3387 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3388 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3389 | vrefresh = panel->downclock_mode->vrefresh; |
| 3390 | } else { |
| 3391 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3392 | drrs->refresh_rate_type); |
| 3393 | mutex_unlock(&drrs->mutex); |
| 3394 | return; |
| 3395 | } |
| 3396 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3397 | |
| 3398 | seq_puts(m, "\n\t\t"); |
| 3399 | mutex_unlock(&drrs->mutex); |
| 3400 | } else { |
| 3401 | /* DRRS not supported. Print the VBT parameter*/ |
| 3402 | seq_puts(m, "\tDRRS Supported : No"); |
| 3403 | } |
| 3404 | seq_puts(m, "\n"); |
| 3405 | } |
| 3406 | |
| 3407 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3408 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3409 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3410 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3411 | struct intel_crtc *intel_crtc; |
| 3412 | int active_crtc_cnt = 0; |
| 3413 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3414 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3415 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3416 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3417 | active_crtc_cnt++; |
| 3418 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3419 | |
| 3420 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3421 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3422 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3423 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3424 | |
| 3425 | if (!active_crtc_cnt) |
| 3426 | seq_puts(m, "No active crtc found\n"); |
| 3427 | |
| 3428 | return 0; |
| 3429 | } |
| 3430 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3431 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3432 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3433 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3434 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3435 | struct intel_encoder *intel_encoder; |
| 3436 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3437 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3438 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3439 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3440 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3441 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3442 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3443 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3444 | |
| 3445 | intel_encoder = intel_attached_encoder(connector); |
| 3446 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3447 | continue; |
| 3448 | |
| 3449 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3450 | if (!intel_dig_port->dp.can_mst) |
| 3451 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3452 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3453 | seq_printf(m, "MST Source Port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3454 | port_name(intel_dig_port->base.port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3455 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3456 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3457 | drm_connector_list_iter_end(&conn_iter); |
| 3458 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3459 | return 0; |
| 3460 | } |
| 3461 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3462 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3463 | const char __user *ubuf, |
| 3464 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3465 | { |
| 3466 | char *input_buffer; |
| 3467 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3468 | struct drm_device *dev; |
| 3469 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3470 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3471 | struct intel_dp *intel_dp; |
| 3472 | int val = 0; |
| 3473 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3474 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3475 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3476 | if (len == 0) |
| 3477 | return 0; |
| 3478 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3479 | input_buffer = memdup_user_nul(ubuf, len); |
| 3480 | if (IS_ERR(input_buffer)) |
| 3481 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3482 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3483 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3484 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3485 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3486 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3487 | struct intel_encoder *encoder; |
| 3488 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3489 | if (connector->connector_type != |
| 3490 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3491 | continue; |
| 3492 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3493 | encoder = to_intel_encoder(connector->encoder); |
| 3494 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3495 | continue; |
| 3496 | |
| 3497 | if (encoder && connector->status == connector_status_connected) { |
| 3498 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3499 | status = kstrtoint(input_buffer, 10, &val); |
| 3500 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3501 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3502 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3503 | /* To prevent erroneous activation of the compliance |
| 3504 | * testing code, only accept an actual value of 1 here |
| 3505 | */ |
| 3506 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3507 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3508 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3509 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3510 | } |
| 3511 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3512 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3513 | kfree(input_buffer); |
| 3514 | if (status < 0) |
| 3515 | return status; |
| 3516 | |
| 3517 | *offp += len; |
| 3518 | return len; |
| 3519 | } |
| 3520 | |
| 3521 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3522 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3523 | struct drm_i915_private *dev_priv = m->private; |
| 3524 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3525 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3526 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3527 | struct intel_dp *intel_dp; |
| 3528 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3529 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3530 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3531 | struct intel_encoder *encoder; |
| 3532 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3533 | if (connector->connector_type != |
| 3534 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3535 | continue; |
| 3536 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3537 | encoder = to_intel_encoder(connector->encoder); |
| 3538 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3539 | continue; |
| 3540 | |
| 3541 | if (encoder && connector->status == connector_status_connected) { |
| 3542 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3543 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3544 | seq_puts(m, "1"); |
| 3545 | else |
| 3546 | seq_puts(m, "0"); |
| 3547 | } else |
| 3548 | seq_puts(m, "0"); |
| 3549 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3550 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3551 | |
| 3552 | return 0; |
| 3553 | } |
| 3554 | |
| 3555 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3556 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3557 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3558 | return single_open(file, i915_displayport_test_active_show, |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3559 | inode->i_private); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3560 | } |
| 3561 | |
| 3562 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3563 | .owner = THIS_MODULE, |
| 3564 | .open = i915_displayport_test_active_open, |
| 3565 | .read = seq_read, |
| 3566 | .llseek = seq_lseek, |
| 3567 | .release = single_release, |
| 3568 | .write = i915_displayport_test_active_write |
| 3569 | }; |
| 3570 | |
| 3571 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3572 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3573 | struct drm_i915_private *dev_priv = m->private; |
| 3574 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3575 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3576 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3577 | struct intel_dp *intel_dp; |
| 3578 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3579 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3580 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3581 | struct intel_encoder *encoder; |
| 3582 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3583 | if (connector->connector_type != |
| 3584 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3585 | continue; |
| 3586 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3587 | encoder = to_intel_encoder(connector->encoder); |
| 3588 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3589 | continue; |
| 3590 | |
| 3591 | if (encoder && connector->status == connector_status_connected) { |
| 3592 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3593 | if (intel_dp->compliance.test_type == |
| 3594 | DP_TEST_LINK_EDID_READ) |
| 3595 | seq_printf(m, "%lx", |
| 3596 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3597 | else if (intel_dp->compliance.test_type == |
| 3598 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3599 | seq_printf(m, "hdisplay: %d\n", |
| 3600 | intel_dp->compliance.test_data.hdisplay); |
| 3601 | seq_printf(m, "vdisplay: %d\n", |
| 3602 | intel_dp->compliance.test_data.vdisplay); |
| 3603 | seq_printf(m, "bpc: %u\n", |
| 3604 | intel_dp->compliance.test_data.bpc); |
| 3605 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3606 | } else |
| 3607 | seq_puts(m, "0"); |
| 3608 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3609 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3610 | |
| 3611 | return 0; |
| 3612 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3613 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3614 | |
| 3615 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3616 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3617 | struct drm_i915_private *dev_priv = m->private; |
| 3618 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3619 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3620 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3621 | struct intel_dp *intel_dp; |
| 3622 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3623 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3624 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3625 | struct intel_encoder *encoder; |
| 3626 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3627 | if (connector->connector_type != |
| 3628 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3629 | continue; |
| 3630 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3631 | encoder = to_intel_encoder(connector->encoder); |
| 3632 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3633 | continue; |
| 3634 | |
| 3635 | if (encoder && connector->status == connector_status_connected) { |
| 3636 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3637 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3638 | } else |
| 3639 | seq_puts(m, "0"); |
| 3640 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3641 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3642 | |
| 3643 | return 0; |
| 3644 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3645 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3646 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3647 | static void wm_latency_show(struct seq_file *m, const uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3648 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3649 | struct drm_i915_private *dev_priv = m->private; |
| 3650 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3651 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3652 | int num_levels; |
| 3653 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3654 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3655 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3656 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3657 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3658 | else if (IS_G4X(dev_priv)) |
| 3659 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3660 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3661 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3662 | |
| 3663 | drm_modeset_lock_all(dev); |
| 3664 | |
| 3665 | for (level = 0; level < num_levels; level++) { |
| 3666 | unsigned int latency = wm[level]; |
| 3667 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3668 | /* |
| 3669 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3670 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3671 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3672 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3673 | IS_VALLEYVIEW(dev_priv) || |
| 3674 | IS_CHERRYVIEW(dev_priv) || |
| 3675 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3676 | latency *= 10; |
| 3677 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3678 | latency *= 5; |
| 3679 | |
| 3680 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3681 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3682 | } |
| 3683 | |
| 3684 | drm_modeset_unlock_all(dev); |
| 3685 | } |
| 3686 | |
| 3687 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3688 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3689 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3690 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3691 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3692 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3693 | latencies = dev_priv->wm.skl_latency; |
| 3694 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3695 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3696 | |
| 3697 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3698 | |
| 3699 | return 0; |
| 3700 | } |
| 3701 | |
| 3702 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3703 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3704 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3705 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3706 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3707 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3708 | latencies = dev_priv->wm.skl_latency; |
| 3709 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3710 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3711 | |
| 3712 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3713 | |
| 3714 | return 0; |
| 3715 | } |
| 3716 | |
| 3717 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3718 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3719 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3720 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3721 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3722 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3723 | latencies = dev_priv->wm.skl_latency; |
| 3724 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3725 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3726 | |
| 3727 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3728 | |
| 3729 | return 0; |
| 3730 | } |
| 3731 | |
| 3732 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3733 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3734 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3735 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3736 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3737 | return -ENODEV; |
| 3738 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3739 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3740 | } |
| 3741 | |
| 3742 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3743 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3744 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3745 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3746 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3747 | return -ENODEV; |
| 3748 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3749 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3750 | } |
| 3751 | |
| 3752 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3753 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3754 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3755 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3756 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3757 | return -ENODEV; |
| 3758 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3759 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3760 | } |
| 3761 | |
| 3762 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3763 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3764 | { |
| 3765 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3766 | struct drm_i915_private *dev_priv = m->private; |
| 3767 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3768 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3769 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3770 | int level; |
| 3771 | int ret; |
| 3772 | char tmp[32]; |
| 3773 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3774 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3775 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3776 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3777 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3778 | else if (IS_G4X(dev_priv)) |
| 3779 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3780 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3781 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3782 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3783 | if (len >= sizeof(tmp)) |
| 3784 | return -EINVAL; |
| 3785 | |
| 3786 | if (copy_from_user(tmp, ubuf, len)) |
| 3787 | return -EFAULT; |
| 3788 | |
| 3789 | tmp[len] = '\0'; |
| 3790 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3791 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3792 | &new[0], &new[1], &new[2], &new[3], |
| 3793 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3794 | if (ret != num_levels) |
| 3795 | return -EINVAL; |
| 3796 | |
| 3797 | drm_modeset_lock_all(dev); |
| 3798 | |
| 3799 | for (level = 0; level < num_levels; level++) |
| 3800 | wm[level] = new[level]; |
| 3801 | |
| 3802 | drm_modeset_unlock_all(dev); |
| 3803 | |
| 3804 | return len; |
| 3805 | } |
| 3806 | |
| 3807 | |
| 3808 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3809 | size_t len, loff_t *offp) |
| 3810 | { |
| 3811 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3812 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3813 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3814 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3815 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3816 | latencies = dev_priv->wm.skl_latency; |
| 3817 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3818 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3819 | |
| 3820 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3821 | } |
| 3822 | |
| 3823 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3824 | size_t len, loff_t *offp) |
| 3825 | { |
| 3826 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3827 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3828 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3829 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3830 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3831 | latencies = dev_priv->wm.skl_latency; |
| 3832 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3833 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3834 | |
| 3835 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3839 | size_t len, loff_t *offp) |
| 3840 | { |
| 3841 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3842 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3843 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3844 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3845 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3846 | latencies = dev_priv->wm.skl_latency; |
| 3847 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3848 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3849 | |
| 3850 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3851 | } |
| 3852 | |
| 3853 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3854 | .owner = THIS_MODULE, |
| 3855 | .open = pri_wm_latency_open, |
| 3856 | .read = seq_read, |
| 3857 | .llseek = seq_lseek, |
| 3858 | .release = single_release, |
| 3859 | .write = pri_wm_latency_write |
| 3860 | }; |
| 3861 | |
| 3862 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3863 | .owner = THIS_MODULE, |
| 3864 | .open = spr_wm_latency_open, |
| 3865 | .read = seq_read, |
| 3866 | .llseek = seq_lseek, |
| 3867 | .release = single_release, |
| 3868 | .write = spr_wm_latency_write |
| 3869 | }; |
| 3870 | |
| 3871 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3872 | .owner = THIS_MODULE, |
| 3873 | .open = cur_wm_latency_open, |
| 3874 | .read = seq_read, |
| 3875 | .llseek = seq_lseek, |
| 3876 | .release = single_release, |
| 3877 | .write = cur_wm_latency_write |
| 3878 | }; |
| 3879 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3880 | static int |
| 3881 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3882 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3883 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3884 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 3885 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3886 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3887 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3888 | } |
| 3889 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3890 | static int |
| 3891 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3892 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3893 | struct drm_i915_private *i915 = data; |
| 3894 | struct intel_engine_cs *engine; |
| 3895 | unsigned int tmp; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3896 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3897 | /* |
| 3898 | * There is no safeguard against this debugfs entry colliding |
| 3899 | * with the hangcheck calling same i915_handle_error() in |
| 3900 | * parallel, causing an explosion. For now we assume that the |
| 3901 | * test harness is responsible enough not to inject gpu hangs |
| 3902 | * while it is writing to 'i915_wedged' |
| 3903 | */ |
| 3904 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3905 | if (i915_reset_backoff(&i915->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3906 | return -EAGAIN; |
| 3907 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3908 | for_each_engine_masked(engine, i915, val, tmp) { |
| 3909 | engine->hangcheck.seqno = intel_engine_get_seqno(engine); |
| 3910 | engine->hangcheck.stalled = true; |
| 3911 | } |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3912 | |
Chris Wilson | ce80075 | 2018-03-20 10:04:49 +0000 | [diff] [blame] | 3913 | i915_handle_error(i915, val, I915_ERROR_CAPTURE, |
| 3914 | "Manually set wedged engine mask = %llx", val); |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3915 | |
| 3916 | wait_on_bit(&i915->gpu_error.flags, |
Chris Wilson | d3df42b | 2017-03-16 17:13:05 +0000 | [diff] [blame] | 3917 | I915_RESET_HANDOFF, |
| 3918 | TASK_UNINTERRUPTIBLE); |
| 3919 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3920 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3921 | } |
| 3922 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3923 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3924 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3925 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3926 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3927 | static int |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3928 | fault_irq_set(struct drm_i915_private *i915, |
| 3929 | unsigned long *irq, |
| 3930 | unsigned long val) |
| 3931 | { |
| 3932 | int err; |
| 3933 | |
| 3934 | err = mutex_lock_interruptible(&i915->drm.struct_mutex); |
| 3935 | if (err) |
| 3936 | return err; |
| 3937 | |
| 3938 | err = i915_gem_wait_for_idle(i915, |
| 3939 | I915_WAIT_LOCKED | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 3940 | I915_WAIT_INTERRUPTIBLE, |
| 3941 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3942 | if (err) |
| 3943 | goto err_unlock; |
| 3944 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3945 | *irq = val; |
| 3946 | mutex_unlock(&i915->drm.struct_mutex); |
| 3947 | |
| 3948 | /* Flush idle worker to disarm irq */ |
Chris Wilson | 7c26240 | 2017-10-06 11:40:38 +0100 | [diff] [blame] | 3949 | drain_delayed_work(&i915->gt.idle_work); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3950 | |
| 3951 | return 0; |
| 3952 | |
| 3953 | err_unlock: |
| 3954 | mutex_unlock(&i915->drm.struct_mutex); |
| 3955 | return err; |
| 3956 | } |
| 3957 | |
| 3958 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3959 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 3960 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3961 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3962 | |
| 3963 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 3964 | return 0; |
| 3965 | } |
| 3966 | |
| 3967 | static int |
| 3968 | i915_ring_missed_irq_set(void *data, u64 val) |
| 3969 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3970 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3971 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3972 | return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3973 | } |
| 3974 | |
| 3975 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 3976 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 3977 | "0x%08llx\n"); |
| 3978 | |
| 3979 | static int |
| 3980 | i915_ring_test_irq_get(void *data, u64 *val) |
| 3981 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3982 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3983 | |
| 3984 | *val = dev_priv->gpu_error.test_irq_rings; |
| 3985 | |
| 3986 | return 0; |
| 3987 | } |
| 3988 | |
| 3989 | static int |
| 3990 | i915_ring_test_irq_set(void *data, u64 val) |
| 3991 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 3992 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3993 | |
Chris Wilson | 5f52172 | 2018-09-07 12:28:51 +0100 | [diff] [blame] | 3994 | /* GuC keeps the user interrupt permanently enabled for submission */ |
| 3995 | if (USES_GUC_SUBMISSION(i915)) |
| 3996 | return -ENODEV; |
| 3997 | |
| 3998 | /* |
| 3999 | * From icl, we can no longer individually mask interrupt generation |
| 4000 | * from each engine. |
| 4001 | */ |
| 4002 | if (INTEL_GEN(i915) >= 11) |
| 4003 | return -ENODEV; |
| 4004 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4005 | val &= INTEL_INFO(i915)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4006 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4007 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4008 | return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4009 | } |
| 4010 | |
| 4011 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4012 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4013 | "0x%08llx\n"); |
| 4014 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4015 | #define DROP_UNBOUND BIT(0) |
| 4016 | #define DROP_BOUND BIT(1) |
| 4017 | #define DROP_RETIRE BIT(2) |
| 4018 | #define DROP_ACTIVE BIT(3) |
| 4019 | #define DROP_FREED BIT(4) |
| 4020 | #define DROP_SHRINK_ALL BIT(5) |
| 4021 | #define DROP_IDLE BIT(6) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4022 | #define DROP_RESET_ACTIVE BIT(7) |
| 4023 | #define DROP_RESET_SEQNO BIT(8) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4024 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4025 | DROP_BOUND | \ |
| 4026 | DROP_RETIRE | \ |
| 4027 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4028 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4029 | DROP_SHRINK_ALL |\ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4030 | DROP_IDLE | \ |
| 4031 | DROP_RESET_ACTIVE | \ |
| 4032 | DROP_RESET_SEQNO) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4033 | static int |
| 4034 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4035 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4036 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4037 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4038 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4039 | } |
| 4040 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4041 | static int |
| 4042 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4043 | { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4044 | struct drm_i915_private *i915 = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4045 | intel_wakeref_t wakeref; |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4046 | int ret = 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4047 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4048 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 4049 | val, val & DROP_ALL); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4050 | wakeref = intel_runtime_pm_get(i915); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4051 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4052 | if (val & DROP_RESET_ACTIVE && !intel_engines_are_idle(i915)) |
| 4053 | i915_gem_set_wedged(i915); |
| 4054 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4055 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4056 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4057 | if (val & (DROP_ACTIVE | DROP_RETIRE | DROP_RESET_SEQNO)) { |
| 4058 | ret = mutex_lock_interruptible(&i915->drm.struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4059 | if (ret) |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 4060 | goto out; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4061 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4062 | if (val & DROP_ACTIVE) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4063 | ret = i915_gem_wait_for_idle(i915, |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4064 | I915_WAIT_INTERRUPTIBLE | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 4065 | I915_WAIT_LOCKED, |
| 4066 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4067 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4068 | if (val & DROP_RETIRE) |
| 4069 | i915_retire_requests(i915); |
| 4070 | |
| 4071 | mutex_unlock(&i915->drm.struct_mutex); |
| 4072 | } |
| 4073 | |
| 4074 | if (val & DROP_RESET_ACTIVE && |
| 4075 | i915_terminally_wedged(&i915->gpu_error)) { |
| 4076 | i915_handle_error(i915, ALL_ENGINES, 0, NULL); |
| 4077 | wait_on_bit(&i915->gpu_error.flags, |
| 4078 | I915_RESET_HANDOFF, |
| 4079 | TASK_UNINTERRUPTIBLE); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4080 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4081 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4082 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4083 | if (val & DROP_BOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4084 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4085 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4086 | if (val & DROP_UNBOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4087 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4088 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4089 | if (val & DROP_SHRINK_ALL) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4090 | i915_gem_shrink_all(i915); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4091 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4092 | |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 4093 | if (val & DROP_IDLE) { |
| 4094 | do { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4095 | if (READ_ONCE(i915->gt.active_requests)) |
| 4096 | flush_delayed_work(&i915->gt.retire_work); |
| 4097 | drain_delayed_work(&i915->gt.idle_work); |
| 4098 | } while (READ_ONCE(i915->gt.awake)); |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 4099 | } |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4100 | |
Chris Wilson | c9c70471 | 2018-02-19 22:06:31 +0000 | [diff] [blame] | 4101 | if (val & DROP_FREED) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4102 | i915_gem_drain_freed_objects(i915); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4103 | |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 4104 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4105 | intel_runtime_pm_put(i915, wakeref); |
Chris Wilson | 9d3eb2c | 2018-10-15 12:58:56 +0100 | [diff] [blame] | 4106 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4107 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4108 | } |
| 4109 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4110 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4111 | i915_drop_caches_get, i915_drop_caches_set, |
| 4112 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4113 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4114 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4115 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4116 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4117 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4118 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4119 | u32 snpcr = 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4120 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 4121 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4122 | return -ENODEV; |
| 4123 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4124 | with_intel_runtime_pm(dev_priv, wakeref) |
| 4125 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4126 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4127 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4128 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4129 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4130 | } |
| 4131 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4132 | static int |
| 4133 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4134 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4135 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4136 | intel_wakeref_t wakeref; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4137 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 4138 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4139 | return -ENODEV; |
| 4140 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4141 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4142 | return -EINVAL; |
| 4143 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4144 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4145 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4146 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4147 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4148 | /* Update the cache sharing policy here as well */ |
| 4149 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4150 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4151 | snpcr |= val << GEN6_MBC_SNPCR_SHIFT; |
| 4152 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4153 | } |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4154 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4155 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4156 | } |
| 4157 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4158 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4159 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4160 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4161 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4162 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4163 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4164 | { |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4165 | #define SS_MAX 2 |
| 4166 | const int ss_max = SS_MAX; |
| 4167 | u32 sig1[SS_MAX], sig2[SS_MAX]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4168 | int ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4169 | |
| 4170 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4171 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4172 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4173 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4174 | |
| 4175 | for (ss = 0; ss < ss_max; ss++) { |
| 4176 | unsigned int eu_cnt; |
| 4177 | |
| 4178 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4179 | /* skip disabled subslice */ |
| 4180 | continue; |
| 4181 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4182 | sseu->slice_mask = BIT(0); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4183 | sseu->subslice_mask[0] |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4184 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4185 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4186 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4187 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4188 | sseu->eu_total += eu_cnt; |
| 4189 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4190 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4191 | } |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4192 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4193 | } |
| 4194 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4195 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4196 | struct sseu_dev_info *sseu) |
| 4197 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4198 | #define SS_MAX 6 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4199 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4200 | 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] | 4201 | int s, ss; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4202 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4203 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4204 | /* |
| 4205 | * FIXME: Valid SS Mask respects the spec and read |
Alexandre Belloni | 3c64ea8 | 2018-11-20 16:14:15 +0100 | [diff] [blame] | 4206 | * only valid bits for those registers, excluding reserved |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4207 | * although this seems wrong because it would leave many |
| 4208 | * subslices without ACK. |
| 4209 | */ |
| 4210 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4211 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4212 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4213 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4214 | } |
| 4215 | |
| 4216 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4217 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4218 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4219 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4220 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4221 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4222 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4223 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4224 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4225 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4226 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4227 | /* skip disabled slice */ |
| 4228 | continue; |
| 4229 | |
| 4230 | sseu->slice_mask |= BIT(s); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4231 | sseu->subslice_mask[s] = info->sseu.subslice_mask[s]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4232 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4233 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4234 | unsigned int eu_cnt; |
| 4235 | |
| 4236 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4237 | /* skip disabled subslice */ |
| 4238 | continue; |
| 4239 | |
| 4240 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4241 | eu_mask[ss % 2]); |
| 4242 | sseu->eu_total += eu_cnt; |
| 4243 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4244 | sseu->eu_per_subslice, |
| 4245 | eu_cnt); |
| 4246 | } |
| 4247 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4248 | #undef SS_MAX |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4249 | } |
| 4250 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4251 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4252 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4253 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4254 | #define SS_MAX 3 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4255 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4256 | 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] | 4257 | int s, ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4258 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4259 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4260 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4261 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4262 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4263 | } |
| 4264 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4265 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4266 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4267 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4268 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4269 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4270 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4271 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4272 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4273 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4274 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4275 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4276 | /* skip disabled slice */ |
| 4277 | continue; |
| 4278 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4279 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4280 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4281 | if (IS_GEN9_BC(dev_priv)) |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4282 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4283 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4284 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4285 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4286 | unsigned int eu_cnt; |
| 4287 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4288 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4289 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4290 | /* skip disabled subslice */ |
| 4291 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4292 | |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4293 | sseu->subslice_mask[s] |= BIT(ss); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4294 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4295 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4296 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4297 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4298 | sseu->eu_total += eu_cnt; |
| 4299 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4300 | sseu->eu_per_subslice, |
| 4301 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4302 | } |
| 4303 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4304 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4305 | } |
| 4306 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4307 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4308 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4309 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4310 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4311 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4312 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4313 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4314 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4315 | if (sseu->slice_mask) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4316 | sseu->eu_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4317 | RUNTIME_INFO(dev_priv)->sseu.eu_per_subslice; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4318 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4319 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4320 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4321 | } |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4322 | sseu->eu_total = sseu->eu_per_subslice * |
| 4323 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4324 | |
| 4325 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4326 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4327 | u8 subslice_7eu = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4328 | RUNTIME_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4329 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4330 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4331 | } |
| 4332 | } |
| 4333 | } |
| 4334 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4335 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4336 | const struct sseu_dev_info *sseu) |
| 4337 | { |
| 4338 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4339 | const char *type = is_available_info ? "Available" : "Enabled"; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4340 | int s; |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4341 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4342 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4343 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4344 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4345 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4346 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4347 | sseu_subslice_total(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4348 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4349 | seq_printf(m, " %s Slice%i subslices: %u\n", type, |
| 4350 | s, hweight8(sseu->subslice_mask[s])); |
| 4351 | } |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4352 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4353 | sseu->eu_total); |
| 4354 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4355 | sseu->eu_per_subslice); |
| 4356 | |
| 4357 | if (!is_available_info) |
| 4358 | return; |
| 4359 | |
| 4360 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4361 | if (HAS_POOLED_EU(dev_priv)) |
| 4362 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4363 | |
| 4364 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4365 | yesno(sseu->has_slice_pg)); |
| 4366 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4367 | yesno(sseu->has_subslice_pg)); |
| 4368 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4369 | yesno(sseu->has_eu_pg)); |
| 4370 | } |
| 4371 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4372 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4373 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4374 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4375 | struct sseu_dev_info sseu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4376 | intel_wakeref_t wakeref; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4377 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4378 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4379 | return -ENODEV; |
| 4380 | |
| 4381 | seq_puts(m, "SSEU Device Info\n"); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4382 | i915_print_sseu_info(m, true, &RUNTIME_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4383 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4384 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4385 | memset(&sseu, 0, sizeof(sseu)); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4386 | sseu.max_slices = RUNTIME_INFO(dev_priv)->sseu.max_slices; |
| 4387 | sseu.max_subslices = RUNTIME_INFO(dev_priv)->sseu.max_subslices; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4388 | sseu.max_eus_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4389 | RUNTIME_INFO(dev_priv)->sseu.max_eus_per_subslice; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4390 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4391 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4392 | if (IS_CHERRYVIEW(dev_priv)) |
| 4393 | cherryview_sseu_device_status(dev_priv, &sseu); |
| 4394 | else if (IS_BROADWELL(dev_priv)) |
| 4395 | broadwell_sseu_device_status(dev_priv, &sseu); |
| 4396 | else if (IS_GEN(dev_priv, 9)) |
| 4397 | gen9_sseu_device_status(dev_priv, &sseu); |
| 4398 | else if (INTEL_GEN(dev_priv) >= 10) |
| 4399 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4400 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4401 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4402 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4403 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4404 | return 0; |
| 4405 | } |
| 4406 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4407 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4408 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4409 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4410 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4411 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4412 | return 0; |
| 4413 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4414 | intel_runtime_pm_get(i915); |
| 4415 | intel_uncore_forcewake_user_get(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4416 | |
| 4417 | return 0; |
| 4418 | } |
| 4419 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4420 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4421 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4422 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4423 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4424 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4425 | return 0; |
| 4426 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4427 | intel_uncore_forcewake_user_put(i915); |
Chris Wilson | 16e4dd03 | 2019-01-14 14:21:10 +0000 | [diff] [blame] | 4428 | intel_runtime_pm_put_unchecked(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4429 | |
| 4430 | return 0; |
| 4431 | } |
| 4432 | |
| 4433 | static const struct file_operations i915_forcewake_fops = { |
| 4434 | .owner = THIS_MODULE, |
| 4435 | .open = i915_forcewake_open, |
| 4436 | .release = i915_forcewake_release, |
| 4437 | }; |
| 4438 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4439 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4440 | { |
| 4441 | struct drm_i915_private *dev_priv = m->private; |
| 4442 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4443 | |
Lyude Paul | 6fc5d78 | 2018-11-20 19:37:17 -0500 | [diff] [blame] | 4444 | /* Synchronize with everything first in case there's been an HPD |
| 4445 | * storm, but we haven't finished handling it in the kernel yet |
| 4446 | */ |
| 4447 | synchronize_irq(dev_priv->drm.irq); |
| 4448 | flush_work(&dev_priv->hotplug.dig_port_work); |
| 4449 | flush_work(&dev_priv->hotplug.hotplug_work); |
| 4450 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4451 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4452 | seq_printf(m, "Detected: %s\n", |
| 4453 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4454 | |
| 4455 | return 0; |
| 4456 | } |
| 4457 | |
| 4458 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4459 | const char __user *ubuf, size_t len, |
| 4460 | loff_t *offp) |
| 4461 | { |
| 4462 | struct seq_file *m = file->private_data; |
| 4463 | struct drm_i915_private *dev_priv = m->private; |
| 4464 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4465 | unsigned int new_threshold; |
| 4466 | int i; |
| 4467 | char *newline; |
| 4468 | char tmp[16]; |
| 4469 | |
| 4470 | if (len >= sizeof(tmp)) |
| 4471 | return -EINVAL; |
| 4472 | |
| 4473 | if (copy_from_user(tmp, ubuf, len)) |
| 4474 | return -EFAULT; |
| 4475 | |
| 4476 | tmp[len] = '\0'; |
| 4477 | |
| 4478 | /* Strip newline, if any */ |
| 4479 | newline = strchr(tmp, '\n'); |
| 4480 | if (newline) |
| 4481 | *newline = '\0'; |
| 4482 | |
| 4483 | if (strcmp(tmp, "reset") == 0) |
| 4484 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4485 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4486 | return -EINVAL; |
| 4487 | |
| 4488 | if (new_threshold > 0) |
| 4489 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4490 | new_threshold); |
| 4491 | else |
| 4492 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4493 | |
| 4494 | spin_lock_irq(&dev_priv->irq_lock); |
| 4495 | hotplug->hpd_storm_threshold = new_threshold; |
| 4496 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4497 | for_each_hpd_pin(i) |
| 4498 | hotplug->stats[i].count = 0; |
| 4499 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4500 | |
| 4501 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4502 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4503 | |
| 4504 | return len; |
| 4505 | } |
| 4506 | |
| 4507 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4508 | { |
| 4509 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4510 | } |
| 4511 | |
| 4512 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4513 | .owner = THIS_MODULE, |
| 4514 | .open = i915_hpd_storm_ctl_open, |
| 4515 | .read = seq_read, |
| 4516 | .llseek = seq_lseek, |
| 4517 | .release = single_release, |
| 4518 | .write = i915_hpd_storm_ctl_write |
| 4519 | }; |
| 4520 | |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4521 | static int i915_hpd_short_storm_ctl_show(struct seq_file *m, void *data) |
| 4522 | { |
| 4523 | struct drm_i915_private *dev_priv = m->private; |
| 4524 | |
| 4525 | seq_printf(m, "Enabled: %s\n", |
| 4526 | yesno(dev_priv->hotplug.hpd_short_storm_enabled)); |
| 4527 | |
| 4528 | return 0; |
| 4529 | } |
| 4530 | |
| 4531 | static int |
| 4532 | i915_hpd_short_storm_ctl_open(struct inode *inode, struct file *file) |
| 4533 | { |
| 4534 | return single_open(file, i915_hpd_short_storm_ctl_show, |
| 4535 | inode->i_private); |
| 4536 | } |
| 4537 | |
| 4538 | static ssize_t i915_hpd_short_storm_ctl_write(struct file *file, |
| 4539 | const char __user *ubuf, |
| 4540 | size_t len, loff_t *offp) |
| 4541 | { |
| 4542 | struct seq_file *m = file->private_data; |
| 4543 | struct drm_i915_private *dev_priv = m->private; |
| 4544 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4545 | char *newline; |
| 4546 | char tmp[16]; |
| 4547 | int i; |
| 4548 | bool new_state; |
| 4549 | |
| 4550 | if (len >= sizeof(tmp)) |
| 4551 | return -EINVAL; |
| 4552 | |
| 4553 | if (copy_from_user(tmp, ubuf, len)) |
| 4554 | return -EFAULT; |
| 4555 | |
| 4556 | tmp[len] = '\0'; |
| 4557 | |
| 4558 | /* Strip newline, if any */ |
| 4559 | newline = strchr(tmp, '\n'); |
| 4560 | if (newline) |
| 4561 | *newline = '\0'; |
| 4562 | |
| 4563 | /* Reset to the "default" state for this system */ |
| 4564 | if (strcmp(tmp, "reset") == 0) |
| 4565 | new_state = !HAS_DP_MST(dev_priv); |
| 4566 | else if (kstrtobool(tmp, &new_state) != 0) |
| 4567 | return -EINVAL; |
| 4568 | |
| 4569 | DRM_DEBUG_KMS("%sabling HPD short storm detection\n", |
| 4570 | new_state ? "En" : "Dis"); |
| 4571 | |
| 4572 | spin_lock_irq(&dev_priv->irq_lock); |
| 4573 | hotplug->hpd_short_storm_enabled = new_state; |
| 4574 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4575 | for_each_hpd_pin(i) |
| 4576 | hotplug->stats[i].count = 0; |
| 4577 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4578 | |
| 4579 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4580 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4581 | |
| 4582 | return len; |
| 4583 | } |
| 4584 | |
| 4585 | static const struct file_operations i915_hpd_short_storm_ctl_fops = { |
| 4586 | .owner = THIS_MODULE, |
| 4587 | .open = i915_hpd_short_storm_ctl_open, |
| 4588 | .read = seq_read, |
| 4589 | .llseek = seq_lseek, |
| 4590 | .release = single_release, |
| 4591 | .write = i915_hpd_short_storm_ctl_write, |
| 4592 | }; |
| 4593 | |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4594 | static int i915_drrs_ctl_set(void *data, u64 val) |
| 4595 | { |
| 4596 | struct drm_i915_private *dev_priv = data; |
| 4597 | struct drm_device *dev = &dev_priv->drm; |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4598 | struct intel_crtc *crtc; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4599 | |
| 4600 | if (INTEL_GEN(dev_priv) < 7) |
| 4601 | return -ENODEV; |
| 4602 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4603 | for_each_intel_crtc(dev, crtc) { |
| 4604 | struct drm_connector_list_iter conn_iter; |
| 4605 | struct intel_crtc_state *crtc_state; |
| 4606 | struct drm_connector *connector; |
| 4607 | struct drm_crtc_commit *commit; |
| 4608 | int ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4609 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4610 | ret = drm_modeset_lock_single_interruptible(&crtc->base.mutex); |
| 4611 | if (ret) |
| 4612 | return ret; |
| 4613 | |
| 4614 | crtc_state = to_intel_crtc_state(crtc->base.state); |
| 4615 | |
| 4616 | if (!crtc_state->base.active || |
| 4617 | !crtc_state->has_drrs) |
| 4618 | goto out; |
| 4619 | |
| 4620 | commit = crtc_state->base.commit; |
| 4621 | if (commit) { |
| 4622 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4623 | if (ret) |
| 4624 | goto out; |
| 4625 | } |
| 4626 | |
| 4627 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 4628 | drm_for_each_connector_iter(connector, &conn_iter) { |
| 4629 | struct intel_encoder *encoder; |
| 4630 | struct intel_dp *intel_dp; |
| 4631 | |
| 4632 | if (!(crtc_state->base.connector_mask & |
| 4633 | drm_connector_mask(connector))) |
| 4634 | continue; |
| 4635 | |
| 4636 | encoder = intel_attached_encoder(connector); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4637 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 4638 | continue; |
| 4639 | |
| 4640 | DRM_DEBUG_DRIVER("Manually %sabling DRRS. %llu\n", |
| 4641 | val ? "en" : "dis", val); |
| 4642 | |
| 4643 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 4644 | if (val) |
| 4645 | intel_edp_drrs_enable(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 | else |
| 4648 | intel_edp_drrs_disable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4649 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4650 | } |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4651 | drm_connector_list_iter_end(&conn_iter); |
| 4652 | |
| 4653 | out: |
| 4654 | drm_modeset_unlock(&crtc->base.mutex); |
| 4655 | if (ret) |
| 4656 | return ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4657 | } |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4658 | |
| 4659 | return 0; |
| 4660 | } |
| 4661 | |
| 4662 | DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); |
| 4663 | |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4664 | static ssize_t |
| 4665 | i915_fifo_underrun_reset_write(struct file *filp, |
| 4666 | const char __user *ubuf, |
| 4667 | size_t cnt, loff_t *ppos) |
| 4668 | { |
| 4669 | struct drm_i915_private *dev_priv = filp->private_data; |
| 4670 | struct intel_crtc *intel_crtc; |
| 4671 | struct drm_device *dev = &dev_priv->drm; |
| 4672 | int ret; |
| 4673 | bool reset; |
| 4674 | |
| 4675 | ret = kstrtobool_from_user(ubuf, cnt, &reset); |
| 4676 | if (ret) |
| 4677 | return ret; |
| 4678 | |
| 4679 | if (!reset) |
| 4680 | return cnt; |
| 4681 | |
| 4682 | for_each_intel_crtc(dev, intel_crtc) { |
| 4683 | struct drm_crtc_commit *commit; |
| 4684 | struct intel_crtc_state *crtc_state; |
| 4685 | |
| 4686 | ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); |
| 4687 | if (ret) |
| 4688 | return ret; |
| 4689 | |
| 4690 | crtc_state = to_intel_crtc_state(intel_crtc->base.state); |
| 4691 | commit = crtc_state->base.commit; |
| 4692 | if (commit) { |
| 4693 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4694 | if (!ret) |
| 4695 | ret = wait_for_completion_interruptible(&commit->flip_done); |
| 4696 | } |
| 4697 | |
| 4698 | if (!ret && crtc_state->base.active) { |
| 4699 | DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", |
| 4700 | pipe_name(intel_crtc->pipe)); |
| 4701 | |
| 4702 | intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); |
| 4703 | } |
| 4704 | |
| 4705 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 4706 | |
| 4707 | if (ret) |
| 4708 | return ret; |
| 4709 | } |
| 4710 | |
| 4711 | ret = intel_fbc_reset_underrun(dev_priv); |
| 4712 | if (ret) |
| 4713 | return ret; |
| 4714 | |
| 4715 | return cnt; |
| 4716 | } |
| 4717 | |
| 4718 | static const struct file_operations i915_fifo_underrun_reset_ops = { |
| 4719 | .owner = THIS_MODULE, |
| 4720 | .open = simple_open, |
| 4721 | .write = i915_fifo_underrun_reset_write, |
| 4722 | .llseek = default_llseek, |
| 4723 | }; |
| 4724 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4725 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4726 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4727 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4728 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4729 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4730 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4731 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4732 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4733 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4734 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4735 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4736 | {"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] | 4737 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4738 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4739 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4740 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4741 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4742 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4743 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4744 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4745 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4746 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4747 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4748 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4749 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4750 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4751 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4752 | {"i915_context_status", i915_context_status, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4753 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4754 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4755 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4756 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4757 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4758 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4759 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4760 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4761 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4762 | {"i915_engine_info", i915_engine_info, 0}, |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 4763 | {"i915_rcs_topology", i915_rcs_topology, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4764 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4765 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4766 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4767 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4768 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4769 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4770 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4771 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4772 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4773 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4774 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4775 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4776 | const char *name; |
| 4777 | const struct file_operations *fops; |
| 4778 | } i915_debugfs_files[] = { |
| 4779 | {"i915_wedged", &i915_wedged_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4780 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4781 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4782 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4783 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4784 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4785 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4786 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4787 | #endif |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4788 | {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4789 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4790 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4791 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4792 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4793 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4794 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4795 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 4796 | {"i915_guc_log_level", &i915_guc_log_level_fops}, |
| 4797 | {"i915_guc_log_relay", &i915_guc_log_relay_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4798 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4799 | {"i915_hpd_short_storm_ctl", &i915_hpd_short_storm_ctl_fops}, |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4800 | {"i915_ipc_status", &i915_ipc_status_fops}, |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4801 | {"i915_drrs_ctl", &i915_drrs_ctl_fops}, |
| 4802 | {"i915_edp_psr_debug", &i915_edp_psr_debug_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4803 | }; |
| 4804 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4805 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4806 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4807 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4808 | struct dentry *ent; |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 4809 | int i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4810 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4811 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4812 | minor->debugfs_root, to_i915(minor->dev), |
| 4813 | &i915_forcewake_fops); |
| 4814 | if (!ent) |
| 4815 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4816 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4817 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4818 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4819 | S_IRUGO | S_IWUSR, |
| 4820 | minor->debugfs_root, |
| 4821 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4822 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4823 | if (!ent) |
| 4824 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4825 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4826 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4827 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4828 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4829 | minor->debugfs_root, minor); |
| 4830 | } |
| 4831 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4832 | struct dpcd_block { |
| 4833 | /* DPCD dump start address. */ |
| 4834 | unsigned int offset; |
| 4835 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4836 | unsigned int end; |
| 4837 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4838 | size_t size; |
| 4839 | /* Only valid for eDP. */ |
| 4840 | bool edp; |
| 4841 | }; |
| 4842 | |
| 4843 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4844 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4845 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4846 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4847 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4848 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4849 | { .offset = DP_SET_POWER }, |
| 4850 | { .offset = DP_EDP_DPCD_REV }, |
| 4851 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4852 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4853 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4854 | }; |
| 4855 | |
| 4856 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4857 | { |
| 4858 | struct drm_connector *connector = m->private; |
| 4859 | struct intel_dp *intel_dp = |
| 4860 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4861 | uint8_t buf[16]; |
| 4862 | ssize_t err; |
| 4863 | int i; |
| 4864 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4865 | if (connector->status != connector_status_connected) |
| 4866 | return -ENODEV; |
| 4867 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4868 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4869 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4870 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4871 | |
| 4872 | if (b->edp && |
| 4873 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4874 | continue; |
| 4875 | |
| 4876 | /* low tech for now */ |
| 4877 | if (WARN_ON(size > sizeof(buf))) |
| 4878 | continue; |
| 4879 | |
| 4880 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
Chris Wilson | 65404c8 | 2018-10-10 09:17:06 +0100 | [diff] [blame] | 4881 | if (err < 0) |
| 4882 | seq_printf(m, "%04x: ERROR %d\n", b->offset, (int)err); |
| 4883 | else |
| 4884 | seq_printf(m, "%04x: %*ph\n", b->offset, (int)err, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4885 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4886 | |
| 4887 | return 0; |
| 4888 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4889 | DEFINE_SHOW_ATTRIBUTE(i915_dpcd); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4890 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4891 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4892 | { |
| 4893 | struct drm_connector *connector = m->private; |
| 4894 | struct intel_dp *intel_dp = |
| 4895 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4896 | |
| 4897 | if (connector->status != connector_status_connected) |
| 4898 | return -ENODEV; |
| 4899 | |
| 4900 | seq_printf(m, "Panel power up delay: %d\n", |
| 4901 | intel_dp->panel_power_up_delay); |
| 4902 | seq_printf(m, "Panel power down delay: %d\n", |
| 4903 | intel_dp->panel_power_down_delay); |
| 4904 | seq_printf(m, "Backlight on delay: %d\n", |
| 4905 | intel_dp->backlight_on_delay); |
| 4906 | seq_printf(m, "Backlight off delay: %d\n", |
| 4907 | intel_dp->backlight_off_delay); |
| 4908 | |
| 4909 | return 0; |
| 4910 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4911 | DEFINE_SHOW_ATTRIBUTE(i915_panel); |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4912 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4913 | static int i915_hdcp_sink_capability_show(struct seq_file *m, void *data) |
| 4914 | { |
| 4915 | struct drm_connector *connector = m->private; |
| 4916 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 4917 | |
| 4918 | if (connector->status != connector_status_connected) |
| 4919 | return -ENODEV; |
| 4920 | |
| 4921 | /* HDCP is supported by connector */ |
Ramalingam C | d3dacc7 | 2018-10-29 15:15:46 +0530 | [diff] [blame] | 4922 | if (!intel_connector->hdcp.shim) |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4923 | return -EINVAL; |
| 4924 | |
| 4925 | seq_printf(m, "%s:%d HDCP version: ", connector->name, |
| 4926 | connector->base.id); |
| 4927 | seq_printf(m, "%s ", !intel_hdcp_capable(intel_connector) ? |
| 4928 | "None" : "HDCP1.4"); |
| 4929 | seq_puts(m, "\n"); |
| 4930 | |
| 4931 | return 0; |
| 4932 | } |
| 4933 | DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability); |
| 4934 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4935 | static int i915_dsc_fec_support_show(struct seq_file *m, void *data) |
| 4936 | { |
| 4937 | struct drm_connector *connector = m->private; |
| 4938 | struct drm_device *dev = connector->dev; |
| 4939 | struct drm_crtc *crtc; |
| 4940 | struct intel_dp *intel_dp; |
| 4941 | struct drm_modeset_acquire_ctx ctx; |
| 4942 | struct intel_crtc_state *crtc_state = NULL; |
| 4943 | int ret = 0; |
| 4944 | bool try_again = false; |
| 4945 | |
| 4946 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 4947 | |
| 4948 | do { |
Manasi Navare | 6afe892 | 2018-12-19 15:51:20 -0800 | [diff] [blame] | 4949 | try_again = false; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4950 | ret = drm_modeset_lock(&dev->mode_config.connection_mutex, |
| 4951 | &ctx); |
| 4952 | if (ret) { |
| 4953 | ret = -EINTR; |
| 4954 | break; |
| 4955 | } |
| 4956 | crtc = connector->state->crtc; |
| 4957 | if (connector->status != connector_status_connected || !crtc) { |
| 4958 | ret = -ENODEV; |
| 4959 | break; |
| 4960 | } |
| 4961 | ret = drm_modeset_lock(&crtc->mutex, &ctx); |
| 4962 | if (ret == -EDEADLK) { |
| 4963 | ret = drm_modeset_backoff(&ctx); |
| 4964 | if (!ret) { |
| 4965 | try_again = true; |
| 4966 | continue; |
| 4967 | } |
| 4968 | break; |
| 4969 | } else if (ret) { |
| 4970 | break; |
| 4971 | } |
| 4972 | intel_dp = enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4973 | crtc_state = to_intel_crtc_state(crtc->state); |
| 4974 | seq_printf(m, "DSC_Enabled: %s\n", |
| 4975 | yesno(crtc_state->dsc_params.compression_enable)); |
| 4976 | if (intel_dp->dsc_dpcd) |
| 4977 | seq_printf(m, "DSC_Sink_Support: %s\n", |
| 4978 | yesno(drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd))); |
| 4979 | if (!intel_dp_is_edp(intel_dp)) |
| 4980 | seq_printf(m, "FEC_Sink_Support: %s\n", |
| 4981 | yesno(drm_dp_sink_supports_fec(intel_dp->fec_capable))); |
| 4982 | } while (try_again); |
| 4983 | |
| 4984 | drm_modeset_drop_locks(&ctx); |
| 4985 | drm_modeset_acquire_fini(&ctx); |
| 4986 | |
| 4987 | return ret; |
| 4988 | } |
| 4989 | |
| 4990 | static ssize_t i915_dsc_fec_support_write(struct file *file, |
| 4991 | const char __user *ubuf, |
| 4992 | size_t len, loff_t *offp) |
| 4993 | { |
| 4994 | bool dsc_enable = false; |
| 4995 | int ret; |
| 4996 | struct drm_connector *connector = |
| 4997 | ((struct seq_file *)file->private_data)->private; |
| 4998 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
| 4999 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 5000 | |
| 5001 | if (len == 0) |
| 5002 | return 0; |
| 5003 | |
| 5004 | DRM_DEBUG_DRIVER("Copied %zu bytes from user to force DSC\n", |
| 5005 | len); |
| 5006 | |
| 5007 | ret = kstrtobool_from_user(ubuf, len, &dsc_enable); |
| 5008 | if (ret < 0) |
| 5009 | return ret; |
| 5010 | |
| 5011 | DRM_DEBUG_DRIVER("Got %s for DSC Enable\n", |
| 5012 | (dsc_enable) ? "true" : "false"); |
| 5013 | intel_dp->force_dsc_en = dsc_enable; |
| 5014 | |
| 5015 | *offp += len; |
| 5016 | return len; |
| 5017 | } |
| 5018 | |
| 5019 | static int i915_dsc_fec_support_open(struct inode *inode, |
| 5020 | struct file *file) |
| 5021 | { |
| 5022 | return single_open(file, i915_dsc_fec_support_show, |
| 5023 | inode->i_private); |
| 5024 | } |
| 5025 | |
| 5026 | static const struct file_operations i915_dsc_fec_support_fops = { |
| 5027 | .owner = THIS_MODULE, |
| 5028 | .open = i915_dsc_fec_support_open, |
| 5029 | .read = seq_read, |
| 5030 | .llseek = seq_lseek, |
| 5031 | .release = single_release, |
| 5032 | .write = i915_dsc_fec_support_write |
| 5033 | }; |
| 5034 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5035 | /** |
| 5036 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5037 | * @connector: pointer to a registered drm_connector |
| 5038 | * |
| 5039 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5040 | * drm_debugfs_connector_remove(). |
| 5041 | * |
| 5042 | * Returns 0 on success, negative error codes on error. |
| 5043 | */ |
| 5044 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5045 | { |
| 5046 | struct dentry *root = connector->debugfs_entry; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 5047 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5048 | |
| 5049 | /* The connector must have been registered beforehands. */ |
| 5050 | if (!root) |
| 5051 | return -ENODEV; |
| 5052 | |
| 5053 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5054 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5055 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5056 | connector, &i915_dpcd_fops); |
| 5057 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 5058 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5059 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5060 | connector, &i915_panel_fops); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 5061 | debugfs_create_file("i915_psr_sink_status", S_IRUGO, root, |
| 5062 | connector, &i915_psr_sink_status_fops); |
| 5063 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5064 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 5065 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5066 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || |
| 5067 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { |
| 5068 | debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, |
| 5069 | connector, &i915_hdcp_sink_capability_fops); |
| 5070 | } |
| 5071 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 5072 | if (INTEL_GEN(dev_priv) >= 10 && |
| 5073 | (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5074 | connector->connector_type == DRM_MODE_CONNECTOR_eDP)) |
| 5075 | debugfs_create_file("i915_dsc_fec_support", S_IRUGO, root, |
| 5076 | connector, &i915_dsc_fec_support_fops); |
| 5077 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5078 | return 0; |
| 5079 | } |