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