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); |
Michal Wajdeczko | 5fbbe8d | 2017-12-21 21:57:34 +0000 | [diff] [blame] | 51 | intel_device_info_dump_runtime(info, &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 | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 300 | struct drm_i915_file_private *file_priv; |
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 | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 305 | }; |
| 306 | |
| 307 | static int per_file_stats(int id, void *ptr, void *data) |
| 308 | { |
| 309 | struct drm_i915_gem_object *obj = ptr; |
| 310 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 311 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 312 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 313 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 314 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 315 | stats->count++; |
| 316 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 317 | if (!obj->bind_count) |
| 318 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 319 | if (obj->base.name || obj->base.dma_buf) |
| 320 | stats->shared += obj->base.size; |
| 321 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 322 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 323 | if (!drm_mm_node_allocated(&vma->node)) |
| 324 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 325 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 326 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 327 | stats->global += vma->node.size; |
| 328 | } else { |
| 329 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 330 | |
Chris Wilson | 82ad644 | 2018-06-05 16:37:58 +0100 | [diff] [blame] | 331 | if (ppgtt->vm.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 332 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 333 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 334 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 335 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 336 | stats->active += vma->node.size; |
| 337 | else |
| 338 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 344 | #define print_file_stats(m, name, stats) do { \ |
| 345 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 346 | seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 347 | name, \ |
| 348 | stats.count, \ |
| 349 | stats.total, \ |
| 350 | stats.active, \ |
| 351 | stats.inactive, \ |
| 352 | stats.global, \ |
| 353 | stats.shared, \ |
| 354 | stats.unbound); \ |
| 355 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 356 | |
| 357 | static void print_batch_pool_stats(struct seq_file *m, |
| 358 | struct drm_i915_private *dev_priv) |
| 359 | { |
| 360 | struct drm_i915_gem_object *obj; |
| 361 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 362 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 363 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 364 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 365 | |
| 366 | memset(&stats, 0, sizeof(stats)); |
| 367 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 368 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 369 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 370 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 371 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 372 | batch_pool_link) |
| 373 | per_file_stats(0, obj, &stats); |
| 374 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 375 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 376 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 377 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 378 | } |
| 379 | |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 380 | static int per_file_ctx_stats(int idx, void *ptr, void *data) |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 381 | { |
| 382 | struct i915_gem_context *ctx = ptr; |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 383 | struct intel_engine_cs *engine; |
| 384 | enum intel_engine_id id; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 385 | |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 386 | for_each_engine(engine, ctx->i915, id) { |
| 387 | struct intel_context *ce = to_intel_context(ctx, engine); |
| 388 | |
| 389 | if (ce->state) |
| 390 | per_file_stats(0, ce->state->obj, data); |
| 391 | if (ce->ring) |
| 392 | per_file_stats(0, ce->ring->vma->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | static void print_context_stats(struct seq_file *m, |
| 399 | struct drm_i915_private *dev_priv) |
| 400 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 401 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 402 | struct file_stats stats; |
| 403 | struct drm_file *file; |
| 404 | |
| 405 | memset(&stats, 0, sizeof(stats)); |
| 406 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 407 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 408 | if (dev_priv->kernel_context) |
| 409 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 410 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 411 | list_for_each_entry(file, &dev->filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 412 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 413 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 414 | } |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 415 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 416 | |
| 417 | print_file_stats(m, "[k]contexts", stats); |
| 418 | } |
| 419 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 420 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 421 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 422 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 423 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 424 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 425 | u32 count, mapped_count, purgeable_count, dpy_count, huge_count; |
| 426 | u64 size, mapped_size, purgeable_size, dpy_size, huge_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 427 | struct drm_i915_gem_object *obj; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 428 | unsigned int page_sizes = 0; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 429 | struct drm_file *file; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 430 | char buf[80]; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 431 | int ret; |
| 432 | |
| 433 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 434 | if (ret) |
| 435 | return ret; |
| 436 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 437 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 438 | dev_priv->mm.object_count, |
| 439 | dev_priv->mm.object_memory); |
| 440 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 441 | size = count = 0; |
| 442 | mapped_size = mapped_count = 0; |
| 443 | purgeable_size = purgeable_count = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 444 | huge_size = huge_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 445 | |
| 446 | spin_lock(&dev_priv->mm.obj_lock); |
| 447 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 448 | size += obj->base.size; |
| 449 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 450 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 451 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 452 | purgeable_size += obj->base.size; |
| 453 | ++purgeable_count; |
| 454 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 455 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 456 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 457 | mapped_count++; |
| 458 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 459 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 460 | |
| 461 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 462 | huge_count++; |
| 463 | huge_size += obj->base.size; |
| 464 | page_sizes |= obj->mm.page_sizes.sg; |
| 465 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 466 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 467 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 468 | |
| 469 | size = count = dpy_size = dpy_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 470 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 471 | size += obj->base.size; |
| 472 | ++count; |
| 473 | |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 474 | if (obj->pin_global) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 475 | dpy_size += obj->base.size; |
| 476 | ++dpy_count; |
| 477 | } |
| 478 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 479 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 480 | purgeable_size += obj->base.size; |
| 481 | ++purgeable_count; |
| 482 | } |
| 483 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 484 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 485 | mapped_count++; |
| 486 | mapped_size += obj->base.size; |
| 487 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 488 | |
| 489 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 490 | huge_count++; |
| 491 | huge_size += obj->base.size; |
| 492 | page_sizes |= obj->mm.page_sizes.sg; |
| 493 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 494 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 495 | spin_unlock(&dev_priv->mm.obj_lock); |
| 496 | |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 497 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 498 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 499 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 500 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 501 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 502 | mapped_count, mapped_size); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 503 | seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n", |
| 504 | huge_count, |
| 505 | stringify_page_sizes(page_sizes, buf, sizeof(buf)), |
| 506 | huge_size); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 507 | seq_printf(m, "%u display objects (globally pinned), %llu bytes\n", |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 508 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 509 | |
Matthew Auld | b7128ef | 2017-12-11 15:18:22 +0000 | [diff] [blame] | 510 | seq_printf(m, "%llu [%pa] gtt total\n", |
Chris Wilson | 82ad644 | 2018-06-05 16:37:58 +0100 | [diff] [blame] | 511 | ggtt->vm.total, &ggtt->mappable_end); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 512 | seq_printf(m, "Supported page sizes: %s\n", |
| 513 | stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes, |
| 514 | buf, sizeof(buf))); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 515 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 516 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 517 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 518 | mutex_unlock(&dev->struct_mutex); |
| 519 | |
| 520 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 521 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 522 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 523 | struct file_stats stats; |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 524 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Chris Wilson | e61e0f5 | 2018-02-21 09:56:36 +0000 | [diff] [blame] | 525 | struct i915_request *request; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 526 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 527 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 528 | mutex_lock(&dev->struct_mutex); |
| 529 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 530 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 531 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 532 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 533 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 534 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 535 | /* |
| 536 | * Although we have a valid reference on file->pid, that does |
| 537 | * not guarantee that the task_struct who called get_pid() is |
| 538 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 539 | * Therefore, we need to protect this ->comm access using RCU. |
| 540 | */ |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 541 | request = list_first_entry_or_null(&file_priv->mm.request_list, |
Chris Wilson | e61e0f5 | 2018-02-21 09:56:36 +0000 | [diff] [blame] | 542 | struct i915_request, |
Chris Wilson | c8659ef | 2017-03-02 12:25:25 +0000 | [diff] [blame] | 543 | client_link); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 544 | rcu_read_lock(); |
Chris Wilson | 4e0d64d | 2018-05-17 22:26:30 +0100 | [diff] [blame] | 545 | task = pid_task(request && request->gem_context->pid ? |
| 546 | request->gem_context->pid : file->pid, |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 547 | PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 548 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 549 | rcu_read_unlock(); |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 550 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 551 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 552 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 553 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 554 | |
| 555 | return 0; |
| 556 | } |
| 557 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 558 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 559 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 560 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 561 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 562 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 563 | struct drm_i915_gem_object **objects; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 564 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 565 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 566 | unsigned long nobject, n; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 567 | int count, ret; |
| 568 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 569 | nobject = READ_ONCE(dev_priv->mm.object_count); |
| 570 | objects = kvmalloc_array(nobject, sizeof(*objects), GFP_KERNEL); |
| 571 | if (!objects) |
| 572 | return -ENOMEM; |
| 573 | |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 574 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 575 | if (ret) |
| 576 | return ret; |
| 577 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 578 | count = 0; |
| 579 | spin_lock(&dev_priv->mm.obj_lock); |
| 580 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
| 581 | objects[count++] = obj; |
| 582 | if (count == nobject) |
| 583 | break; |
| 584 | } |
| 585 | spin_unlock(&dev_priv->mm.obj_lock); |
| 586 | |
| 587 | total_obj_size = total_gtt_size = 0; |
| 588 | for (n = 0; n < count; n++) { |
| 589 | obj = objects[n]; |
| 590 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 591 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 592 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 593 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 594 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 595 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | mutex_unlock(&dev->struct_mutex); |
| 599 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 600 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 601 | count, total_obj_size, total_gtt_size); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 602 | kvfree(objects); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 603 | |
| 604 | return 0; |
| 605 | } |
| 606 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 607 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 608 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 609 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 610 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 611 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 612 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 613 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 614 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 615 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 616 | |
| 617 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 618 | if (ret) |
| 619 | return ret; |
| 620 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 621 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 622 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 623 | int count; |
| 624 | |
| 625 | count = 0; |
| 626 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 627 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 628 | batch_pool_link) |
| 629 | count++; |
| 630 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 631 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 632 | |
| 633 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 634 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 635 | batch_pool_link) { |
| 636 | seq_puts(m, " "); |
| 637 | describe_obj(m, obj); |
| 638 | seq_putc(m, '\n'); |
| 639 | } |
| 640 | |
| 641 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 642 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 643 | } |
| 644 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 645 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 646 | |
| 647 | mutex_unlock(&dev->struct_mutex); |
| 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 652 | static void gen8_display_interrupt_info(struct seq_file *m) |
| 653 | { |
| 654 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 655 | int pipe; |
| 656 | |
| 657 | for_each_pipe(dev_priv, pipe) { |
| 658 | enum intel_display_power_domain power_domain; |
| 659 | |
| 660 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 661 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 662 | power_domain)) { |
| 663 | seq_printf(m, "Pipe %c power disabled\n", |
| 664 | pipe_name(pipe)); |
| 665 | continue; |
| 666 | } |
| 667 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
| 668 | pipe_name(pipe), |
| 669 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
| 670 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
| 671 | pipe_name(pipe), |
| 672 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
| 673 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
| 674 | pipe_name(pipe), |
| 675 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
| 676 | |
| 677 | intel_display_power_put(dev_priv, power_domain); |
| 678 | } |
| 679 | |
| 680 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 681 | I915_READ(GEN8_DE_PORT_IMR)); |
| 682 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 683 | I915_READ(GEN8_DE_PORT_IIR)); |
| 684 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 685 | I915_READ(GEN8_DE_PORT_IER)); |
| 686 | |
| 687 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 688 | I915_READ(GEN8_DE_MISC_IMR)); |
| 689 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 690 | I915_READ(GEN8_DE_MISC_IIR)); |
| 691 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 692 | I915_READ(GEN8_DE_MISC_IER)); |
| 693 | |
| 694 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 695 | I915_READ(GEN8_PCU_IMR)); |
| 696 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 697 | I915_READ(GEN8_PCU_IIR)); |
| 698 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 699 | I915_READ(GEN8_PCU_IER)); |
| 700 | } |
| 701 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 702 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 703 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 704 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 705 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 706 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 707 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 708 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 709 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 710 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 711 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 712 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 713 | I915_READ(GEN8_MASTER_IRQ)); |
| 714 | |
| 715 | seq_printf(m, "Display IER:\t%08x\n", |
| 716 | I915_READ(VLV_IER)); |
| 717 | seq_printf(m, "Display IIR:\t%08x\n", |
| 718 | I915_READ(VLV_IIR)); |
| 719 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 720 | I915_READ(VLV_IIR_RW)); |
| 721 | seq_printf(m, "Display IMR:\t%08x\n", |
| 722 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 723 | for_each_pipe(dev_priv, pipe) { |
| 724 | enum intel_display_power_domain power_domain; |
| 725 | |
| 726 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 727 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 728 | power_domain)) { |
| 729 | seq_printf(m, "Pipe %c power disabled\n", |
| 730 | pipe_name(pipe)); |
| 731 | continue; |
| 732 | } |
| 733 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 734 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 735 | pipe_name(pipe), |
| 736 | I915_READ(PIPESTAT(pipe))); |
| 737 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 738 | intel_display_power_put(dev_priv, power_domain); |
| 739 | } |
| 740 | |
| 741 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 742 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 743 | I915_READ(PORT_HOTPLUG_EN)); |
| 744 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 745 | I915_READ(VLV_DPFLIPSTAT)); |
| 746 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 747 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 748 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 749 | |
| 750 | for (i = 0; i < 4; i++) { |
| 751 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 752 | i, I915_READ(GEN8_GT_IMR(i))); |
| 753 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 754 | i, I915_READ(GEN8_GT_IIR(i))); |
| 755 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 756 | i, I915_READ(GEN8_GT_IER(i))); |
| 757 | } |
| 758 | |
| 759 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 760 | I915_READ(GEN8_PCU_IMR)); |
| 761 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 762 | I915_READ(GEN8_PCU_IIR)); |
| 763 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 764 | I915_READ(GEN8_PCU_IER)); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 765 | } else if (INTEL_GEN(dev_priv) >= 11) { |
| 766 | seq_printf(m, "Master Interrupt Control: %08x\n", |
| 767 | I915_READ(GEN11_GFX_MSTR_IRQ)); |
| 768 | |
| 769 | seq_printf(m, "Render/Copy Intr Enable: %08x\n", |
| 770 | I915_READ(GEN11_RENDER_COPY_INTR_ENABLE)); |
| 771 | seq_printf(m, "VCS/VECS Intr Enable: %08x\n", |
| 772 | I915_READ(GEN11_VCS_VECS_INTR_ENABLE)); |
| 773 | seq_printf(m, "GUC/SG Intr Enable:\t %08x\n", |
| 774 | I915_READ(GEN11_GUC_SG_INTR_ENABLE)); |
| 775 | seq_printf(m, "GPM/WGBOXPERF Intr Enable: %08x\n", |
| 776 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE)); |
| 777 | seq_printf(m, "Crypto Intr Enable:\t %08x\n", |
| 778 | I915_READ(GEN11_CRYPTO_RSVD_INTR_ENABLE)); |
| 779 | seq_printf(m, "GUnit/CSME Intr Enable:\t %08x\n", |
| 780 | I915_READ(GEN11_GUNIT_CSME_INTR_ENABLE)); |
| 781 | |
| 782 | seq_printf(m, "Display Interrupt Control:\t%08x\n", |
| 783 | I915_READ(GEN11_DISPLAY_INT_CTL)); |
| 784 | |
| 785 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 786 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 787 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 788 | I915_READ(GEN8_MASTER_IRQ)); |
| 789 | |
| 790 | for (i = 0; i < 4; i++) { |
| 791 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 792 | i, I915_READ(GEN8_GT_IMR(i))); |
| 793 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 794 | i, I915_READ(GEN8_GT_IIR(i))); |
| 795 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 796 | i, I915_READ(GEN8_GT_IER(i))); |
| 797 | } |
| 798 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 799 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 800 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 801 | seq_printf(m, "Display IER:\t%08x\n", |
| 802 | I915_READ(VLV_IER)); |
| 803 | seq_printf(m, "Display IIR:\t%08x\n", |
| 804 | I915_READ(VLV_IIR)); |
| 805 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 806 | I915_READ(VLV_IIR_RW)); |
| 807 | seq_printf(m, "Display IMR:\t%08x\n", |
| 808 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 809 | for_each_pipe(dev_priv, pipe) { |
| 810 | enum intel_display_power_domain power_domain; |
| 811 | |
| 812 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 813 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 814 | power_domain)) { |
| 815 | seq_printf(m, "Pipe %c power disabled\n", |
| 816 | pipe_name(pipe)); |
| 817 | continue; |
| 818 | } |
| 819 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 820 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 821 | pipe_name(pipe), |
| 822 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 823 | intel_display_power_put(dev_priv, power_domain); |
| 824 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 825 | |
| 826 | seq_printf(m, "Master IER:\t%08x\n", |
| 827 | I915_READ(VLV_MASTER_IER)); |
| 828 | |
| 829 | seq_printf(m, "Render IER:\t%08x\n", |
| 830 | I915_READ(GTIER)); |
| 831 | seq_printf(m, "Render IIR:\t%08x\n", |
| 832 | I915_READ(GTIIR)); |
| 833 | seq_printf(m, "Render IMR:\t%08x\n", |
| 834 | I915_READ(GTIMR)); |
| 835 | |
| 836 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 837 | I915_READ(GEN6_PMIER)); |
| 838 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 839 | I915_READ(GEN6_PMIIR)); |
| 840 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 841 | I915_READ(GEN6_PMIMR)); |
| 842 | |
| 843 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 844 | I915_READ(PORT_HOTPLUG_EN)); |
| 845 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 846 | I915_READ(VLV_DPFLIPSTAT)); |
| 847 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 848 | I915_READ(DPINVGTT)); |
| 849 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 850 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 851 | seq_printf(m, "Interrupt enable: %08x\n", |
| 852 | I915_READ(IER)); |
| 853 | seq_printf(m, "Interrupt identity: %08x\n", |
| 854 | I915_READ(IIR)); |
| 855 | seq_printf(m, "Interrupt mask: %08x\n", |
| 856 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 857 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 858 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 859 | pipe_name(pipe), |
| 860 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 861 | } else { |
| 862 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 863 | I915_READ(DEIER)); |
| 864 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 865 | I915_READ(DEIIR)); |
| 866 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 867 | I915_READ(DEIMR)); |
| 868 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 869 | I915_READ(SDEIER)); |
| 870 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 871 | I915_READ(SDEIIR)); |
| 872 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 873 | I915_READ(SDEIMR)); |
| 874 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 875 | I915_READ(GTIER)); |
| 876 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 877 | I915_READ(GTIIR)); |
| 878 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 879 | I915_READ(GTIMR)); |
| 880 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 881 | |
| 882 | if (INTEL_GEN(dev_priv) >= 11) { |
| 883 | seq_printf(m, "RCS Intr Mask:\t %08x\n", |
| 884 | I915_READ(GEN11_RCS0_RSVD_INTR_MASK)); |
| 885 | seq_printf(m, "BCS Intr Mask:\t %08x\n", |
| 886 | I915_READ(GEN11_BCS_RSVD_INTR_MASK)); |
| 887 | seq_printf(m, "VCS0/VCS1 Intr Mask:\t %08x\n", |
| 888 | I915_READ(GEN11_VCS0_VCS1_INTR_MASK)); |
| 889 | seq_printf(m, "VCS2/VCS3 Intr Mask:\t %08x\n", |
| 890 | I915_READ(GEN11_VCS2_VCS3_INTR_MASK)); |
| 891 | seq_printf(m, "VECS0/VECS1 Intr Mask:\t %08x\n", |
| 892 | I915_READ(GEN11_VECS0_VECS1_INTR_MASK)); |
| 893 | seq_printf(m, "GUC/SG Intr Mask:\t %08x\n", |
| 894 | I915_READ(GEN11_GUC_SG_INTR_MASK)); |
| 895 | seq_printf(m, "GPM/WGBOXPERF Intr Mask: %08x\n", |
| 896 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK)); |
| 897 | seq_printf(m, "Crypto Intr Mask:\t %08x\n", |
| 898 | I915_READ(GEN11_CRYPTO_RSVD_INTR_MASK)); |
| 899 | seq_printf(m, "Gunit/CSME Intr Mask:\t %08x\n", |
| 900 | I915_READ(GEN11_GUNIT_CSME_INTR_MASK)); |
| 901 | |
| 902 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | d5acadf | 2017-12-09 10:44:18 +0000 | [diff] [blame] | 903 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 904 | seq_printf(m, |
| 905 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 906 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 907 | } |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 908 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 909 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 910 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 911 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 912 | return 0; |
| 913 | } |
| 914 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 915 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 916 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 917 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 918 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 919 | int i, ret; |
| 920 | |
| 921 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 922 | if (ret) |
| 923 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 924 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 925 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 926 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 927 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 928 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 929 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 930 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 931 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 932 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 933 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 934 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 935 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 936 | } |
| 937 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 938 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 939 | return 0; |
| 940 | } |
| 941 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 942 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 943 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 944 | size_t count, loff_t *pos) |
| 945 | { |
| 946 | struct i915_gpu_state *error = file->private_data; |
| 947 | struct drm_i915_error_state_buf str; |
| 948 | ssize_t ret; |
| 949 | loff_t tmp; |
| 950 | |
| 951 | if (!error) |
| 952 | return 0; |
| 953 | |
| 954 | ret = i915_error_state_buf_init(&str, error->i915, count, *pos); |
| 955 | if (ret) |
| 956 | return ret; |
| 957 | |
| 958 | ret = i915_error_state_to_str(&str, error); |
| 959 | if (ret) |
| 960 | goto out; |
| 961 | |
| 962 | tmp = 0; |
| 963 | ret = simple_read_from_buffer(ubuf, count, &tmp, str.buf, str.bytes); |
| 964 | if (ret < 0) |
| 965 | goto out; |
| 966 | |
| 967 | *pos = str.start + ret; |
| 968 | out: |
| 969 | i915_error_state_buf_release(&str); |
| 970 | return ret; |
| 971 | } |
| 972 | |
| 973 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 974 | { |
| 975 | i915_gpu_state_put(file->private_data); |
| 976 | return 0; |
| 977 | } |
| 978 | |
| 979 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 980 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 981 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 982 | struct i915_gpu_state *gpu; |
| 983 | |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 984 | intel_runtime_pm_get(i915); |
| 985 | gpu = i915_capture_gpu_state(i915); |
| 986 | intel_runtime_pm_put(i915); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 987 | if (!gpu) |
| 988 | return -ENOMEM; |
| 989 | |
| 990 | file->private_data = gpu; |
| 991 | return 0; |
| 992 | } |
| 993 | |
| 994 | static const struct file_operations i915_gpu_info_fops = { |
| 995 | .owner = THIS_MODULE, |
| 996 | .open = i915_gpu_info_open, |
| 997 | .read = gpu_state_read, |
| 998 | .llseek = default_llseek, |
| 999 | .release = gpu_state_release, |
| 1000 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1001 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1002 | static ssize_t |
| 1003 | i915_error_state_write(struct file *filp, |
| 1004 | const char __user *ubuf, |
| 1005 | size_t cnt, |
| 1006 | loff_t *ppos) |
| 1007 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1008 | struct i915_gpu_state *error = filp->private_data; |
| 1009 | |
| 1010 | if (!error) |
| 1011 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1012 | |
| 1013 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1014 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1015 | |
| 1016 | return cnt; |
| 1017 | } |
| 1018 | |
| 1019 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1020 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1021 | file->private_data = i915_first_error_state(inode->i_private); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1022 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1023 | } |
| 1024 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1025 | static const struct file_operations i915_error_state_fops = { |
| 1026 | .owner = THIS_MODULE, |
| 1027 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1028 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1029 | .write = i915_error_state_write, |
| 1030 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1031 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1032 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1033 | #endif |
| 1034 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1035 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1036 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1037 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1038 | struct drm_i915_private *dev_priv = data; |
| 1039 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1040 | int ret; |
| 1041 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1042 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1043 | if (ret) |
| 1044 | return ret; |
| 1045 | |
Chris Wilson | 65c475c | 2018-01-02 15:12:31 +0000 | [diff] [blame] | 1046 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1047 | ret = i915_gem_set_global_seqno(dev, val); |
Chris Wilson | 65c475c | 2018-01-02 15:12:31 +0000 | [diff] [blame] | 1048 | intel_runtime_pm_put(dev_priv); |
| 1049 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1050 | mutex_unlock(&dev->struct_mutex); |
| 1051 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1052 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1053 | } |
| 1054 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1055 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
Chris Wilson | 9b6586a | 2017-02-23 07:44:08 +0000 | [diff] [blame] | 1056 | NULL, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1057 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1058 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1059 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1060 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1061 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1062 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1063 | int ret = 0; |
| 1064 | |
| 1065 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1066 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1067 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1068 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1069 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1070 | |
| 1071 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1072 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1073 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1074 | MEMSTAT_VID_SHIFT); |
| 1075 | seq_printf(m, "Current P-state: %d\n", |
| 1076 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1077 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1078 | u32 rpmodectl, freq_sts; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1079 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1080 | mutex_lock(&dev_priv->pcu_lock); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1081 | |
| 1082 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1083 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1084 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1085 | seq_printf(m, "HW control enabled: %s\n", |
| 1086 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1087 | seq_printf(m, "SW control enabled: %s\n", |
| 1088 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1089 | GEN6_RP_MEDIA_SW_MODE)); |
| 1090 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1091 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1092 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1093 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1094 | |
| 1095 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1096 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1097 | |
| 1098 | seq_printf(m, "current GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1099 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1100 | |
| 1101 | seq_printf(m, "max GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1102 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1103 | |
| 1104 | seq_printf(m, "min GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1105 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1106 | |
| 1107 | seq_printf(m, "idle GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1108 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1109 | |
| 1110 | seq_printf(m, |
| 1111 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1112 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1113 | mutex_unlock(&dev_priv->pcu_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1114 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1115 | u32 rp_state_limits; |
| 1116 | u32 gt_perf_status; |
| 1117 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1118 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1119 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1120 | u32 rpupei, rpcurup, rpprevup; |
| 1121 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1122 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1123 | int max_freq; |
| 1124 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1125 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1126 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1127 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1128 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1129 | } else { |
| 1130 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1131 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1132 | } |
| 1133 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1134 | /* RPSTAT1 is in the GT power well */ |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1135 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1136 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1137 | reqf = I915_READ(GEN6_RPNSWREQ); |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1138 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1139 | reqf >>= 23; |
| 1140 | else { |
| 1141 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1142 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1143 | reqf >>= 24; |
| 1144 | else |
| 1145 | reqf >>= 25; |
| 1146 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1147 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1148 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1149 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1150 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1151 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1152 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1153 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1154 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1155 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1156 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1157 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1158 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1159 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Tvrtko Ursulin | c84b270 | 2017-11-21 18:18:44 +0000 | [diff] [blame] | 1160 | cagf = intel_gpu_freq(dev_priv, |
| 1161 | intel_get_cagf(dev_priv, rpstat)); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1162 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1163 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1164 | |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1165 | if (INTEL_GEN(dev_priv) >= 11) { |
| 1166 | pm_ier = I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE); |
| 1167 | pm_imr = I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK); |
| 1168 | /* |
| 1169 | * The equivalent to the PM ISR & IIR cannot be read |
| 1170 | * without affecting the current state of the system |
| 1171 | */ |
| 1172 | pm_isr = 0; |
| 1173 | pm_iir = 0; |
| 1174 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1175 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1176 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1177 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1178 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1179 | } else { |
| 1180 | pm_ier = I915_READ(GEN6_PMIER); |
| 1181 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1182 | pm_isr = I915_READ(GEN6_PMISR); |
| 1183 | pm_iir = I915_READ(GEN6_PMIIR); |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1184 | } |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1185 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1186 | |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1187 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1188 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1189 | seq_printf(m, "HW control enabled: %s\n", |
| 1190 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1191 | seq_printf(m, "SW control enabled: %s\n", |
| 1192 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1193 | GEN6_RP_MEDIA_SW_MODE)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1194 | |
| 1195 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x, MASK=0x%08x\n", |
| 1196 | pm_ier, pm_imr, pm_mask); |
| 1197 | if (INTEL_GEN(dev_priv) <= 10) |
| 1198 | seq_printf(m, "PM ISR=0x%08x IIR=0x%08x\n", |
| 1199 | pm_isr, pm_iir); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1200 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1201 | rps->pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1202 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1203 | seq_printf(m, "Render p-state ratio: %d\n", |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1204 | (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1205 | seq_printf(m, "Render p-state VID: %d\n", |
| 1206 | gt_perf_status & 0xff); |
| 1207 | seq_printf(m, "Render p-state limit: %d\n", |
| 1208 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1209 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1210 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1211 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1212 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1213 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1214 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1215 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1216 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1217 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1218 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1219 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1220 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1221 | seq_printf(m, "Up threshold: %d%%\n", |
| 1222 | rps->power.up_threshold); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1223 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1224 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1225 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1226 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1227 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1228 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1229 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1230 | seq_printf(m, "Down threshold: %d%%\n", |
| 1231 | rps->power.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1232 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1233 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1234 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1235 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1236 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1237 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1238 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1239 | |
| 1240 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1241 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1242 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1243 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1244 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1245 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1246 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1247 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1248 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1249 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1250 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1251 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1252 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1253 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1254 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1255 | seq_printf(m, "Current freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1256 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1257 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1258 | seq_printf(m, "Idle freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1259 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1260 | seq_printf(m, "Min freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1261 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1262 | seq_printf(m, "Boost freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1263 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1264 | seq_printf(m, "Max freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1265 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1266 | seq_printf(m, |
| 1267 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1268 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1269 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1270 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1271 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1272 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1273 | 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] | 1274 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1275 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1276 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1277 | intel_runtime_pm_put(dev_priv); |
| 1278 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1279 | } |
| 1280 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1281 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1282 | struct seq_file *m, |
| 1283 | struct intel_instdone *instdone) |
| 1284 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1285 | int slice; |
| 1286 | int subslice; |
| 1287 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1288 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1289 | instdone->instdone); |
| 1290 | |
| 1291 | if (INTEL_GEN(dev_priv) <= 3) |
| 1292 | return; |
| 1293 | |
| 1294 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1295 | instdone->slice_common); |
| 1296 | |
| 1297 | if (INTEL_GEN(dev_priv) <= 6) |
| 1298 | return; |
| 1299 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1300 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1301 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1302 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1303 | |
| 1304 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1305 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1306 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1307 | } |
| 1308 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1309 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1310 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1311 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1312 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1313 | u64 acthd[I915_NUM_ENGINES]; |
| 1314 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1315 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1316 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1317 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1318 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1319 | seq_puts(m, "Wedged\n"); |
| 1320 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
| 1321 | seq_puts(m, "Reset in progress: struct_mutex backoff\n"); |
| 1322 | if (test_bit(I915_RESET_HANDOFF, &dev_priv->gpu_error.flags)) |
| 1323 | seq_puts(m, "Reset in progress: reset handoff to waiter\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1324 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1325 | seq_puts(m, "Waiter holding struct mutex\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1326 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1327 | seq_puts(m, "struct_mutex blocked for reset\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1328 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1329 | if (!i915_modparams.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1330 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1331 | return 0; |
| 1332 | } |
| 1333 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1334 | intel_runtime_pm_get(dev_priv); |
| 1335 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1336 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1337 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1338 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1339 | } |
| 1340 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1341 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1342 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1343 | intel_runtime_pm_put(dev_priv); |
| 1344 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1345 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1346 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1347 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1348 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1349 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1350 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1351 | else |
| 1352 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1353 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1354 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1355 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1356 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1357 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1358 | struct rb_node *rb; |
| 1359 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1360 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 52d7f16 | 2018-04-30 14:15:00 +0100 | [diff] [blame] | 1361 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1362 | engine->hangcheck.seqno, seqno[id], |
Chris Wilson | 52d7f16 | 2018-04-30 14:15:00 +0100 | [diff] [blame] | 1363 | intel_engine_last_submit(engine)); |
Chris Wilson | 1fd00c0f | 2018-06-02 11:48:53 +0100 | [diff] [blame] | 1364 | 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] | 1365 | yesno(intel_engine_has_waiter(engine)), |
| 1366 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1367 | &dev_priv->gpu_error.missed_irq_rings)), |
Chris Wilson | 1fd00c0f | 2018-06-02 11:48:53 +0100 | [diff] [blame] | 1368 | yesno(engine->hangcheck.stalled), |
| 1369 | yesno(engine->hangcheck.wedged)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1370 | |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1371 | spin_lock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1372 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
Geliang Tang | f802cf7 | 2016-12-19 22:43:49 +0800 | [diff] [blame] | 1373 | struct intel_wait *w = rb_entry(rb, typeof(*w), node); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1374 | |
| 1375 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1376 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1377 | } |
Chris Wilson | 61d3dc7 | 2017-03-03 19:08:24 +0000 | [diff] [blame] | 1378 | spin_unlock_irq(&b->rb_lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1379 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1380 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1381 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1382 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1383 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1384 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1385 | engine->hangcheck.action, |
| 1386 | jiffies_to_msecs(jiffies - |
| 1387 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1388 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1389 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1390 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1391 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1392 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1393 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1394 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1395 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1396 | i915_instdone_info(dev_priv, m, |
| 1397 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1398 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | return 0; |
| 1402 | } |
| 1403 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1404 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1405 | { |
| 1406 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1407 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1408 | struct intel_engine_cs *engine; |
| 1409 | enum intel_engine_id id; |
| 1410 | |
| 1411 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1412 | |
| 1413 | for_each_engine(engine, dev_priv, id) { |
| 1414 | seq_printf(m, "%s = %u\n", engine->name, |
| 1415 | i915_reset_engine_count(error, engine)); |
| 1416 | } |
| 1417 | |
| 1418 | return 0; |
| 1419 | } |
| 1420 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1421 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1422 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1423 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1424 | u32 rgvmodectl, rstdbyctl; |
| 1425 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1426 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1427 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1428 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1429 | crstandvid = I915_READ16(CRSTANDVID); |
| 1430 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1431 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1432 | seq_printf(m, "Boost freq: %d\n", |
| 1433 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1434 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1435 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1436 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1437 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1438 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1439 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1440 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1441 | seq_printf(m, "Starting frequency: P%d\n", |
| 1442 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1443 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1444 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1445 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1446 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1447 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1448 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1449 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1450 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1451 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1452 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1453 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1454 | break; |
| 1455 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1456 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1457 | break; |
| 1458 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1459 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1460 | break; |
| 1461 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1462 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1463 | break; |
| 1464 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1465 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1466 | break; |
| 1467 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1468 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1469 | break; |
| 1470 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1471 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1472 | break; |
| 1473 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1474 | |
| 1475 | return 0; |
| 1476 | } |
| 1477 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1478 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1479 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1480 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1481 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1482 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1483 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1484 | seq_printf(m, "user.bypass_count = %u\n", |
| 1485 | i915->uncore.user_forcewake.count); |
| 1486 | |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1487 | for_each_fw_domain(fw_domain, i915, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1488 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1489 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1490 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1491 | |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1495 | static void print_rc6_res(struct seq_file *m, |
| 1496 | const char *title, |
| 1497 | const i915_reg_t reg) |
| 1498 | { |
| 1499 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1500 | |
| 1501 | seq_printf(m, "%s %u (%llu us)\n", |
| 1502 | title, I915_READ(reg), |
| 1503 | intel_rc6_residency_us(dev_priv, reg)); |
| 1504 | } |
| 1505 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1506 | static int vlv_drpc_info(struct seq_file *m) |
| 1507 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1508 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1509 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1510 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1511 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1512 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1513 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1514 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1515 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1516 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1517 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1518 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1519 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1520 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1521 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1522 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1523 | 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] | 1524 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1525 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1526 | } |
| 1527 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1528 | static int gen6_drpc_info(struct seq_file *m) |
| 1529 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1530 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1531 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1532 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1533 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1534 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1535 | 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] | 1536 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1537 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1538 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1539 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1540 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1541 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1542 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1543 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1544 | mutex_lock(&dev_priv->pcu_lock); |
| 1545 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, |
| 1546 | &rc6vids); |
| 1547 | mutex_unlock(&dev_priv->pcu_lock); |
| 1548 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1549 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1550 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1551 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1552 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1553 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1554 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1555 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1556 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1557 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1558 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1559 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1560 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1561 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1562 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1563 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1564 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1565 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1566 | case GEN6_RC0: |
| 1567 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1568 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1569 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1570 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1571 | break; |
| 1572 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1573 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1574 | break; |
| 1575 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1576 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1577 | break; |
| 1578 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1579 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1580 | break; |
| 1581 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1582 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1583 | break; |
| 1584 | } |
| 1585 | |
| 1586 | seq_printf(m, "Core Power Down: %s\n", |
| 1587 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1588 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1589 | seq_printf(m, "Render Power Well: %s\n", |
| 1590 | (gen9_powergate_status & |
| 1591 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1592 | seq_printf(m, "Media Power Well: %s\n", |
| 1593 | (gen9_powergate_status & |
| 1594 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1595 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1596 | |
| 1597 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1598 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1599 | GEN6_GT_GFX_RC6_LOCKED); |
| 1600 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1601 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1602 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1603 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1604 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1605 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1606 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1607 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1608 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1609 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1610 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
| 1611 | } |
| 1612 | |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1613 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1617 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1618 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1619 | int err; |
| 1620 | |
| 1621 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1622 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1623 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1624 | err = vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1625 | else if (INTEL_GEN(dev_priv) >= 6) |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1626 | err = gen6_drpc_info(m); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1627 | else |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1628 | err = ironlake_drpc_info(m); |
| 1629 | |
| 1630 | intel_runtime_pm_put(dev_priv); |
| 1631 | |
| 1632 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1633 | } |
| 1634 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1635 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1636 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1637 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1638 | |
| 1639 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1640 | dev_priv->fb_tracking.busy_bits); |
| 1641 | |
| 1642 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1643 | dev_priv->fb_tracking.flip_bits); |
| 1644 | |
| 1645 | return 0; |
| 1646 | } |
| 1647 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1648 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1649 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1650 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1651 | struct intel_fbc *fbc = &dev_priv->fbc; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1652 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1653 | if (!HAS_FBC(dev_priv)) |
| 1654 | return -ENODEV; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1655 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1656 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1657 | mutex_lock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1658 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1659 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1660 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1661 | else |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1662 | seq_printf(m, "FBC disabled: %s\n", fbc->no_fbc_reason); |
| 1663 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1664 | if (intel_fbc_is_active(dev_priv)) { |
| 1665 | u32 mask; |
| 1666 | |
| 1667 | if (INTEL_GEN(dev_priv) >= 8) |
| 1668 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1669 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1670 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1671 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1672 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1673 | else if (IS_G4X(dev_priv)) |
| 1674 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1675 | else |
| 1676 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1677 | FBC_STAT_COMPRESSED); |
| 1678 | |
| 1679 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1680 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1681 | |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1682 | mutex_unlock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1683 | intel_runtime_pm_put(dev_priv); |
| 1684 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1685 | return 0; |
| 1686 | } |
| 1687 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1688 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1689 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1690 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1691 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1692 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1693 | return -ENODEV; |
| 1694 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1695 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1696 | |
| 1697 | return 0; |
| 1698 | } |
| 1699 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1700 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1701 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1702 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1703 | u32 reg; |
| 1704 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1705 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1706 | return -ENODEV; |
| 1707 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1708 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1709 | |
| 1710 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1711 | dev_priv->fbc.false_color = val; |
| 1712 | |
| 1713 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1714 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1715 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1716 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1717 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1718 | return 0; |
| 1719 | } |
| 1720 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1721 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1722 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1723 | "%llu\n"); |
| 1724 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1725 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1726 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1727 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1728 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1729 | if (!HAS_IPS(dev_priv)) |
| 1730 | return -ENODEV; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1731 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1732 | intel_runtime_pm_get(dev_priv); |
| 1733 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1734 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1735 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1736 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1737 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1738 | seq_puts(m, "Currently: unknown\n"); |
| 1739 | } else { |
| 1740 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1741 | seq_puts(m, "Currently: enabled\n"); |
| 1742 | else |
| 1743 | seq_puts(m, "Currently: disabled\n"); |
| 1744 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1745 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1746 | intel_runtime_pm_put(dev_priv); |
| 1747 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1748 | return 0; |
| 1749 | } |
| 1750 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1751 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1752 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1753 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1754 | bool sr_enabled = false; |
| 1755 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1756 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1757 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1758 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1759 | if (INTEL_GEN(dev_priv) >= 9) |
| 1760 | /* no global SR status; inspect per-plane WM */; |
| 1761 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1762 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1763 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1764 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1765 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1766 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1767 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1768 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1769 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1770 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1771 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1772 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1773 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1774 | intel_runtime_pm_put(dev_priv); |
| 1775 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1776 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1777 | |
| 1778 | return 0; |
| 1779 | } |
| 1780 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1781 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1782 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1783 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1784 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1785 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1786 | int ret; |
| 1787 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1788 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1789 | return -ENODEV; |
| 1790 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1791 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1792 | if (ret) |
| 1793 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1794 | |
| 1795 | temp = i915_mch_val(dev_priv); |
| 1796 | chipset = i915_chipset_val(dev_priv); |
| 1797 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1798 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1799 | |
| 1800 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1801 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1802 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1803 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1804 | |
| 1805 | return 0; |
| 1806 | } |
| 1807 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1808 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1809 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1810 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1811 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1812 | unsigned int max_gpu_freq, min_gpu_freq; |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1813 | int gpu_freq, ia_freq; |
| 1814 | int ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1815 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1816 | if (!HAS_LLC(dev_priv)) |
| 1817 | return -ENODEV; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1818 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1819 | intel_runtime_pm_get(dev_priv); |
| 1820 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1821 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1822 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1823 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1824 | |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1825 | min_gpu_freq = rps->min_freq; |
| 1826 | max_gpu_freq = rps->max_freq; |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1827 | if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1828 | /* Convert GT frequency to 50 HZ units */ |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1829 | min_gpu_freq /= GEN9_FREQ_SCALER; |
| 1830 | max_gpu_freq /= GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1831 | } |
| 1832 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1833 | 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] | 1834 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1835 | 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] | 1836 | ia_freq = gpu_freq; |
| 1837 | sandybridge_pcode_read(dev_priv, |
| 1838 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1839 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1840 | 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] | 1841 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1842 | (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1843 | INTEL_GEN(dev_priv) >= 10 ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1844 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1845 | ((ia_freq >> 0) & 0xff) * 100, |
| 1846 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1847 | } |
| 1848 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1849 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1850 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1851 | out: |
| 1852 | intel_runtime_pm_put(dev_priv); |
| 1853 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1854 | } |
| 1855 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1856 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1857 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1858 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1859 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1860 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1861 | int ret; |
| 1862 | |
| 1863 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1864 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1865 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1866 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1867 | if (opregion->header) |
| 1868 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1869 | |
| 1870 | mutex_unlock(&dev->struct_mutex); |
| 1871 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1872 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1873 | return 0; |
| 1874 | } |
| 1875 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1876 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1877 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1878 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1879 | |
| 1880 | if (opregion->vbt) |
| 1881 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1882 | |
| 1883 | return 0; |
| 1884 | } |
| 1885 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1886 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1887 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1888 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1889 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1890 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1891 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1892 | int ret; |
| 1893 | |
| 1894 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1895 | if (ret) |
| 1896 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1897 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1898 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1899 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1900 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1901 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1902 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1903 | fbdev_fb->base.width, |
| 1904 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1905 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1906 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1907 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1908 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1909 | describe_obj(m, intel_fb_obj(&fbdev_fb->base)); |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1910 | seq_putc(m, '\n'); |
| 1911 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1912 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1913 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1914 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1915 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1916 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1917 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1918 | continue; |
| 1919 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1920 | 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] | 1921 | fb->base.width, |
| 1922 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1923 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1924 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1925 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1926 | drm_framebuffer_read_refcount(&fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1927 | describe_obj(m, intel_fb_obj(&fb->base)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1928 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1929 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1930 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1931 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1932 | |
| 1933 | return 0; |
| 1934 | } |
| 1935 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1936 | 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] | 1937 | { |
Chris Wilson | ef5032a | 2018-03-07 13:42:24 +0000 | [diff] [blame] | 1938 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", |
| 1939 | ring->space, ring->head, ring->tail, ring->emit); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1940 | } |
| 1941 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1942 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1943 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1944 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1945 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1946 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1947 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1948 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1949 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1950 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1951 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1952 | if (ret) |
| 1953 | return ret; |
| 1954 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1955 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 288f1ce | 2018-09-04 16:31:17 +0100 | [diff] [blame] | 1956 | seq_puts(m, "HW context "); |
| 1957 | if (!list_empty(&ctx->hw_id_link)) |
| 1958 | seq_printf(m, "%x [pin %u]", ctx->hw_id, |
| 1959 | atomic_read(&ctx->hw_id_pin_count)); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1960 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1961 | struct task_struct *task; |
| 1962 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1963 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1964 | if (task) { |
| 1965 | seq_printf(m, "(%s [%d]) ", |
| 1966 | task->comm, task->pid); |
| 1967 | put_task_struct(task); |
| 1968 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1969 | } else if (IS_ERR(ctx->file_priv)) { |
| 1970 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1971 | } else { |
| 1972 | seq_puts(m, "(kernel) "); |
| 1973 | } |
| 1974 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1975 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1976 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1977 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1978 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | ab82a06 | 2018-04-30 14:15:01 +0100 | [diff] [blame] | 1979 | struct intel_context *ce = |
| 1980 | to_intel_context(ctx, engine); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1981 | |
| 1982 | seq_printf(m, "%s: ", engine->name); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1983 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1984 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1985 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1986 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1987 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1988 | } |
| 1989 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1990 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1991 | } |
| 1992 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1993 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1994 | |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1998 | static const char *swizzle_string(unsigned swizzle) |
| 1999 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2000 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2001 | case I915_BIT_6_SWIZZLE_NONE: |
| 2002 | return "none"; |
| 2003 | case I915_BIT_6_SWIZZLE_9: |
| 2004 | return "bit9"; |
| 2005 | case I915_BIT_6_SWIZZLE_9_10: |
| 2006 | return "bit9/bit10"; |
| 2007 | case I915_BIT_6_SWIZZLE_9_11: |
| 2008 | return "bit9/bit11"; |
| 2009 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2010 | return "bit9/bit10/bit11"; |
| 2011 | case I915_BIT_6_SWIZZLE_9_17: |
| 2012 | return "bit9/bit17"; |
| 2013 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2014 | return "bit9/bit10/bit17"; |
| 2015 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2016 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | return "bug"; |
| 2020 | } |
| 2021 | |
| 2022 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2023 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2024 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2025 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2026 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2027 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2028 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2029 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2030 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2031 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2032 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2033 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2034 | seq_printf(m, "DDC = 0x%08x\n", |
| 2035 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2036 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2037 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2038 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2039 | I915_READ16(C0DRB3)); |
| 2040 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2041 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2042 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2043 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2044 | I915_READ(MAD_DIMM_C0)); |
| 2045 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2046 | I915_READ(MAD_DIMM_C1)); |
| 2047 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2048 | I915_READ(MAD_DIMM_C2)); |
| 2049 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2050 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2051 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2052 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2053 | I915_READ(GAMTARBMODE)); |
| 2054 | else |
| 2055 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2056 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2057 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2058 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2059 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2060 | |
| 2061 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2062 | seq_puts(m, "L-shaped memory detected\n"); |
| 2063 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2064 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2065 | |
| 2066 | return 0; |
| 2067 | } |
| 2068 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2069 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2070 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2071 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2072 | struct seq_file *m = data; |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2073 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2074 | |
| 2075 | if (!ppgtt) { |
| 2076 | seq_printf(m, " no ppgtt for context %d\n", |
| 2077 | ctx->user_handle); |
| 2078 | return 0; |
| 2079 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2080 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2081 | if (i915_gem_context_is_default(ctx)) |
| 2082 | seq_puts(m, " default context:\n"); |
| 2083 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2084 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2085 | ppgtt->debug_dump(ppgtt, m); |
| 2086 | |
| 2087 | return 0; |
| 2088 | } |
| 2089 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2090 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2091 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2092 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2093 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2094 | struct intel_engine_cs *engine; |
| 2095 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2096 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2097 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2098 | if (!ppgtt) |
| 2099 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2100 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2101 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2102 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2103 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2104 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2105 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2106 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2107 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2108 | } |
| 2109 | } |
| 2110 | } |
| 2111 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2112 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2113 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2114 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2115 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2116 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2117 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2118 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2119 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2120 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2121 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2122 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2123 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2124 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2125 | I915_READ(RING_MODE_GEN7(engine))); |
| 2126 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2127 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2128 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2129 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2130 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2131 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2132 | } |
| 2133 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2134 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2135 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2136 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2137 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2138 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2139 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2140 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2141 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2142 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2143 | } |
| 2144 | |
| 2145 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2146 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2147 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2148 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2149 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2150 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2151 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2152 | mutex_lock(&dev->filelist_mutex); |
| 2153 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2154 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2155 | goto out_unlock; |
| 2156 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2157 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2158 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2159 | if (INTEL_GEN(dev_priv) >= 8) |
| 2160 | gen8_ppgtt_info(m, dev_priv); |
| 2161 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2162 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2163 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2164 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2165 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2166 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2167 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2168 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2169 | if (!task) { |
| 2170 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2171 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2172 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2173 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2174 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2175 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2176 | (void *)(unsigned long)m); |
| 2177 | } |
| 2178 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2179 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2180 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2181 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2182 | out_unlock: |
| 2183 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2184 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2185 | } |
| 2186 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2187 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2188 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2189 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2190 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2191 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2192 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2193 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2194 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2195 | |
| 2196 | return count; |
| 2197 | } |
| 2198 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2199 | static const char *rps_power_to_str(unsigned int power) |
| 2200 | { |
| 2201 | static const char * const strings[] = { |
| 2202 | [LOW_POWER] = "low power", |
| 2203 | [BETWEEN] = "mixed", |
| 2204 | [HIGH_POWER] = "high power", |
| 2205 | }; |
| 2206 | |
| 2207 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2208 | return "unknown"; |
| 2209 | |
| 2210 | return strings[power]; |
| 2211 | } |
| 2212 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2213 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2214 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2215 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2216 | struct drm_device *dev = &dev_priv->drm; |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2217 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2218 | u32 act_freq = rps->cur_freq; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2219 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2220 | |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2221 | if (intel_runtime_pm_get_if_in_use(dev_priv)) { |
| 2222 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 2223 | mutex_lock(&dev_priv->pcu_lock); |
| 2224 | act_freq = vlv_punit_read(dev_priv, |
| 2225 | PUNIT_REG_GPU_FREQ_STS); |
| 2226 | act_freq = (act_freq >> 8) & 0xff; |
| 2227 | mutex_unlock(&dev_priv->pcu_lock); |
| 2228 | } else { |
| 2229 | act_freq = intel_get_cagf(dev_priv, |
| 2230 | I915_READ(GEN6_RPSTAT1)); |
| 2231 | } |
| 2232 | intel_runtime_pm_put(dev_priv); |
| 2233 | } |
| 2234 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2235 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2236 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2237 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2238 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2239 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2240 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2241 | seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2242 | seq_printf(m, "Frequency requested %d, actual %d\n", |
| 2243 | intel_gpu_freq(dev_priv, rps->cur_freq), |
| 2244 | intel_gpu_freq(dev_priv, act_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2245 | 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] | 2246 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2247 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2248 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2249 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2250 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2251 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2252 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2253 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2254 | |
| 2255 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2256 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2257 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2258 | struct task_struct *task; |
| 2259 | |
| 2260 | rcu_read_lock(); |
| 2261 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2262 | seq_printf(m, "%s [%d]: %d boosts\n", |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2263 | task ? task->comm : "<unknown>", |
| 2264 | task ? task->pid : -1, |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2265 | atomic_read(&file_priv->rps_client.boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2266 | rcu_read_unlock(); |
| 2267 | } |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2268 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2269 | atomic_read(&rps->boosts)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2270 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2271 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2272 | if (INTEL_GEN(dev_priv) >= 6 && |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2273 | rps->enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2274 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2275 | u32 rpup, rpupei; |
| 2276 | u32 rpdown, rpdownei; |
| 2277 | |
| 2278 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2279 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2280 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2281 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2282 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2283 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2284 | |
| 2285 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2286 | rps_power_to_str(rps->power.mode)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2287 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2288 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2289 | rps->power.up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2290 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2291 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2292 | rps->power.down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2293 | } else { |
| 2294 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2295 | } |
| 2296 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2297 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2298 | } |
| 2299 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2300 | static int i915_llc(struct seq_file *m, void *data) |
| 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); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2303 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2304 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2305 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2306 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2307 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2308 | |
| 2309 | return 0; |
| 2310 | } |
| 2311 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2312 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2313 | { |
| 2314 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2315 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2316 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2317 | if (!HAS_HUC(dev_priv)) |
| 2318 | return -ENODEV; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2319 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2320 | p = drm_seq_file_printer(m); |
| 2321 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2322 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2323 | intel_runtime_pm_get(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2324 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2325 | intel_runtime_pm_put(dev_priv); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2326 | |
| 2327 | return 0; |
| 2328 | } |
| 2329 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2330 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2331 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2332 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2333 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2334 | u32 tmp, i; |
| 2335 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2336 | if (!HAS_GUC(dev_priv)) |
| 2337 | return -ENODEV; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2338 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2339 | p = drm_seq_file_printer(m); |
| 2340 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2341 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2342 | intel_runtime_pm_get(dev_priv); |
| 2343 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2344 | tmp = I915_READ(GUC_STATUS); |
| 2345 | |
| 2346 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2347 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2348 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2349 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2350 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2351 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2352 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2353 | seq_puts(m, "\nScratch registers:\n"); |
| 2354 | for (i = 0; i < 16; i++) |
| 2355 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2356 | |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2357 | intel_runtime_pm_put(dev_priv); |
| 2358 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2359 | return 0; |
| 2360 | } |
| 2361 | |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2362 | static const char * |
| 2363 | stringify_guc_log_type(enum guc_log_buffer_type type) |
| 2364 | { |
| 2365 | switch (type) { |
| 2366 | case GUC_ISR_LOG_BUFFER: |
| 2367 | return "ISR"; |
| 2368 | case GUC_DPC_LOG_BUFFER: |
| 2369 | return "DPC"; |
| 2370 | case GUC_CRASH_DUMP_LOG_BUFFER: |
| 2371 | return "CRASH"; |
| 2372 | default: |
| 2373 | MISSING_CASE(type); |
| 2374 | } |
| 2375 | |
| 2376 | return ""; |
| 2377 | } |
| 2378 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2379 | static void i915_guc_log_info(struct seq_file *m, |
| 2380 | struct drm_i915_private *dev_priv) |
| 2381 | { |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2382 | struct intel_guc_log *log = &dev_priv->guc.log; |
| 2383 | enum guc_log_buffer_type type; |
| 2384 | |
| 2385 | if (!intel_guc_log_relay_enabled(log)) { |
| 2386 | seq_puts(m, "GuC log relay disabled\n"); |
| 2387 | return; |
| 2388 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2389 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2390 | seq_puts(m, "GuC logging stats:\n"); |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2391 | |
Michał Winiarski | 6a96be2 | 2018-03-19 10:53:42 +0100 | [diff] [blame] | 2392 | seq_printf(m, "\tRelay full count: %u\n", |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2393 | log->relay.full_count); |
| 2394 | |
| 2395 | for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { |
| 2396 | seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", |
| 2397 | stringify_guc_log_type(type), |
| 2398 | log->stats[type].flush, |
| 2399 | log->stats[type].sampled_overflow); |
| 2400 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2401 | } |
| 2402 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2403 | static void i915_guc_client_info(struct seq_file *m, |
| 2404 | struct drm_i915_private *dev_priv, |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2405 | struct intel_guc_client *client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2406 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2407 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2408 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2409 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2410 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2411 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2412 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2413 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2414 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2415 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2416 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2417 | u64 submissions = client->submissions[id]; |
| 2418 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2419 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2420 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2421 | } |
| 2422 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2423 | } |
| 2424 | |
| 2425 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2426 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2427 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2428 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2429 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2430 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2431 | return -ENODEV; |
| 2432 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2433 | i915_guc_log_info(m, dev_priv); |
| 2434 | |
| 2435 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2436 | return 0; |
| 2437 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2438 | GEM_BUG_ON(!guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2439 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2440 | seq_printf(m, "\nDoorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2441 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2442 | seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2443 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2444 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2445 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Chris Wilson | e78c917 | 2018-02-07 21:05:42 +0000 | [diff] [blame] | 2446 | if (guc->preempt_client) { |
| 2447 | seq_printf(m, "\nGuC preempt client @ %p:\n", |
| 2448 | guc->preempt_client); |
| 2449 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
| 2450 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2451 | |
| 2452 | /* Add more as required ... */ |
| 2453 | |
| 2454 | return 0; |
| 2455 | } |
| 2456 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2457 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2458 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2459 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2460 | const struct intel_guc *guc = &dev_priv->guc; |
| 2461 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2462 | struct intel_guc_client *client = guc->execbuf_client; |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2463 | unsigned int tmp; |
| 2464 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2465 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2466 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2467 | return -ENODEV; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2468 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2469 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2470 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2471 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2472 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2473 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2474 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2475 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2476 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2477 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2478 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2479 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2480 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2481 | desc->engines_used); |
| 2482 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2483 | desc->db_trigger_phy, |
| 2484 | desc->db_trigger_cpu, |
| 2485 | desc->db_trigger_uk); |
| 2486 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2487 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2488 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2489 | desc->wq_addr, desc->wq_size); |
| 2490 | seq_putc(m, '\n'); |
| 2491 | |
| 2492 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2493 | u32 guc_engine_id = engine->guc_id; |
| 2494 | struct guc_execlist_context *lrc = |
| 2495 | &desc->lrc[guc_engine_id]; |
| 2496 | |
| 2497 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2498 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2499 | lrc->context_desc); |
| 2500 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2501 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2502 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2503 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2504 | seq_putc(m, '\n'); |
| 2505 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2506 | } |
| 2507 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2508 | return 0; |
| 2509 | } |
| 2510 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2511 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2512 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2513 | struct drm_info_node *node = m->private; |
| 2514 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2515 | bool dump_load_err = !!node->info_ent->data; |
| 2516 | struct drm_i915_gem_object *obj = NULL; |
| 2517 | u32 *log; |
| 2518 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2519 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2520 | if (!HAS_GUC(dev_priv)) |
| 2521 | return -ENODEV; |
| 2522 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2523 | if (dump_load_err) |
| 2524 | obj = dev_priv->guc.load_err_log; |
| 2525 | else if (dev_priv->guc.log.vma) |
| 2526 | obj = dev_priv->guc.log.vma->obj; |
| 2527 | |
| 2528 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2529 | return 0; |
| 2530 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2531 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2532 | if (IS_ERR(log)) { |
| 2533 | DRM_DEBUG("Failed to pin object\n"); |
| 2534 | seq_puts(m, "(log data unaccessible)\n"); |
| 2535 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2536 | } |
| 2537 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2538 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2539 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2540 | *(log + i), *(log + i + 1), |
| 2541 | *(log + i + 2), *(log + i + 3)); |
| 2542 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2543 | seq_putc(m, '\n'); |
| 2544 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2545 | i915_gem_object_unpin_map(obj); |
| 2546 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2547 | return 0; |
| 2548 | } |
| 2549 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2550 | static int i915_guc_log_level_get(void *data, u64 *val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2551 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2552 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2553 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2554 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2555 | return -ENODEV; |
| 2556 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2557 | *val = intel_guc_log_get_level(&dev_priv->guc.log); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2558 | |
| 2559 | return 0; |
| 2560 | } |
| 2561 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2562 | static int i915_guc_log_level_set(void *data, u64 val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2563 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2564 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2565 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2566 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2567 | return -ENODEV; |
| 2568 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2569 | return intel_guc_log_set_level(&dev_priv->guc.log, val); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2570 | } |
| 2571 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2572 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, |
| 2573 | i915_guc_log_level_get, i915_guc_log_level_set, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2574 | "%lld\n"); |
| 2575 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2576 | static int i915_guc_log_relay_open(struct inode *inode, struct file *file) |
| 2577 | { |
| 2578 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2579 | |
| 2580 | if (!USES_GUC(dev_priv)) |
| 2581 | return -ENODEV; |
| 2582 | |
| 2583 | file->private_data = &dev_priv->guc.log; |
| 2584 | |
| 2585 | return intel_guc_log_relay_open(&dev_priv->guc.log); |
| 2586 | } |
| 2587 | |
| 2588 | static ssize_t |
| 2589 | i915_guc_log_relay_write(struct file *filp, |
| 2590 | const char __user *ubuf, |
| 2591 | size_t cnt, |
| 2592 | loff_t *ppos) |
| 2593 | { |
| 2594 | struct intel_guc_log *log = filp->private_data; |
| 2595 | |
| 2596 | intel_guc_log_relay_flush(log); |
| 2597 | |
| 2598 | return cnt; |
| 2599 | } |
| 2600 | |
| 2601 | static int i915_guc_log_relay_release(struct inode *inode, struct file *file) |
| 2602 | { |
| 2603 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2604 | |
| 2605 | intel_guc_log_relay_close(&dev_priv->guc.log); |
| 2606 | |
| 2607 | return 0; |
| 2608 | } |
| 2609 | |
| 2610 | static const struct file_operations i915_guc_log_relay_fops = { |
| 2611 | .owner = THIS_MODULE, |
| 2612 | .open = i915_guc_log_relay_open, |
| 2613 | .write = i915_guc_log_relay_write, |
| 2614 | .release = i915_guc_log_relay_release, |
| 2615 | }; |
| 2616 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2617 | static int i915_psr_sink_status_show(struct seq_file *m, void *data) |
| 2618 | { |
| 2619 | u8 val; |
| 2620 | static const char * const sink_status[] = { |
| 2621 | "inactive", |
| 2622 | "transition to active, capture and display", |
| 2623 | "active, display from RFB", |
| 2624 | "active, capture and display on sink device timings", |
| 2625 | "transition to inactive, capture and display, timing re-sync", |
| 2626 | "reserved", |
| 2627 | "reserved", |
| 2628 | "sink internal error", |
| 2629 | }; |
| 2630 | struct drm_connector *connector = m->private; |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2631 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2632 | struct intel_dp *intel_dp = |
| 2633 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2634 | int ret; |
| 2635 | |
| 2636 | if (!CAN_PSR(dev_priv)) { |
| 2637 | seq_puts(m, "PSR Unsupported\n"); |
| 2638 | return -ENODEV; |
| 2639 | } |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2640 | |
| 2641 | if (connector->status != connector_status_connected) |
| 2642 | return -ENODEV; |
| 2643 | |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2644 | ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val); |
| 2645 | |
| 2646 | if (ret == 1) { |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2647 | const char *str = "unknown"; |
| 2648 | |
| 2649 | val &= DP_PSR_SINK_STATE_MASK; |
| 2650 | if (val < ARRAY_SIZE(sink_status)) |
| 2651 | str = sink_status[val]; |
| 2652 | seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str); |
| 2653 | } else { |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2654 | return ret; |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2655 | } |
| 2656 | |
| 2657 | return 0; |
| 2658 | } |
| 2659 | DEFINE_SHOW_ATTRIBUTE(i915_psr_sink_status); |
| 2660 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2661 | static void |
| 2662 | 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] | 2663 | { |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2664 | u32 val, psr_status; |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2665 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2666 | if (dev_priv->psr.psr2_enabled) { |
| 2667 | static const char * const live_status[] = { |
| 2668 | "IDLE", |
| 2669 | "CAPTURE", |
| 2670 | "CAPTURE_FS", |
| 2671 | "SLEEP", |
| 2672 | "BUFON_FW", |
| 2673 | "ML_UP", |
| 2674 | "SU_STANDBY", |
| 2675 | "FAST_SLEEP", |
| 2676 | "DEEP_SLEEP", |
| 2677 | "BUF_ON", |
| 2678 | "TG_ON" |
| 2679 | }; |
| 2680 | psr_status = I915_READ(EDP_PSR2_STATUS); |
| 2681 | val = (psr_status & EDP_PSR2_STATUS_STATE_MASK) >> |
| 2682 | EDP_PSR2_STATUS_STATE_SHIFT; |
| 2683 | if (val < ARRAY_SIZE(live_status)) { |
| 2684 | seq_printf(m, "Source PSR status: 0x%x [%s]\n", |
| 2685 | psr_status, live_status[val]); |
| 2686 | return; |
| 2687 | } |
| 2688 | } else { |
| 2689 | static const char * const live_status[] = { |
| 2690 | "IDLE", |
| 2691 | "SRDONACK", |
| 2692 | "SRDENT", |
| 2693 | "BUFOFF", |
| 2694 | "BUFON", |
| 2695 | "AUXACK", |
| 2696 | "SRDOFFACK", |
| 2697 | "SRDENT_ON", |
| 2698 | }; |
| 2699 | psr_status = I915_READ(EDP_PSR_STATUS); |
| 2700 | val = (psr_status & EDP_PSR_STATUS_STATE_MASK) >> |
| 2701 | EDP_PSR_STATUS_STATE_SHIFT; |
| 2702 | if (val < ARRAY_SIZE(live_status)) { |
| 2703 | seq_printf(m, "Source PSR status: 0x%x [%s]\n", |
| 2704 | psr_status, live_status[val]); |
| 2705 | return; |
| 2706 | } |
| 2707 | } |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2708 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2709 | 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] | 2710 | } |
| 2711 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2712 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2713 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2714 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2715 | u32 psrperf = 0; |
| 2716 | bool enabled = false; |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2717 | bool sink_support; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2718 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2719 | if (!HAS_PSR(dev_priv)) |
| 2720 | return -ENODEV; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2721 | |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2722 | sink_support = dev_priv->psr.sink_support; |
| 2723 | seq_printf(m, "Sink_Support: %s\n", yesno(sink_support)); |
| 2724 | if (!sink_support) |
| 2725 | return 0; |
| 2726 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2727 | intel_runtime_pm_get(dev_priv); |
| 2728 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2729 | mutex_lock(&dev_priv->psr.lock); |
Azhar Shaikh | 0577ab4 | 2018-08-22 10:23:48 -0700 | [diff] [blame] | 2730 | seq_printf(m, "PSR mode: %s\n", |
| 2731 | dev_priv->psr.psr2_enabled ? "PSR2" : "PSR1"); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2732 | seq_printf(m, "Enabled: %s\n", yesno(dev_priv->psr.enabled)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2733 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2734 | dev_priv->psr.busy_frontbuffer_bits); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2735 | |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2736 | if (dev_priv->psr.psr2_enabled) |
| 2737 | enabled = I915_READ(EDP_PSR2_CTL) & EDP_PSR2_ENABLE; |
| 2738 | else |
| 2739 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2740 | |
| 2741 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2742 | yesno(dev_priv->psr.link_standby)); |
| 2743 | |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2744 | seq_printf(m, "HW Enabled & Active bit: %s\n", yesno(enabled)); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2745 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2746 | /* |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2747 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2748 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2749 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2750 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2751 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2752 | |
| 2753 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2754 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2755 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2756 | psr_source_status(dev_priv, m); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2757 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2758 | |
Dhinakaran Pandiyan | 9844d4b | 2018-08-21 15:11:55 -0700 | [diff] [blame] | 2759 | if (READ_ONCE(dev_priv->psr.debug) & I915_PSR_DEBUG_IRQ) { |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2760 | seq_printf(m, "Last attempted entry at: %lld\n", |
| 2761 | dev_priv->psr.last_entry_attempt); |
| 2762 | seq_printf(m, "Last exit at: %lld\n", |
| 2763 | dev_priv->psr.last_exit); |
| 2764 | } |
| 2765 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2766 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2767 | return 0; |
| 2768 | } |
| 2769 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2770 | static int |
| 2771 | i915_edp_psr_debug_set(void *data, u64 val) |
| 2772 | { |
| 2773 | struct drm_i915_private *dev_priv = data; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2774 | struct drm_modeset_acquire_ctx ctx; |
| 2775 | int ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2776 | |
| 2777 | if (!CAN_PSR(dev_priv)) |
| 2778 | return -ENODEV; |
| 2779 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2780 | DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2781 | |
| 2782 | intel_runtime_pm_get(dev_priv); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2783 | |
| 2784 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 2785 | |
| 2786 | retry: |
| 2787 | ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val); |
| 2788 | if (ret == -EDEADLK) { |
| 2789 | ret = drm_modeset_backoff(&ctx); |
| 2790 | if (!ret) |
| 2791 | goto retry; |
| 2792 | } |
| 2793 | |
| 2794 | drm_modeset_drop_locks(&ctx); |
| 2795 | drm_modeset_acquire_fini(&ctx); |
| 2796 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2797 | intel_runtime_pm_put(dev_priv); |
| 2798 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2799 | return ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2800 | } |
| 2801 | |
| 2802 | static int |
| 2803 | i915_edp_psr_debug_get(void *data, u64 *val) |
| 2804 | { |
| 2805 | struct drm_i915_private *dev_priv = data; |
| 2806 | |
| 2807 | if (!CAN_PSR(dev_priv)) |
| 2808 | return -ENODEV; |
| 2809 | |
| 2810 | *val = READ_ONCE(dev_priv->psr.debug); |
| 2811 | return 0; |
| 2812 | } |
| 2813 | |
| 2814 | DEFINE_SIMPLE_ATTRIBUTE(i915_edp_psr_debug_fops, |
| 2815 | i915_edp_psr_debug_get, i915_edp_psr_debug_set, |
| 2816 | "%llu\n"); |
| 2817 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2818 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2819 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2820 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2821 | unsigned long long power; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2822 | u32 units; |
| 2823 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2824 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2825 | return -ENODEV; |
| 2826 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2827 | intel_runtime_pm_get(dev_priv); |
| 2828 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2829 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) { |
| 2830 | intel_runtime_pm_put(dev_priv); |
| 2831 | return -ENODEV; |
| 2832 | } |
| 2833 | |
| 2834 | units = (power & 0x1f00) >> 8; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2835 | power = I915_READ(MCH_SECP_NRG_STTS); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2836 | power = (1000000 * power) >> units; /* convert to uJ */ |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2837 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2838 | intel_runtime_pm_put(dev_priv); |
| 2839 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2840 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2841 | |
| 2842 | return 0; |
| 2843 | } |
| 2844 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2845 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2846 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2847 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2848 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2849 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2850 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2851 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2852 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 2853 | seq_printf(m, "GPU idle: %s (epoch %u)\n", |
| 2854 | yesno(!dev_priv->gt.awake), dev_priv->gt.epoch); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2855 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2856 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2857 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2858 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2859 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2860 | #else |
| 2861 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2862 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2863 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2864 | pci_power_name(pdev->current_state), |
| 2865 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2866 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2867 | return 0; |
| 2868 | } |
| 2869 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2870 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2871 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2872 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2873 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2874 | int i; |
| 2875 | |
| 2876 | mutex_lock(&power_domains->lock); |
| 2877 | |
| 2878 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2879 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2880 | struct i915_power_well *power_well; |
| 2881 | enum intel_display_power_domain power_domain; |
| 2882 | |
| 2883 | power_well = &power_domains->power_wells[i]; |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2884 | seq_printf(m, "%-25s %d\n", power_well->desc->name, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2885 | power_well->count); |
| 2886 | |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2887 | for_each_power_domain(power_domain, power_well->desc->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2888 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2889 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2890 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2891 | } |
| 2892 | |
| 2893 | mutex_unlock(&power_domains->lock); |
| 2894 | |
| 2895 | return 0; |
| 2896 | } |
| 2897 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2898 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2899 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2900 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2901 | struct intel_csr *csr; |
| 2902 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2903 | if (!HAS_CSR(dev_priv)) |
| 2904 | return -ENODEV; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2905 | |
| 2906 | csr = &dev_priv->csr; |
| 2907 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2908 | intel_runtime_pm_get(dev_priv); |
| 2909 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2910 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2911 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2912 | |
| 2913 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2914 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2915 | |
| 2916 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2917 | CSR_VERSION_MINOR(csr->version)); |
| 2918 | |
Jyoti Yadav | 27d7aaa | 2018-10-05 14:08:46 -0400 | [diff] [blame] | 2919 | if (IS_BROXTON(dev_priv)) { |
| 2920 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2921 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
| 2922 | } else if (IS_GEN(dev_priv, 9, 11)) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2923 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2924 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2925 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2926 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
| 2927 | } |
| 2928 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2929 | out: |
| 2930 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2931 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2932 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2933 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2934 | intel_runtime_pm_put(dev_priv); |
| 2935 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2936 | return 0; |
| 2937 | } |
| 2938 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2939 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2940 | struct drm_display_mode *mode) |
| 2941 | { |
| 2942 | int i; |
| 2943 | |
| 2944 | for (i = 0; i < tabs; i++) |
| 2945 | seq_putc(m, '\t'); |
| 2946 | |
| 2947 | 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", |
| 2948 | mode->base.id, mode->name, |
| 2949 | mode->vrefresh, mode->clock, |
| 2950 | mode->hdisplay, mode->hsync_start, |
| 2951 | mode->hsync_end, mode->htotal, |
| 2952 | mode->vdisplay, mode->vsync_start, |
| 2953 | mode->vsync_end, mode->vtotal, |
| 2954 | mode->type, mode->flags); |
| 2955 | } |
| 2956 | |
| 2957 | static void intel_encoder_info(struct seq_file *m, |
| 2958 | struct intel_crtc *intel_crtc, |
| 2959 | struct intel_encoder *intel_encoder) |
| 2960 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2961 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2962 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2963 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2964 | struct intel_connector *intel_connector; |
| 2965 | struct drm_encoder *encoder; |
| 2966 | |
| 2967 | encoder = &intel_encoder->base; |
| 2968 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2969 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2970 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2971 | struct drm_connector *connector = &intel_connector->base; |
| 2972 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2973 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2974 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2975 | drm_get_connector_status_name(connector->status)); |
| 2976 | if (connector->status == connector_status_connected) { |
| 2977 | struct drm_display_mode *mode = &crtc->mode; |
| 2978 | seq_printf(m, ", mode:\n"); |
| 2979 | intel_seq_print_mode(m, 2, mode); |
| 2980 | } else { |
| 2981 | seq_putc(m, '\n'); |
| 2982 | } |
| 2983 | } |
| 2984 | } |
| 2985 | |
| 2986 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2987 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2988 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2989 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2990 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2991 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2992 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2993 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2994 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2995 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2996 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2997 | fb->base.id, plane_state->src_x >> 16, |
| 2998 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2999 | else |
| 3000 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3001 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 3002 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 3003 | } |
| 3004 | |
| 3005 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 3006 | { |
| 3007 | struct drm_display_mode *mode = panel->fixed_mode; |
| 3008 | |
| 3009 | seq_printf(m, "\tfixed mode:\n"); |
| 3010 | intel_seq_print_mode(m, 2, mode); |
| 3011 | } |
| 3012 | |
| 3013 | static void intel_dp_info(struct seq_file *m, |
| 3014 | struct intel_connector *intel_connector) |
| 3015 | { |
| 3016 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3017 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 3018 | |
| 3019 | 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] | 3020 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3021 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3022 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 3023 | |
| 3024 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 3025 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3026 | } |
| 3027 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3028 | static void intel_dp_mst_info(struct seq_file *m, |
| 3029 | struct intel_connector *intel_connector) |
| 3030 | { |
| 3031 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3032 | struct intel_dp_mst_encoder *intel_mst = |
| 3033 | enc_to_mst(&intel_encoder->base); |
| 3034 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 3035 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 3036 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 3037 | intel_connector->port); |
| 3038 | |
| 3039 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 3040 | } |
| 3041 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3042 | static void intel_hdmi_info(struct seq_file *m, |
| 3043 | struct intel_connector *intel_connector) |
| 3044 | { |
| 3045 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 3046 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 3047 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 3048 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3049 | } |
| 3050 | |
| 3051 | static void intel_lvds_info(struct seq_file *m, |
| 3052 | struct intel_connector *intel_connector) |
| 3053 | { |
| 3054 | intel_panel_info(m, &intel_connector->panel); |
| 3055 | } |
| 3056 | |
| 3057 | static void intel_connector_info(struct seq_file *m, |
| 3058 | struct drm_connector *connector) |
| 3059 | { |
| 3060 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 3061 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3062 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3063 | |
| 3064 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 3065 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3066 | drm_get_connector_status_name(connector->status)); |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame^] | 3067 | |
| 3068 | if (connector->status == connector_status_disconnected) |
| 3069 | return; |
| 3070 | |
| 3071 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 3072 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 3073 | connector->display_info.width_mm, |
| 3074 | connector->display_info.height_mm); |
| 3075 | seq_printf(m, "\tsubpixel order: %s\n", |
| 3076 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 3077 | seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3078 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 3079 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3080 | return; |
| 3081 | |
| 3082 | switch (connector->connector_type) { |
| 3083 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 3084 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 3085 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3086 | intel_dp_mst_info(m, intel_connector); |
| 3087 | else |
| 3088 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3089 | break; |
| 3090 | case DRM_MODE_CONNECTOR_LVDS: |
| 3091 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3092 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3093 | break; |
| 3094 | case DRM_MODE_CONNECTOR_HDMIA: |
| 3095 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 3096 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3097 | intel_hdmi_info(m, intel_connector); |
| 3098 | break; |
| 3099 | default: |
| 3100 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3101 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3102 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3103 | seq_printf(m, "\tmodes:\n"); |
| 3104 | list_for_each_entry(mode, &connector->modes, head) |
| 3105 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3106 | } |
| 3107 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3108 | static const char *plane_type(enum drm_plane_type type) |
| 3109 | { |
| 3110 | switch (type) { |
| 3111 | case DRM_PLANE_TYPE_OVERLAY: |
| 3112 | return "OVL"; |
| 3113 | case DRM_PLANE_TYPE_PRIMARY: |
| 3114 | return "PRI"; |
| 3115 | case DRM_PLANE_TYPE_CURSOR: |
| 3116 | return "CUR"; |
| 3117 | /* |
| 3118 | * Deliberately omitting default: to generate compiler warnings |
| 3119 | * when a new drm_plane_type gets added. |
| 3120 | */ |
| 3121 | } |
| 3122 | |
| 3123 | return "unknown"; |
| 3124 | } |
| 3125 | |
| 3126 | static const char *plane_rotation(unsigned int rotation) |
| 3127 | { |
| 3128 | static char buf[48]; |
| 3129 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 3130 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3131 | * will print them all to visualize if the values are misused |
| 3132 | */ |
| 3133 | snprintf(buf, sizeof(buf), |
| 3134 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 3135 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 3136 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 3137 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 3138 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 3139 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 3140 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3141 | rotation); |
| 3142 | |
| 3143 | return buf; |
| 3144 | } |
| 3145 | |
| 3146 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3147 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3148 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3149 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3150 | struct intel_plane *intel_plane; |
| 3151 | |
| 3152 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3153 | struct drm_plane_state *state; |
| 3154 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3155 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3156 | |
| 3157 | if (!plane->state) { |
| 3158 | seq_puts(m, "plane->state is NULL!\n"); |
| 3159 | continue; |
| 3160 | } |
| 3161 | |
| 3162 | state = plane->state; |
| 3163 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3164 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 3165 | drm_get_format_name(state->fb->format->format, |
| 3166 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3167 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3168 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3169 | } |
| 3170 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3171 | 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", |
| 3172 | plane->base.id, |
| 3173 | plane_type(intel_plane->base.type), |
| 3174 | state->crtc_x, state->crtc_y, |
| 3175 | state->crtc_w, state->crtc_h, |
| 3176 | (state->src_x >> 16), |
| 3177 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3178 | (state->src_y >> 16), |
| 3179 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3180 | (state->src_w >> 16), |
| 3181 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3182 | (state->src_h >> 16), |
| 3183 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3184 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3185 | plane_rotation(state->rotation)); |
| 3186 | } |
| 3187 | } |
| 3188 | |
| 3189 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3190 | { |
| 3191 | struct intel_crtc_state *pipe_config; |
| 3192 | int num_scalers = intel_crtc->num_scalers; |
| 3193 | int i; |
| 3194 | |
| 3195 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3196 | |
| 3197 | /* Not all platformas have a scaler */ |
| 3198 | if (num_scalers) { |
| 3199 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3200 | num_scalers, |
| 3201 | pipe_config->scaler_state.scaler_users, |
| 3202 | pipe_config->scaler_state.scaler_id); |
| 3203 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3204 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3205 | struct intel_scaler *sc = |
| 3206 | &pipe_config->scaler_state.scalers[i]; |
| 3207 | |
| 3208 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3209 | i, yesno(sc->in_use), sc->mode); |
| 3210 | } |
| 3211 | seq_puts(m, "\n"); |
| 3212 | } else { |
| 3213 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3214 | } |
| 3215 | } |
| 3216 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3217 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3218 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3219 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3220 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3221 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3222 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3223 | struct drm_connector_list_iter conn_iter; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3224 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3225 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3226 | seq_printf(m, "CRTC info\n"); |
| 3227 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3228 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3229 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3230 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3231 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3232 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3233 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3234 | 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] | 3235 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3236 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3237 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3238 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3239 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3240 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3241 | struct intel_plane *cursor = |
| 3242 | to_intel_plane(crtc->base.cursor); |
| 3243 | |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3244 | intel_crtc_info(m, crtc); |
| 3245 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3246 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3247 | yesno(cursor->base.state->visible), |
| 3248 | cursor->base.state->crtc_x, |
| 3249 | cursor->base.state->crtc_y, |
| 3250 | cursor->base.state->crtc_w, |
| 3251 | cursor->base.state->crtc_h, |
| 3252 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3253 | intel_scaler_info(m, crtc); |
| 3254 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3255 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3256 | |
| 3257 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3258 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3259 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3260 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3261 | } |
| 3262 | |
| 3263 | seq_printf(m, "\n"); |
| 3264 | seq_printf(m, "Connector info\n"); |
| 3265 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3266 | mutex_lock(&dev->mode_config.mutex); |
| 3267 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3268 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3269 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3270 | drm_connector_list_iter_end(&conn_iter); |
| 3271 | mutex_unlock(&dev->mode_config.mutex); |
| 3272 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3273 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3274 | |
| 3275 | return 0; |
| 3276 | } |
| 3277 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3278 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3279 | { |
| 3280 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3281 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3282 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3283 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3284 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3285 | intel_runtime_pm_get(dev_priv); |
| 3286 | |
Chris Wilson | 6f56103 | 2018-01-24 11:36:07 +0000 | [diff] [blame] | 3287 | seq_printf(m, "GT awake? %s (epoch %u)\n", |
| 3288 | yesno(dev_priv->gt.awake), dev_priv->gt.epoch); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3289 | seq_printf(m, "Global active requests: %d\n", |
| 3290 | dev_priv->gt.active_requests); |
Lionel Landwerlin | f577a03 | 2017-11-13 23:34:53 +0000 | [diff] [blame] | 3291 | seq_printf(m, "CS timestamp frequency: %u kHz\n", |
| 3292 | dev_priv->info.cs_timestamp_frequency_khz); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3293 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3294 | p = drm_seq_file_printer(m); |
| 3295 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 0db18b1 | 2017-12-08 01:23:00 +0000 | [diff] [blame] | 3296 | intel_engine_dump(engine, &p, "%s\n", engine->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3297 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3298 | intel_runtime_pm_put(dev_priv); |
| 3299 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3300 | return 0; |
| 3301 | } |
| 3302 | |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3303 | static int i915_rcs_topology(struct seq_file *m, void *unused) |
| 3304 | { |
| 3305 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3306 | struct drm_printer p = drm_seq_file_printer(m); |
| 3307 | |
| 3308 | intel_device_info_dump_topology(&INTEL_INFO(dev_priv)->sseu, &p); |
| 3309 | |
| 3310 | return 0; |
| 3311 | } |
| 3312 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3313 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3314 | { |
| 3315 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3316 | |
| 3317 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3318 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3319 | |
| 3320 | return 0; |
| 3321 | } |
| 3322 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3323 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3324 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3325 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3326 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3327 | int i; |
| 3328 | |
| 3329 | drm_modeset_lock_all(dev); |
| 3330 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3331 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3332 | |
Lucas De Marchi | 72f775f | 2018-03-20 15:06:34 -0700 | [diff] [blame] | 3333 | 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] | 3334 | pll->info->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3335 | 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] | 3336 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3337 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3338 | 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] | 3339 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3340 | pll->state.hw_state.dpll_md); |
| 3341 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3342 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3343 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Paulo Zanoni | c27e917 | 2018-04-27 16:14:36 -0700 | [diff] [blame] | 3344 | seq_printf(m, " cfgcr0: 0x%08x\n", pll->state.hw_state.cfgcr0); |
| 3345 | seq_printf(m, " cfgcr1: 0x%08x\n", pll->state.hw_state.cfgcr1); |
| 3346 | seq_printf(m, " mg_refclkin_ctl: 0x%08x\n", |
| 3347 | pll->state.hw_state.mg_refclkin_ctl); |
| 3348 | seq_printf(m, " mg_clktop2_coreclkctl1: 0x%08x\n", |
| 3349 | pll->state.hw_state.mg_clktop2_coreclkctl1); |
| 3350 | seq_printf(m, " mg_clktop2_hsclkctl: 0x%08x\n", |
| 3351 | pll->state.hw_state.mg_clktop2_hsclkctl); |
| 3352 | seq_printf(m, " mg_pll_div0: 0x%08x\n", |
| 3353 | pll->state.hw_state.mg_pll_div0); |
| 3354 | seq_printf(m, " mg_pll_div1: 0x%08x\n", |
| 3355 | pll->state.hw_state.mg_pll_div1); |
| 3356 | seq_printf(m, " mg_pll_lf: 0x%08x\n", |
| 3357 | pll->state.hw_state.mg_pll_lf); |
| 3358 | seq_printf(m, " mg_pll_frac_lock: 0x%08x\n", |
| 3359 | pll->state.hw_state.mg_pll_frac_lock); |
| 3360 | seq_printf(m, " mg_pll_ssc: 0x%08x\n", |
| 3361 | pll->state.hw_state.mg_pll_ssc); |
| 3362 | seq_printf(m, " mg_pll_bias: 0x%08x\n", |
| 3363 | pll->state.hw_state.mg_pll_bias); |
| 3364 | seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", |
| 3365 | pll->state.hw_state.mg_pll_tdc_coldst_bias); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3366 | } |
| 3367 | drm_modeset_unlock_all(dev); |
| 3368 | |
| 3369 | return 0; |
| 3370 | } |
| 3371 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3372 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3373 | { |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3374 | struct i915_workarounds *wa = &node_to_i915(m->private)->workarounds; |
Chris Wilson | f4ecfbf | 2018-04-14 13:27:54 +0100 | [diff] [blame] | 3375 | int i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3376 | |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3377 | seq_printf(m, "Workarounds applied: %d\n", wa->count); |
| 3378 | for (i = 0; i < wa->count; ++i) |
| 3379 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n", |
| 3380 | wa->reg[i].addr, wa->reg[i].value, wa->reg[i].mask); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3381 | |
| 3382 | return 0; |
| 3383 | } |
| 3384 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3385 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3386 | { |
| 3387 | struct drm_i915_private *dev_priv = m->private; |
| 3388 | |
| 3389 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3390 | yesno(dev_priv->ipc_enabled)); |
| 3391 | return 0; |
| 3392 | } |
| 3393 | |
| 3394 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3395 | { |
| 3396 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3397 | |
| 3398 | if (!HAS_IPC(dev_priv)) |
| 3399 | return -ENODEV; |
| 3400 | |
| 3401 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3402 | } |
| 3403 | |
| 3404 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3405 | size_t len, loff_t *offp) |
| 3406 | { |
| 3407 | struct seq_file *m = file->private_data; |
| 3408 | struct drm_i915_private *dev_priv = m->private; |
| 3409 | int ret; |
| 3410 | bool enable; |
| 3411 | |
| 3412 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3413 | if (ret < 0) |
| 3414 | return ret; |
| 3415 | |
| 3416 | intel_runtime_pm_get(dev_priv); |
| 3417 | if (!dev_priv->ipc_enabled && enable) |
| 3418 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3419 | dev_priv->wm.distrust_bios_wm = true; |
| 3420 | dev_priv->ipc_enabled = enable; |
| 3421 | intel_enable_ipc(dev_priv); |
| 3422 | intel_runtime_pm_put(dev_priv); |
| 3423 | |
| 3424 | return len; |
| 3425 | } |
| 3426 | |
| 3427 | static const struct file_operations i915_ipc_status_fops = { |
| 3428 | .owner = THIS_MODULE, |
| 3429 | .open = i915_ipc_status_open, |
| 3430 | .read = seq_read, |
| 3431 | .llseek = seq_lseek, |
| 3432 | .release = single_release, |
| 3433 | .write = i915_ipc_status_write |
| 3434 | }; |
| 3435 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3436 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3437 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3438 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3439 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3440 | struct skl_ddb_allocation *ddb; |
| 3441 | struct skl_ddb_entry *entry; |
| 3442 | enum pipe pipe; |
| 3443 | int plane; |
| 3444 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3445 | if (INTEL_GEN(dev_priv) < 9) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 3446 | return -ENODEV; |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3447 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3448 | drm_modeset_lock_all(dev); |
| 3449 | |
| 3450 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3451 | |
| 3452 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3453 | |
| 3454 | for_each_pipe(dev_priv, pipe) { |
| 3455 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3456 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3457 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3458 | entry = &ddb->plane[pipe][plane]; |
| 3459 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3460 | entry->start, entry->end, |
| 3461 | skl_ddb_entry_size(entry)); |
| 3462 | } |
| 3463 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3464 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3465 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3466 | entry->end, skl_ddb_entry_size(entry)); |
| 3467 | } |
| 3468 | |
| 3469 | drm_modeset_unlock_all(dev); |
| 3470 | |
| 3471 | return 0; |
| 3472 | } |
| 3473 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3474 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3475 | struct drm_device *dev, |
| 3476 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3477 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3478 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3479 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3480 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3481 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3482 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3483 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3484 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3485 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3486 | if (connector->state->crtc != &intel_crtc->base) |
| 3487 | continue; |
| 3488 | |
| 3489 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3490 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3491 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3492 | |
| 3493 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3494 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3495 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3496 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3497 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3498 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3499 | else |
| 3500 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3501 | |
| 3502 | seq_puts(m, "\n\n"); |
| 3503 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3504 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3505 | struct intel_panel *panel; |
| 3506 | |
| 3507 | mutex_lock(&drrs->mutex); |
| 3508 | /* DRRS Supported */ |
| 3509 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3510 | |
| 3511 | /* disable_drrs() will make drrs->dp NULL */ |
| 3512 | if (!drrs->dp) { |
C, Ramalingam | ce6e213 | 2017-11-20 09:53:47 +0530 | [diff] [blame] | 3513 | seq_puts(m, "Idleness DRRS: Disabled\n"); |
| 3514 | if (dev_priv->psr.enabled) |
| 3515 | seq_puts(m, |
| 3516 | "\tAs PSR is enabled, DRRS is not enabled\n"); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3517 | mutex_unlock(&drrs->mutex); |
| 3518 | return; |
| 3519 | } |
| 3520 | |
| 3521 | panel = &drrs->dp->attached_connector->panel; |
| 3522 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3523 | drrs->busy_frontbuffer_bits); |
| 3524 | |
| 3525 | seq_puts(m, "\n\t\t"); |
| 3526 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3527 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3528 | vrefresh = panel->fixed_mode->vrefresh; |
| 3529 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3530 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3531 | vrefresh = panel->downclock_mode->vrefresh; |
| 3532 | } else { |
| 3533 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3534 | drrs->refresh_rate_type); |
| 3535 | mutex_unlock(&drrs->mutex); |
| 3536 | return; |
| 3537 | } |
| 3538 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3539 | |
| 3540 | seq_puts(m, "\n\t\t"); |
| 3541 | mutex_unlock(&drrs->mutex); |
| 3542 | } else { |
| 3543 | /* DRRS not supported. Print the VBT parameter*/ |
| 3544 | seq_puts(m, "\tDRRS Supported : No"); |
| 3545 | } |
| 3546 | seq_puts(m, "\n"); |
| 3547 | } |
| 3548 | |
| 3549 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3550 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3551 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3552 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3553 | struct intel_crtc *intel_crtc; |
| 3554 | int active_crtc_cnt = 0; |
| 3555 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3556 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3557 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3558 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3559 | active_crtc_cnt++; |
| 3560 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3561 | |
| 3562 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3563 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3564 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3565 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3566 | |
| 3567 | if (!active_crtc_cnt) |
| 3568 | seq_puts(m, "No active crtc found\n"); |
| 3569 | |
| 3570 | return 0; |
| 3571 | } |
| 3572 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3573 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3574 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3575 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3576 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3577 | struct intel_encoder *intel_encoder; |
| 3578 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3579 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3580 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3581 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3582 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3583 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3584 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3585 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3586 | |
| 3587 | intel_encoder = intel_attached_encoder(connector); |
| 3588 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3589 | continue; |
| 3590 | |
| 3591 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3592 | if (!intel_dig_port->dp.can_mst) |
| 3593 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3594 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3595 | seq_printf(m, "MST Source Port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3596 | port_name(intel_dig_port->base.port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3597 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3598 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3599 | drm_connector_list_iter_end(&conn_iter); |
| 3600 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3601 | return 0; |
| 3602 | } |
| 3603 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3604 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3605 | const char __user *ubuf, |
| 3606 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3607 | { |
| 3608 | char *input_buffer; |
| 3609 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3610 | struct drm_device *dev; |
| 3611 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3612 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3613 | struct intel_dp *intel_dp; |
| 3614 | int val = 0; |
| 3615 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3616 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3617 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3618 | if (len == 0) |
| 3619 | return 0; |
| 3620 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3621 | input_buffer = memdup_user_nul(ubuf, len); |
| 3622 | if (IS_ERR(input_buffer)) |
| 3623 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3624 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3625 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3626 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3627 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3628 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3629 | struct intel_encoder *encoder; |
| 3630 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3631 | if (connector->connector_type != |
| 3632 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3633 | continue; |
| 3634 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3635 | encoder = to_intel_encoder(connector->encoder); |
| 3636 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3637 | continue; |
| 3638 | |
| 3639 | if (encoder && connector->status == connector_status_connected) { |
| 3640 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3641 | status = kstrtoint(input_buffer, 10, &val); |
| 3642 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3643 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3644 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3645 | /* To prevent erroneous activation of the compliance |
| 3646 | * testing code, only accept an actual value of 1 here |
| 3647 | */ |
| 3648 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3649 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3650 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3651 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3652 | } |
| 3653 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3654 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3655 | kfree(input_buffer); |
| 3656 | if (status < 0) |
| 3657 | return status; |
| 3658 | |
| 3659 | *offp += len; |
| 3660 | return len; |
| 3661 | } |
| 3662 | |
| 3663 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3664 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3665 | struct drm_i915_private *dev_priv = m->private; |
| 3666 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3667 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3668 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3669 | struct intel_dp *intel_dp; |
| 3670 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3671 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3672 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3673 | struct intel_encoder *encoder; |
| 3674 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3675 | if (connector->connector_type != |
| 3676 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3677 | continue; |
| 3678 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3679 | encoder = to_intel_encoder(connector->encoder); |
| 3680 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3681 | continue; |
| 3682 | |
| 3683 | if (encoder && connector->status == connector_status_connected) { |
| 3684 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3685 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3686 | seq_puts(m, "1"); |
| 3687 | else |
| 3688 | seq_puts(m, "0"); |
| 3689 | } else |
| 3690 | seq_puts(m, "0"); |
| 3691 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3692 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3693 | |
| 3694 | return 0; |
| 3695 | } |
| 3696 | |
| 3697 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3698 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3699 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3700 | return single_open(file, i915_displayport_test_active_show, |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3701 | inode->i_private); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3702 | } |
| 3703 | |
| 3704 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3705 | .owner = THIS_MODULE, |
| 3706 | .open = i915_displayport_test_active_open, |
| 3707 | .read = seq_read, |
| 3708 | .llseek = seq_lseek, |
| 3709 | .release = single_release, |
| 3710 | .write = i915_displayport_test_active_write |
| 3711 | }; |
| 3712 | |
| 3713 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3714 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3715 | struct drm_i915_private *dev_priv = m->private; |
| 3716 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3717 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3718 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3719 | struct intel_dp *intel_dp; |
| 3720 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3721 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3722 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3723 | struct intel_encoder *encoder; |
| 3724 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3725 | if (connector->connector_type != |
| 3726 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3727 | continue; |
| 3728 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3729 | encoder = to_intel_encoder(connector->encoder); |
| 3730 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3731 | continue; |
| 3732 | |
| 3733 | if (encoder && connector->status == connector_status_connected) { |
| 3734 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3735 | if (intel_dp->compliance.test_type == |
| 3736 | DP_TEST_LINK_EDID_READ) |
| 3737 | seq_printf(m, "%lx", |
| 3738 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3739 | else if (intel_dp->compliance.test_type == |
| 3740 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3741 | seq_printf(m, "hdisplay: %d\n", |
| 3742 | intel_dp->compliance.test_data.hdisplay); |
| 3743 | seq_printf(m, "vdisplay: %d\n", |
| 3744 | intel_dp->compliance.test_data.vdisplay); |
| 3745 | seq_printf(m, "bpc: %u\n", |
| 3746 | intel_dp->compliance.test_data.bpc); |
| 3747 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3748 | } else |
| 3749 | seq_puts(m, "0"); |
| 3750 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3751 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3752 | |
| 3753 | return 0; |
| 3754 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3755 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3756 | |
| 3757 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3758 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3759 | struct drm_i915_private *dev_priv = m->private; |
| 3760 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3761 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3762 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3763 | struct intel_dp *intel_dp; |
| 3764 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3765 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3766 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3767 | struct intel_encoder *encoder; |
| 3768 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3769 | if (connector->connector_type != |
| 3770 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3771 | continue; |
| 3772 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3773 | encoder = to_intel_encoder(connector->encoder); |
| 3774 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3775 | continue; |
| 3776 | |
| 3777 | if (encoder && connector->status == connector_status_connected) { |
| 3778 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3779 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3780 | } else |
| 3781 | seq_puts(m, "0"); |
| 3782 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3783 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3784 | |
| 3785 | return 0; |
| 3786 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3787 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3788 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3789 | 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] | 3790 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3791 | struct drm_i915_private *dev_priv = m->private; |
| 3792 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3793 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3794 | int num_levels; |
| 3795 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3796 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3797 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3798 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3799 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3800 | else if (IS_G4X(dev_priv)) |
| 3801 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3802 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3803 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3804 | |
| 3805 | drm_modeset_lock_all(dev); |
| 3806 | |
| 3807 | for (level = 0; level < num_levels; level++) { |
| 3808 | unsigned int latency = wm[level]; |
| 3809 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3810 | /* |
| 3811 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3812 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3813 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3814 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3815 | IS_VALLEYVIEW(dev_priv) || |
| 3816 | IS_CHERRYVIEW(dev_priv) || |
| 3817 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3818 | latency *= 10; |
| 3819 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3820 | latency *= 5; |
| 3821 | |
| 3822 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3823 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3824 | } |
| 3825 | |
| 3826 | drm_modeset_unlock_all(dev); |
| 3827 | } |
| 3828 | |
| 3829 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3830 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3831 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3832 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3833 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3834 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3835 | latencies = dev_priv->wm.skl_latency; |
| 3836 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3837 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3838 | |
| 3839 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3840 | |
| 3841 | return 0; |
| 3842 | } |
| 3843 | |
| 3844 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3845 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3846 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3847 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3848 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3849 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3850 | latencies = dev_priv->wm.skl_latency; |
| 3851 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3852 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3853 | |
| 3854 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3855 | |
| 3856 | return 0; |
| 3857 | } |
| 3858 | |
| 3859 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3860 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3861 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3862 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3863 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3864 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3865 | latencies = dev_priv->wm.skl_latency; |
| 3866 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3867 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3868 | |
| 3869 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3870 | |
| 3871 | return 0; |
| 3872 | } |
| 3873 | |
| 3874 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3875 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3876 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3877 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3878 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3879 | return -ENODEV; |
| 3880 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3881 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3882 | } |
| 3883 | |
| 3884 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3885 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3886 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3887 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3888 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3889 | return -ENODEV; |
| 3890 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3891 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3892 | } |
| 3893 | |
| 3894 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3895 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3896 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3897 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3898 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3899 | return -ENODEV; |
| 3900 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3901 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | 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] | 3905 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3906 | { |
| 3907 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3908 | struct drm_i915_private *dev_priv = m->private; |
| 3909 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3910 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3911 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3912 | int level; |
| 3913 | int ret; |
| 3914 | char tmp[32]; |
| 3915 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3916 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3917 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3918 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3919 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3920 | else if (IS_G4X(dev_priv)) |
| 3921 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3922 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3923 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3924 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3925 | if (len >= sizeof(tmp)) |
| 3926 | return -EINVAL; |
| 3927 | |
| 3928 | if (copy_from_user(tmp, ubuf, len)) |
| 3929 | return -EFAULT; |
| 3930 | |
| 3931 | tmp[len] = '\0'; |
| 3932 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3933 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3934 | &new[0], &new[1], &new[2], &new[3], |
| 3935 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3936 | if (ret != num_levels) |
| 3937 | return -EINVAL; |
| 3938 | |
| 3939 | drm_modeset_lock_all(dev); |
| 3940 | |
| 3941 | for (level = 0; level < num_levels; level++) |
| 3942 | wm[level] = new[level]; |
| 3943 | |
| 3944 | drm_modeset_unlock_all(dev); |
| 3945 | |
| 3946 | return len; |
| 3947 | } |
| 3948 | |
| 3949 | |
| 3950 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3951 | size_t len, loff_t *offp) |
| 3952 | { |
| 3953 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3954 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3955 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3956 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3957 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3958 | latencies = dev_priv->wm.skl_latency; |
| 3959 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3960 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3961 | |
| 3962 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3963 | } |
| 3964 | |
| 3965 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3966 | size_t len, loff_t *offp) |
| 3967 | { |
| 3968 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3969 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3970 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3971 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3972 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3973 | latencies = dev_priv->wm.skl_latency; |
| 3974 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3975 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3976 | |
| 3977 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3978 | } |
| 3979 | |
| 3980 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3981 | size_t len, loff_t *offp) |
| 3982 | { |
| 3983 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3984 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3985 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3986 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3987 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3988 | latencies = dev_priv->wm.skl_latency; |
| 3989 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3990 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3991 | |
| 3992 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3993 | } |
| 3994 | |
| 3995 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3996 | .owner = THIS_MODULE, |
| 3997 | .open = pri_wm_latency_open, |
| 3998 | .read = seq_read, |
| 3999 | .llseek = seq_lseek, |
| 4000 | .release = single_release, |
| 4001 | .write = pri_wm_latency_write |
| 4002 | }; |
| 4003 | |
| 4004 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4005 | .owner = THIS_MODULE, |
| 4006 | .open = spr_wm_latency_open, |
| 4007 | .read = seq_read, |
| 4008 | .llseek = seq_lseek, |
| 4009 | .release = single_release, |
| 4010 | .write = spr_wm_latency_write |
| 4011 | }; |
| 4012 | |
| 4013 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4014 | .owner = THIS_MODULE, |
| 4015 | .open = cur_wm_latency_open, |
| 4016 | .read = seq_read, |
| 4017 | .llseek = seq_lseek, |
| 4018 | .release = single_release, |
| 4019 | .write = cur_wm_latency_write |
| 4020 | }; |
| 4021 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4022 | static int |
| 4023 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4024 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4025 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4026 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4027 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4028 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4029 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4030 | } |
| 4031 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4032 | static int |
| 4033 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4034 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4035 | struct drm_i915_private *i915 = data; |
| 4036 | struct intel_engine_cs *engine; |
| 4037 | unsigned int tmp; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4038 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4039 | /* |
| 4040 | * There is no safeguard against this debugfs entry colliding |
| 4041 | * with the hangcheck calling same i915_handle_error() in |
| 4042 | * parallel, causing an explosion. For now we assume that the |
| 4043 | * test harness is responsible enough not to inject gpu hangs |
| 4044 | * while it is writing to 'i915_wedged' |
| 4045 | */ |
| 4046 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4047 | if (i915_reset_backoff(&i915->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4048 | return -EAGAIN; |
| 4049 | |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4050 | for_each_engine_masked(engine, i915, val, tmp) { |
| 4051 | engine->hangcheck.seqno = intel_engine_get_seqno(engine); |
| 4052 | engine->hangcheck.stalled = true; |
| 4053 | } |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4054 | |
Chris Wilson | ce80075 | 2018-03-20 10:04:49 +0000 | [diff] [blame] | 4055 | i915_handle_error(i915, val, I915_ERROR_CAPTURE, |
| 4056 | "Manually set wedged engine mask = %llx", val); |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 4057 | |
| 4058 | wait_on_bit(&i915->gpu_error.flags, |
Chris Wilson | d3df42b | 2017-03-16 17:13:05 +0000 | [diff] [blame] | 4059 | I915_RESET_HANDOFF, |
| 4060 | TASK_UNINTERRUPTIBLE); |
| 4061 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4062 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4063 | } |
| 4064 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4065 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4066 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4067 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4068 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4069 | static int |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4070 | fault_irq_set(struct drm_i915_private *i915, |
| 4071 | unsigned long *irq, |
| 4072 | unsigned long val) |
| 4073 | { |
| 4074 | int err; |
| 4075 | |
| 4076 | err = mutex_lock_interruptible(&i915->drm.struct_mutex); |
| 4077 | if (err) |
| 4078 | return err; |
| 4079 | |
| 4080 | err = i915_gem_wait_for_idle(i915, |
| 4081 | I915_WAIT_LOCKED | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 4082 | I915_WAIT_INTERRUPTIBLE, |
| 4083 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4084 | if (err) |
| 4085 | goto err_unlock; |
| 4086 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4087 | *irq = val; |
| 4088 | mutex_unlock(&i915->drm.struct_mutex); |
| 4089 | |
| 4090 | /* Flush idle worker to disarm irq */ |
Chris Wilson | 7c26240 | 2017-10-06 11:40:38 +0100 | [diff] [blame] | 4091 | drain_delayed_work(&i915->gt.idle_work); |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4092 | |
| 4093 | return 0; |
| 4094 | |
| 4095 | err_unlock: |
| 4096 | mutex_unlock(&i915->drm.struct_mutex); |
| 4097 | return err; |
| 4098 | } |
| 4099 | |
| 4100 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4101 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4102 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4103 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4104 | |
| 4105 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4106 | return 0; |
| 4107 | } |
| 4108 | |
| 4109 | static int |
| 4110 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4111 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4112 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4113 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4114 | return fault_irq_set(i915, &i915->gpu_error.missed_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4115 | } |
| 4116 | |
| 4117 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4118 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4119 | "0x%08llx\n"); |
| 4120 | |
| 4121 | static int |
| 4122 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4123 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4124 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4125 | |
| 4126 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4127 | |
| 4128 | return 0; |
| 4129 | } |
| 4130 | |
| 4131 | static int |
| 4132 | i915_ring_test_irq_set(void *data, u64 val) |
| 4133 | { |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4134 | struct drm_i915_private *i915 = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4135 | |
Chris Wilson | 5f52172 | 2018-09-07 12:28:51 +0100 | [diff] [blame] | 4136 | /* GuC keeps the user interrupt permanently enabled for submission */ |
| 4137 | if (USES_GUC_SUBMISSION(i915)) |
| 4138 | return -ENODEV; |
| 4139 | |
| 4140 | /* |
| 4141 | * From icl, we can no longer individually mask interrupt generation |
| 4142 | * from each engine. |
| 4143 | */ |
| 4144 | if (INTEL_GEN(i915) >= 11) |
| 4145 | return -ENODEV; |
| 4146 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4147 | val &= INTEL_INFO(i915)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4148 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4149 | |
Chris Wilson | 64486ae | 2017-03-07 15:59:08 +0000 | [diff] [blame] | 4150 | return fault_irq_set(i915, &i915->gpu_error.test_irq_rings, val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4151 | } |
| 4152 | |
| 4153 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4154 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4155 | "0x%08llx\n"); |
| 4156 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4157 | #define DROP_UNBOUND BIT(0) |
| 4158 | #define DROP_BOUND BIT(1) |
| 4159 | #define DROP_RETIRE BIT(2) |
| 4160 | #define DROP_ACTIVE BIT(3) |
| 4161 | #define DROP_FREED BIT(4) |
| 4162 | #define DROP_SHRINK_ALL BIT(5) |
| 4163 | #define DROP_IDLE BIT(6) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4164 | #define DROP_RESET_ACTIVE BIT(7) |
| 4165 | #define DROP_RESET_SEQNO BIT(8) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4166 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4167 | DROP_BOUND | \ |
| 4168 | DROP_RETIRE | \ |
| 4169 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4170 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4171 | DROP_SHRINK_ALL |\ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4172 | DROP_IDLE | \ |
| 4173 | DROP_RESET_ACTIVE | \ |
| 4174 | DROP_RESET_SEQNO) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4175 | static int |
| 4176 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4177 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4178 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4179 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4180 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4181 | } |
| 4182 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4183 | static int |
| 4184 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4185 | { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4186 | struct drm_i915_private *i915 = data; |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4187 | int ret = 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4188 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4189 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 4190 | val, val & DROP_ALL); |
Chris Wilson | 9d3eb2c | 2018-10-15 12:58:56 +0100 | [diff] [blame] | 4191 | intel_runtime_pm_get(i915); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4192 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4193 | if (val & DROP_RESET_ACTIVE && !intel_engines_are_idle(i915)) |
| 4194 | i915_gem_set_wedged(i915); |
| 4195 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4196 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4197 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4198 | if (val & (DROP_ACTIVE | DROP_RETIRE | DROP_RESET_SEQNO)) { |
| 4199 | ret = mutex_lock_interruptible(&i915->drm.struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4200 | if (ret) |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 4201 | goto out; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4202 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4203 | if (val & DROP_ACTIVE) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4204 | ret = i915_gem_wait_for_idle(i915, |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4205 | I915_WAIT_INTERRUPTIBLE | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 4206 | I915_WAIT_LOCKED, |
| 4207 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4208 | |
Chris Wilson | 9d3eb2c | 2018-10-15 12:58:56 +0100 | [diff] [blame] | 4209 | if (ret == 0 && val & DROP_RESET_SEQNO) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4210 | ret = i915_gem_set_global_seqno(&i915->drm, 1); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4211 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4212 | if (val & DROP_RETIRE) |
| 4213 | i915_retire_requests(i915); |
| 4214 | |
| 4215 | mutex_unlock(&i915->drm.struct_mutex); |
| 4216 | } |
| 4217 | |
| 4218 | if (val & DROP_RESET_ACTIVE && |
| 4219 | i915_terminally_wedged(&i915->gpu_error)) { |
| 4220 | i915_handle_error(i915, ALL_ENGINES, 0, NULL); |
| 4221 | wait_on_bit(&i915->gpu_error.flags, |
| 4222 | I915_RESET_HANDOFF, |
| 4223 | TASK_UNINTERRUPTIBLE); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 4224 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4225 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4226 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4227 | if (val & DROP_BOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4228 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4229 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4230 | if (val & DROP_UNBOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4231 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4232 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4233 | if (val & DROP_SHRINK_ALL) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4234 | i915_gem_shrink_all(i915); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 4235 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 4236 | |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 4237 | if (val & DROP_IDLE) { |
| 4238 | do { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4239 | if (READ_ONCE(i915->gt.active_requests)) |
| 4240 | flush_delayed_work(&i915->gt.retire_work); |
| 4241 | drain_delayed_work(&i915->gt.idle_work); |
| 4242 | } while (READ_ONCE(i915->gt.awake)); |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 4243 | } |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 4244 | |
Chris Wilson | c9c70471 | 2018-02-19 22:06:31 +0000 | [diff] [blame] | 4245 | if (val & DROP_FREED) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 4246 | i915_gem_drain_freed_objects(i915); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4247 | |
Joonas Lahtinen | 198a2a2 | 2018-10-18 12:20:25 +0300 | [diff] [blame] | 4248 | out: |
Chris Wilson | 9d3eb2c | 2018-10-15 12:58:56 +0100 | [diff] [blame] | 4249 | intel_runtime_pm_put(i915); |
| 4250 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4251 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4252 | } |
| 4253 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4254 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4255 | i915_drop_caches_get, i915_drop_caches_set, |
| 4256 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4257 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4258 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4259 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4260 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4261 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4262 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4263 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4264 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4265 | return -ENODEV; |
| 4266 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4267 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4268 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4269 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4270 | |
| 4271 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4272 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4273 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4274 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4275 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4276 | } |
| 4277 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4278 | static int |
| 4279 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4280 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4281 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4282 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4283 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4284 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4285 | return -ENODEV; |
| 4286 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4287 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4288 | return -EINVAL; |
| 4289 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4290 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4291 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4292 | |
| 4293 | /* Update the cache sharing policy here as well */ |
| 4294 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4295 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4296 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4297 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4298 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4299 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4300 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4301 | } |
| 4302 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4303 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4304 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4305 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4306 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4307 | static void cherryview_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) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4309 | { |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4310 | #define SS_MAX 2 |
| 4311 | const int ss_max = SS_MAX; |
| 4312 | u32 sig1[SS_MAX], sig2[SS_MAX]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4313 | int ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4314 | |
| 4315 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4316 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4317 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4318 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4319 | |
| 4320 | for (ss = 0; ss < ss_max; ss++) { |
| 4321 | unsigned int eu_cnt; |
| 4322 | |
| 4323 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4324 | /* skip disabled subslice */ |
| 4325 | continue; |
| 4326 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4327 | sseu->slice_mask = BIT(0); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4328 | sseu->subslice_mask[0] |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4329 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4330 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4331 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4332 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4333 | sseu->eu_total += eu_cnt; |
| 4334 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4335 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4336 | } |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4337 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4338 | } |
| 4339 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4340 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4341 | struct sseu_dev_info *sseu) |
| 4342 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4343 | #define SS_MAX 6 |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4344 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4345 | 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] | 4346 | int s, ss; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4347 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4348 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4349 | /* |
| 4350 | * FIXME: Valid SS Mask respects the spec and read |
| 4351 | * only valid bits for those registers, excluding reserverd |
| 4352 | * although this seems wrong because it would leave many |
| 4353 | * subslices without ACK. |
| 4354 | */ |
| 4355 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4356 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4357 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4358 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4359 | } |
| 4360 | |
| 4361 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4362 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4363 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4364 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4365 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4366 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4367 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4368 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4369 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4370 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4371 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4372 | /* skip disabled slice */ |
| 4373 | continue; |
| 4374 | |
| 4375 | sseu->slice_mask |= BIT(s); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4376 | sseu->subslice_mask[s] = info->sseu.subslice_mask[s]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4377 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4378 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4379 | unsigned int eu_cnt; |
| 4380 | |
| 4381 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4382 | /* skip disabled subslice */ |
| 4383 | continue; |
| 4384 | |
| 4385 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4386 | eu_mask[ss % 2]); |
| 4387 | sseu->eu_total += eu_cnt; |
| 4388 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4389 | sseu->eu_per_subslice, |
| 4390 | eu_cnt); |
| 4391 | } |
| 4392 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4393 | #undef SS_MAX |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4394 | } |
| 4395 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4396 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4397 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4398 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4399 | #define SS_MAX 3 |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4400 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4401 | 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] | 4402 | int s, ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4403 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4404 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4405 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4406 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4407 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4408 | } |
| 4409 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4410 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4411 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4412 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4413 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4414 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4415 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4416 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4417 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4418 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4419 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4420 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4421 | /* skip disabled slice */ |
| 4422 | continue; |
| 4423 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4424 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4425 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4426 | if (IS_GEN9_BC(dev_priv)) |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4427 | sseu->subslice_mask[s] = |
| 4428 | INTEL_INFO(dev_priv)->sseu.subslice_mask[s]; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4429 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4430 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4431 | unsigned int eu_cnt; |
| 4432 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4433 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4434 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4435 | /* skip disabled subslice */ |
| 4436 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4437 | |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4438 | sseu->subslice_mask[s] |= BIT(ss); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4439 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4440 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4441 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4442 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4443 | sseu->eu_total += eu_cnt; |
| 4444 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4445 | sseu->eu_per_subslice, |
| 4446 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4447 | } |
| 4448 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4449 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4450 | } |
| 4451 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4452 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4453 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4454 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4455 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4456 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4457 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4458 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4459 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4460 | if (sseu->slice_mask) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4461 | sseu->eu_per_subslice = |
| 4462 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4463 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4464 | sseu->subslice_mask[s] = |
| 4465 | INTEL_INFO(dev_priv)->sseu.subslice_mask[s]; |
| 4466 | } |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4467 | sseu->eu_total = sseu->eu_per_subslice * |
| 4468 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4469 | |
| 4470 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4471 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4472 | u8 subslice_7eu = |
| 4473 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4474 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4475 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4476 | } |
| 4477 | } |
| 4478 | } |
| 4479 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4480 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4481 | const struct sseu_dev_info *sseu) |
| 4482 | { |
| 4483 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4484 | const char *type = is_available_info ? "Available" : "Enabled"; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4485 | int s; |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4486 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4487 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4488 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4489 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4490 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4491 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4492 | sseu_subslice_total(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4493 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4494 | seq_printf(m, " %s Slice%i subslices: %u\n", type, |
| 4495 | s, hweight8(sseu->subslice_mask[s])); |
| 4496 | } |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4497 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4498 | sseu->eu_total); |
| 4499 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4500 | sseu->eu_per_subslice); |
| 4501 | |
| 4502 | if (!is_available_info) |
| 4503 | return; |
| 4504 | |
| 4505 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4506 | if (HAS_POOLED_EU(dev_priv)) |
| 4507 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4508 | |
| 4509 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4510 | yesno(sseu->has_slice_pg)); |
| 4511 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4512 | yesno(sseu->has_subslice_pg)); |
| 4513 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4514 | yesno(sseu->has_eu_pg)); |
| 4515 | } |
| 4516 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4517 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4518 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4519 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4520 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4521 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4522 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4523 | return -ENODEV; |
| 4524 | |
| 4525 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4526 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4527 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4528 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4529 | memset(&sseu, 0, sizeof(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4530 | sseu.max_slices = INTEL_INFO(dev_priv)->sseu.max_slices; |
| 4531 | sseu.max_subslices = INTEL_INFO(dev_priv)->sseu.max_subslices; |
| 4532 | sseu.max_eus_per_subslice = |
| 4533 | INTEL_INFO(dev_priv)->sseu.max_eus_per_subslice; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4534 | |
| 4535 | intel_runtime_pm_get(dev_priv); |
| 4536 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4537 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4538 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4539 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4540 | broadwell_sseu_device_status(dev_priv, &sseu); |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4541 | } else if (IS_GEN9(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4542 | gen9_sseu_device_status(dev_priv, &sseu); |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4543 | } else if (INTEL_GEN(dev_priv) >= 10) { |
| 4544 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4545 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4546 | |
| 4547 | intel_runtime_pm_put(dev_priv); |
| 4548 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4549 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4550 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4551 | return 0; |
| 4552 | } |
| 4553 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4554 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4555 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4556 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4557 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4558 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4559 | return 0; |
| 4560 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4561 | intel_runtime_pm_get(i915); |
| 4562 | intel_uncore_forcewake_user_get(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4563 | |
| 4564 | return 0; |
| 4565 | } |
| 4566 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4567 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4568 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4569 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4570 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4571 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4572 | return 0; |
| 4573 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4574 | intel_uncore_forcewake_user_put(i915); |
| 4575 | intel_runtime_pm_put(i915); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4576 | |
| 4577 | return 0; |
| 4578 | } |
| 4579 | |
| 4580 | static const struct file_operations i915_forcewake_fops = { |
| 4581 | .owner = THIS_MODULE, |
| 4582 | .open = i915_forcewake_open, |
| 4583 | .release = i915_forcewake_release, |
| 4584 | }; |
| 4585 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4586 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4587 | { |
| 4588 | struct drm_i915_private *dev_priv = m->private; |
| 4589 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4590 | |
| 4591 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4592 | seq_printf(m, "Detected: %s\n", |
| 4593 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4594 | |
| 4595 | return 0; |
| 4596 | } |
| 4597 | |
| 4598 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4599 | const char __user *ubuf, size_t len, |
| 4600 | loff_t *offp) |
| 4601 | { |
| 4602 | struct seq_file *m = file->private_data; |
| 4603 | struct drm_i915_private *dev_priv = m->private; |
| 4604 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4605 | unsigned int new_threshold; |
| 4606 | int i; |
| 4607 | char *newline; |
| 4608 | char tmp[16]; |
| 4609 | |
| 4610 | if (len >= sizeof(tmp)) |
| 4611 | return -EINVAL; |
| 4612 | |
| 4613 | if (copy_from_user(tmp, ubuf, len)) |
| 4614 | return -EFAULT; |
| 4615 | |
| 4616 | tmp[len] = '\0'; |
| 4617 | |
| 4618 | /* Strip newline, if any */ |
| 4619 | newline = strchr(tmp, '\n'); |
| 4620 | if (newline) |
| 4621 | *newline = '\0'; |
| 4622 | |
| 4623 | if (strcmp(tmp, "reset") == 0) |
| 4624 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4625 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4626 | return -EINVAL; |
| 4627 | |
| 4628 | if (new_threshold > 0) |
| 4629 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4630 | new_threshold); |
| 4631 | else |
| 4632 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4633 | |
| 4634 | spin_lock_irq(&dev_priv->irq_lock); |
| 4635 | hotplug->hpd_storm_threshold = new_threshold; |
| 4636 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4637 | for_each_hpd_pin(i) |
| 4638 | hotplug->stats[i].count = 0; |
| 4639 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4640 | |
| 4641 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4642 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4643 | |
| 4644 | return len; |
| 4645 | } |
| 4646 | |
| 4647 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4648 | { |
| 4649 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4650 | } |
| 4651 | |
| 4652 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4653 | .owner = THIS_MODULE, |
| 4654 | .open = i915_hpd_storm_ctl_open, |
| 4655 | .read = seq_read, |
| 4656 | .llseek = seq_lseek, |
| 4657 | .release = single_release, |
| 4658 | .write = i915_hpd_storm_ctl_write |
| 4659 | }; |
| 4660 | |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4661 | static int i915_drrs_ctl_set(void *data, u64 val) |
| 4662 | { |
| 4663 | struct drm_i915_private *dev_priv = data; |
| 4664 | struct drm_device *dev = &dev_priv->drm; |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4665 | struct intel_crtc *crtc; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4666 | |
| 4667 | if (INTEL_GEN(dev_priv) < 7) |
| 4668 | return -ENODEV; |
| 4669 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4670 | for_each_intel_crtc(dev, crtc) { |
| 4671 | struct drm_connector_list_iter conn_iter; |
| 4672 | struct intel_crtc_state *crtc_state; |
| 4673 | struct drm_connector *connector; |
| 4674 | struct drm_crtc_commit *commit; |
| 4675 | int ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4676 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4677 | ret = drm_modeset_lock_single_interruptible(&crtc->base.mutex); |
| 4678 | if (ret) |
| 4679 | return ret; |
| 4680 | |
| 4681 | crtc_state = to_intel_crtc_state(crtc->base.state); |
| 4682 | |
| 4683 | if (!crtc_state->base.active || |
| 4684 | !crtc_state->has_drrs) |
| 4685 | goto out; |
| 4686 | |
| 4687 | commit = crtc_state->base.commit; |
| 4688 | if (commit) { |
| 4689 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4690 | if (ret) |
| 4691 | goto out; |
| 4692 | } |
| 4693 | |
| 4694 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 4695 | drm_for_each_connector_iter(connector, &conn_iter) { |
| 4696 | struct intel_encoder *encoder; |
| 4697 | struct intel_dp *intel_dp; |
| 4698 | |
| 4699 | if (!(crtc_state->base.connector_mask & |
| 4700 | drm_connector_mask(connector))) |
| 4701 | continue; |
| 4702 | |
| 4703 | encoder = intel_attached_encoder(connector); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4704 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 4705 | continue; |
| 4706 | |
| 4707 | DRM_DEBUG_DRIVER("Manually %sabling DRRS. %llu\n", |
| 4708 | val ? "en" : "dis", val); |
| 4709 | |
| 4710 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 4711 | if (val) |
| 4712 | intel_edp_drrs_enable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4713 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4714 | else |
| 4715 | intel_edp_drrs_disable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4716 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4717 | } |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4718 | drm_connector_list_iter_end(&conn_iter); |
| 4719 | |
| 4720 | out: |
| 4721 | drm_modeset_unlock(&crtc->base.mutex); |
| 4722 | if (ret) |
| 4723 | return ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4724 | } |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4725 | |
| 4726 | return 0; |
| 4727 | } |
| 4728 | |
| 4729 | DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); |
| 4730 | |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4731 | static ssize_t |
| 4732 | i915_fifo_underrun_reset_write(struct file *filp, |
| 4733 | const char __user *ubuf, |
| 4734 | size_t cnt, loff_t *ppos) |
| 4735 | { |
| 4736 | struct drm_i915_private *dev_priv = filp->private_data; |
| 4737 | struct intel_crtc *intel_crtc; |
| 4738 | struct drm_device *dev = &dev_priv->drm; |
| 4739 | int ret; |
| 4740 | bool reset; |
| 4741 | |
| 4742 | ret = kstrtobool_from_user(ubuf, cnt, &reset); |
| 4743 | if (ret) |
| 4744 | return ret; |
| 4745 | |
| 4746 | if (!reset) |
| 4747 | return cnt; |
| 4748 | |
| 4749 | for_each_intel_crtc(dev, intel_crtc) { |
| 4750 | struct drm_crtc_commit *commit; |
| 4751 | struct intel_crtc_state *crtc_state; |
| 4752 | |
| 4753 | ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); |
| 4754 | if (ret) |
| 4755 | return ret; |
| 4756 | |
| 4757 | crtc_state = to_intel_crtc_state(intel_crtc->base.state); |
| 4758 | commit = crtc_state->base.commit; |
| 4759 | if (commit) { |
| 4760 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4761 | if (!ret) |
| 4762 | ret = wait_for_completion_interruptible(&commit->flip_done); |
| 4763 | } |
| 4764 | |
| 4765 | if (!ret && crtc_state->base.active) { |
| 4766 | DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", |
| 4767 | pipe_name(intel_crtc->pipe)); |
| 4768 | |
| 4769 | intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); |
| 4770 | } |
| 4771 | |
| 4772 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 4773 | |
| 4774 | if (ret) |
| 4775 | return ret; |
| 4776 | } |
| 4777 | |
| 4778 | ret = intel_fbc_reset_underrun(dev_priv); |
| 4779 | if (ret) |
| 4780 | return ret; |
| 4781 | |
| 4782 | return cnt; |
| 4783 | } |
| 4784 | |
| 4785 | static const struct file_operations i915_fifo_underrun_reset_ops = { |
| 4786 | .owner = THIS_MODULE, |
| 4787 | .open = simple_open, |
| 4788 | .write = i915_fifo_underrun_reset_write, |
| 4789 | .llseek = default_llseek, |
| 4790 | }; |
| 4791 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4792 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4793 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4794 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4795 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4796 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4797 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4798 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4799 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4800 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4801 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4802 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4803 | {"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] | 4804 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4805 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4806 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4807 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4808 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4809 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4810 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4811 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4812 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4813 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4814 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4815 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4816 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4817 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4818 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4819 | {"i915_context_status", i915_context_status, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4820 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4821 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4822 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4823 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4824 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4825 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4826 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4827 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4828 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4829 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4830 | {"i915_engine_info", i915_engine_info, 0}, |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 4831 | {"i915_rcs_topology", i915_rcs_topology, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4832 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4833 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4834 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4835 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4836 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4837 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4838 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4839 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4840 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4841 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4842 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4843 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4844 | const char *name; |
| 4845 | const struct file_operations *fops; |
| 4846 | } i915_debugfs_files[] = { |
| 4847 | {"i915_wedged", &i915_wedged_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4848 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4849 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4850 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4851 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4852 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4853 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4854 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4855 | #endif |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4856 | {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4857 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4858 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4859 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4860 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4861 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4862 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4863 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4864 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 4865 | {"i915_guc_log_level", &i915_guc_log_level_fops}, |
| 4866 | {"i915_guc_log_relay", &i915_guc_log_relay_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4867 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4868 | {"i915_ipc_status", &i915_ipc_status_fops}, |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4869 | {"i915_drrs_ctl", &i915_drrs_ctl_fops}, |
| 4870 | {"i915_edp_psr_debug", &i915_edp_psr_debug_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4871 | }; |
| 4872 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4873 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4874 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4875 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4876 | struct dentry *ent; |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 4877 | int i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4878 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4879 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4880 | minor->debugfs_root, to_i915(minor->dev), |
| 4881 | &i915_forcewake_fops); |
| 4882 | if (!ent) |
| 4883 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4884 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4885 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4886 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4887 | S_IRUGO | S_IWUSR, |
| 4888 | minor->debugfs_root, |
| 4889 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4890 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4891 | if (!ent) |
| 4892 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4893 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4894 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4895 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4896 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4897 | minor->debugfs_root, minor); |
| 4898 | } |
| 4899 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4900 | struct dpcd_block { |
| 4901 | /* DPCD dump start address. */ |
| 4902 | unsigned int offset; |
| 4903 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4904 | unsigned int end; |
| 4905 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4906 | size_t size; |
| 4907 | /* Only valid for eDP. */ |
| 4908 | bool edp; |
| 4909 | }; |
| 4910 | |
| 4911 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4912 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4913 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4914 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4915 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4916 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4917 | { .offset = DP_SET_POWER }, |
| 4918 | { .offset = DP_EDP_DPCD_REV }, |
| 4919 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4920 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4921 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4922 | }; |
| 4923 | |
| 4924 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4925 | { |
| 4926 | struct drm_connector *connector = m->private; |
| 4927 | struct intel_dp *intel_dp = |
| 4928 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4929 | uint8_t buf[16]; |
| 4930 | ssize_t err; |
| 4931 | int i; |
| 4932 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4933 | if (connector->status != connector_status_connected) |
| 4934 | return -ENODEV; |
| 4935 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4936 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4937 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4938 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4939 | |
| 4940 | if (b->edp && |
| 4941 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4942 | continue; |
| 4943 | |
| 4944 | /* low tech for now */ |
| 4945 | if (WARN_ON(size > sizeof(buf))) |
| 4946 | continue; |
| 4947 | |
| 4948 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
Chris Wilson | 65404c8 | 2018-10-10 09:17:06 +0100 | [diff] [blame] | 4949 | if (err < 0) |
| 4950 | seq_printf(m, "%04x: ERROR %d\n", b->offset, (int)err); |
| 4951 | else |
| 4952 | seq_printf(m, "%04x: %*ph\n", b->offset, (int)err, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4953 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4954 | |
| 4955 | return 0; |
| 4956 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4957 | DEFINE_SHOW_ATTRIBUTE(i915_dpcd); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4958 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4959 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4960 | { |
| 4961 | struct drm_connector *connector = m->private; |
| 4962 | struct intel_dp *intel_dp = |
| 4963 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4964 | |
| 4965 | if (connector->status != connector_status_connected) |
| 4966 | return -ENODEV; |
| 4967 | |
| 4968 | seq_printf(m, "Panel power up delay: %d\n", |
| 4969 | intel_dp->panel_power_up_delay); |
| 4970 | seq_printf(m, "Panel power down delay: %d\n", |
| 4971 | intel_dp->panel_power_down_delay); |
| 4972 | seq_printf(m, "Backlight on delay: %d\n", |
| 4973 | intel_dp->backlight_on_delay); |
| 4974 | seq_printf(m, "Backlight off delay: %d\n", |
| 4975 | intel_dp->backlight_off_delay); |
| 4976 | |
| 4977 | return 0; |
| 4978 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4979 | DEFINE_SHOW_ATTRIBUTE(i915_panel); |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4980 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4981 | static int i915_hdcp_sink_capability_show(struct seq_file *m, void *data) |
| 4982 | { |
| 4983 | struct drm_connector *connector = m->private; |
| 4984 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 4985 | |
| 4986 | if (connector->status != connector_status_connected) |
| 4987 | return -ENODEV; |
| 4988 | |
| 4989 | /* HDCP is supported by connector */ |
Ramalingam C | d3dacc7 | 2018-10-29 15:15:46 +0530 | [diff] [blame] | 4990 | if (!intel_connector->hdcp.shim) |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4991 | return -EINVAL; |
| 4992 | |
| 4993 | seq_printf(m, "%s:%d HDCP version: ", connector->name, |
| 4994 | connector->base.id); |
| 4995 | seq_printf(m, "%s ", !intel_hdcp_capable(intel_connector) ? |
| 4996 | "None" : "HDCP1.4"); |
| 4997 | seq_puts(m, "\n"); |
| 4998 | |
| 4999 | return 0; |
| 5000 | } |
| 5001 | DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability); |
| 5002 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5003 | /** |
| 5004 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5005 | * @connector: pointer to a registered drm_connector |
| 5006 | * |
| 5007 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5008 | * drm_debugfs_connector_remove(). |
| 5009 | * |
| 5010 | * Returns 0 on success, negative error codes on error. |
| 5011 | */ |
| 5012 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5013 | { |
| 5014 | struct dentry *root = connector->debugfs_entry; |
| 5015 | |
| 5016 | /* The connector must have been registered beforehands. */ |
| 5017 | if (!root) |
| 5018 | return -ENODEV; |
| 5019 | |
| 5020 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5021 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5022 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5023 | connector, &i915_dpcd_fops); |
| 5024 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 5025 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5026 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5027 | connector, &i915_panel_fops); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 5028 | debugfs_create_file("i915_psr_sink_status", S_IRUGO, root, |
| 5029 | connector, &i915_psr_sink_status_fops); |
| 5030 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5031 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 5032 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5033 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || |
| 5034 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { |
| 5035 | debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, |
| 5036 | connector, &i915_hdcp_sink_capability_fops); |
| 5037 | } |
| 5038 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5039 | return 0; |
| 5040 | } |