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 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 29 | #include <linux/sched/mm.h> |
Jani Nikula | 98afa31 | 2019-04-05 14:00:08 +0300 | [diff] [blame] | 30 | #include <linux/sort.h> |
| 31 | |
Daniel Vetter | fcd70cd | 2019-01-17 22:03:34 +0100 | [diff] [blame] | 32 | #include <drm/drm_debugfs.h> |
| 33 | #include <drm/drm_fourcc.h> |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 34 | |
Chris Wilson | 112ed2d | 2019-04-24 18:48:39 +0100 | [diff] [blame] | 35 | #include "gt/intel_reset.h" |
| 36 | |
Jani Nikula | 27fec1f | 2019-04-05 14:00:17 +0300 | [diff] [blame] | 37 | #include "intel_dp.h" |
Jani Nikula | 98afa31 | 2019-04-05 14:00:08 +0300 | [diff] [blame] | 38 | #include "intel_drv.h" |
| 39 | #include "intel_fbc.h" |
| 40 | #include "intel_guc_submission.h" |
Jani Nikula | 408bd91 | 2019-04-05 14:00:13 +0300 | [diff] [blame] | 41 | #include "intel_hdcp.h" |
Jani Nikula | 0550691 | 2019-04-05 14:00:18 +0300 | [diff] [blame] | 42 | #include "intel_hdmi.h" |
Jani Nikula | 696173b | 2019-04-05 14:00:15 +0300 | [diff] [blame] | 43 | #include "intel_pm.h" |
Jani Nikula | 55367a2 | 2019-04-05 14:00:09 +0300 | [diff] [blame] | 44 | #include "intel_psr.h" |
Chris Wilson | 9f58892 | 2019-01-16 15:33:04 +0000 | [diff] [blame] | 45 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 46 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 47 | { |
| 48 | return to_i915(node->minor->dev); |
| 49 | } |
| 50 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 51 | static int i915_capabilities(struct seq_file *m, void *data) |
| 52 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 53 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 54 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 55 | struct drm_printer p = drm_seq_file_printer(m); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 56 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 57 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 58 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 59 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 60 | |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 61 | intel_device_info_dump_flags(info, &p); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 62 | intel_device_info_dump_runtime(RUNTIME_INFO(dev_priv), &p); |
Chris Wilson | 3fed180 | 2018-02-07 21:05:43 +0000 | [diff] [blame] | 63 | intel_driver_caps_print(&dev_priv->caps, &p); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 64 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 65 | kernel_param_lock(THIS_MODULE); |
Michal Wajdeczko | acfb997 | 2017-12-19 11:43:46 +0000 | [diff] [blame] | 66 | i915_params_dump(&i915_modparams, &p); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 67 | kernel_param_unlock(THIS_MODULE); |
| 68 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 69 | return 0; |
| 70 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 71 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 72 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 73 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 74 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 75 | } |
| 76 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 77 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 78 | { |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 79 | return obj->pin_global ? 'p' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 80 | } |
| 81 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 82 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 83 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 84 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 85 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 86 | case I915_TILING_NONE: return ' '; |
| 87 | case I915_TILING_X: return 'X'; |
| 88 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 89 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 92 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 93 | { |
Chris Wilson | a65adaf | 2017-10-09 09:43:57 +0100 | [diff] [blame] | 94 | return obj->userfault_count ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 97 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 98 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 99 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 102 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 103 | { |
| 104 | u64 size = 0; |
| 105 | struct i915_vma *vma; |
| 106 | |
Chris Wilson | e2189dd | 2017-12-07 21:14:07 +0000 | [diff] [blame] | 107 | for_each_ggtt_vma(vma, obj) { |
| 108 | if (drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 109 | size += vma->node.size; |
| 110 | } |
| 111 | |
| 112 | return size; |
| 113 | } |
| 114 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 115 | static const char * |
| 116 | stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len) |
| 117 | { |
| 118 | size_t x = 0; |
| 119 | |
| 120 | switch (page_sizes) { |
| 121 | case 0: |
| 122 | return ""; |
| 123 | case I915_GTT_PAGE_SIZE_4K: |
| 124 | return "4K"; |
| 125 | case I915_GTT_PAGE_SIZE_64K: |
| 126 | return "64K"; |
| 127 | case I915_GTT_PAGE_SIZE_2M: |
| 128 | return "2M"; |
| 129 | default: |
| 130 | if (!buf) |
| 131 | return "M"; |
| 132 | |
| 133 | if (page_sizes & I915_GTT_PAGE_SIZE_2M) |
| 134 | x += snprintf(buf + x, len - x, "2M, "); |
| 135 | if (page_sizes & I915_GTT_PAGE_SIZE_64K) |
| 136 | x += snprintf(buf + x, len - x, "64K, "); |
| 137 | if (page_sizes & I915_GTT_PAGE_SIZE_4K) |
| 138 | x += snprintf(buf + x, len - x, "4K, "); |
| 139 | buf[x-2] = '\0'; |
| 140 | |
| 141 | return buf; |
| 142 | } |
| 143 | } |
| 144 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 145 | static void |
| 146 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 147 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 148 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 149 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 150 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 151 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 152 | int pin_count = 0; |
| 153 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 154 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 155 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 156 | 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] | 157 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 158 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 159 | get_pin_flag(obj), |
| 160 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 161 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 162 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 163 | obj->base.size / 1024, |
Christian König | c0a51fd | 2018-02-16 13:43:38 +0100 | [diff] [blame] | 164 | obj->read_domains, |
| 165 | obj->write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 166 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 167 | obj->mm.dirty ? " dirty" : "", |
| 168 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 169 | if (obj->base.name) |
| 170 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 171 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 172 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 173 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 174 | } |
| 175 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 176 | if (obj->pin_global) |
| 177 | seq_printf(m, " (global)"); |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 178 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 179 | if (!drm_mm_node_allocated(&vma->node)) |
| 180 | continue; |
| 181 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 182 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx, pages: %s", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 183 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 184 | vma->node.start, vma->node.size, |
| 185 | stringify_page_sizes(vma->page_sizes.gtt, NULL, 0)); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 186 | if (i915_vma_is_ggtt(vma)) { |
| 187 | switch (vma->ggtt_view.type) { |
| 188 | case I915_GGTT_VIEW_NORMAL: |
| 189 | seq_puts(m, ", normal"); |
| 190 | break; |
| 191 | |
| 192 | case I915_GGTT_VIEW_PARTIAL: |
| 193 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 194 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 195 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 196 | break; |
| 197 | |
| 198 | case I915_GGTT_VIEW_ROTATED: |
| 199 | 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] | 200 | vma->ggtt_view.rotated.plane[0].width, |
| 201 | vma->ggtt_view.rotated.plane[0].height, |
| 202 | vma->ggtt_view.rotated.plane[0].stride, |
| 203 | vma->ggtt_view.rotated.plane[0].offset, |
| 204 | vma->ggtt_view.rotated.plane[1].width, |
| 205 | vma->ggtt_view.rotated.plane[1].height, |
| 206 | vma->ggtt_view.rotated.plane[1].stride, |
| 207 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 208 | break; |
| 209 | |
| 210 | default: |
| 211 | MISSING_CASE(vma->ggtt_view.type); |
| 212 | break; |
| 213 | } |
| 214 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 215 | if (vma->fence) |
| 216 | seq_printf(m, " , fence: %d%s", |
| 217 | vma->fence->id, |
Chris Wilson | 21950ee | 2019-02-05 13:00:05 +0000 | [diff] [blame] | 218 | i915_active_request_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 219 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 220 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 221 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 222 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 223 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 224 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 225 | if (engine) |
| 226 | seq_printf(m, " (%s)", engine->name); |
| 227 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 228 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 229 | if (frontbuffer_bits) |
| 230 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 231 | } |
| 232 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 233 | static int obj_rank_by_stolen(const void *A, const void *B) |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 234 | { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 235 | const struct drm_i915_gem_object *a = |
| 236 | *(const struct drm_i915_gem_object **)A; |
| 237 | const struct drm_i915_gem_object *b = |
| 238 | *(const struct drm_i915_gem_object **)B; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 239 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 240 | if (a->stolen->start < b->stolen->start) |
| 241 | return -1; |
| 242 | if (a->stolen->start > b->stolen->start) |
| 243 | return 1; |
| 244 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 248 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 249 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 250 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 251 | struct drm_i915_gem_object **objects; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 252 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 253 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 254 | unsigned long total, count, n; |
| 255 | int ret; |
| 256 | |
| 257 | total = READ_ONCE(dev_priv->mm.object_count); |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 258 | objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 259 | if (!objects) |
| 260 | return -ENOMEM; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 261 | |
| 262 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 263 | if (ret) |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 264 | goto out; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 265 | |
| 266 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 267 | |
| 268 | spin_lock(&dev_priv->mm.obj_lock); |
| 269 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 270 | if (count == total) |
| 271 | break; |
| 272 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 273 | if (obj->stolen == NULL) |
| 274 | continue; |
| 275 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 276 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 277 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 278 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 279 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 281 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 282 | if (count == total) |
| 283 | break; |
| 284 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 285 | if (obj->stolen == NULL) |
| 286 | continue; |
| 287 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 288 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 289 | total_obj_size += obj->base.size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 290 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 291 | spin_unlock(&dev_priv->mm.obj_lock); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 292 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 293 | sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL); |
| 294 | |
| 295 | seq_puts(m, "Stolen:\n"); |
| 296 | for (n = 0; n < count; n++) { |
| 297 | seq_puts(m, " "); |
| 298 | describe_obj(m, objects[n]); |
| 299 | seq_putc(m, '\n'); |
| 300 | } |
| 301 | seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 302 | count, total_obj_size, total_gtt_size); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 303 | |
| 304 | mutex_unlock(&dev->struct_mutex); |
| 305 | out: |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 306 | kvfree(objects); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 307 | return ret; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 308 | } |
| 309 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 310 | struct file_stats { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 311 | struct i915_address_space *vm; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 312 | unsigned long count; |
| 313 | u64 total, unbound; |
| 314 | u64 global, shared; |
| 315 | u64 active, inactive; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 316 | u64 closed; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 317 | }; |
| 318 | |
| 319 | static int per_file_stats(int id, void *ptr, void *data) |
| 320 | { |
| 321 | struct drm_i915_gem_object *obj = ptr; |
| 322 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 323 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 324 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 325 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 326 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 327 | stats->count++; |
| 328 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 329 | if (!obj->bind_count) |
| 330 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 331 | if (obj->base.name || obj->base.dma_buf) |
| 332 | stats->shared += obj->base.size; |
| 333 | |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 334 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 335 | if (!drm_mm_node_allocated(&vma->node)) |
| 336 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 337 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 338 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 339 | stats->global += vma->node.size; |
| 340 | } else { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 341 | if (vma->vm != stats->vm) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 342 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 343 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 344 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 345 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 346 | stats->active += vma->node.size; |
| 347 | else |
| 348 | stats->inactive += vma->node.size; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 349 | |
| 350 | if (i915_vma_is_closed(vma)) |
| 351 | stats->closed += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | return 0; |
| 355 | } |
| 356 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 357 | #define print_file_stats(m, name, stats) do { \ |
| 358 | if (stats.count) \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 359 | seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound, %llu closed)\n", \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 360 | name, \ |
| 361 | stats.count, \ |
| 362 | stats.total, \ |
| 363 | stats.active, \ |
| 364 | stats.inactive, \ |
| 365 | stats.global, \ |
| 366 | stats.shared, \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 367 | stats.unbound, \ |
| 368 | stats.closed); \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 369 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 370 | |
| 371 | static void print_batch_pool_stats(struct seq_file *m, |
| 372 | struct drm_i915_private *dev_priv) |
| 373 | { |
| 374 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 375 | struct intel_engine_cs *engine; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 376 | struct file_stats stats = {}; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 377 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 378 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 379 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 380 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 381 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 382 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 383 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 384 | batch_pool_link) |
| 385 | per_file_stats(0, obj, &stats); |
| 386 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 387 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 388 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 389 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 390 | } |
| 391 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 392 | static void print_context_stats(struct seq_file *m, |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 393 | struct drm_i915_private *i915) |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 394 | { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 395 | struct file_stats kstats = {}; |
| 396 | struct i915_gem_context *ctx; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 397 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 398 | list_for_each_entry(ctx, &i915->contexts.list, link) { |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 399 | struct intel_context *ce; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 400 | |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 401 | list_for_each_entry(ce, &ctx->active_engines, active_link) { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 402 | if (ce->state) |
| 403 | per_file_stats(0, ce->state->obj, &kstats); |
| 404 | if (ce->ring) |
| 405 | per_file_stats(0, ce->ring->vma->obj, &kstats); |
| 406 | } |
| 407 | |
| 408 | if (!IS_ERR_OR_NULL(ctx->file_priv)) { |
| 409 | struct file_stats stats = { .vm = &ctx->ppgtt->vm, }; |
| 410 | struct drm_file *file = ctx->file_priv->file; |
| 411 | struct task_struct *task; |
| 412 | char name[80]; |
| 413 | |
| 414 | spin_lock(&file->table_lock); |
| 415 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
| 416 | spin_unlock(&file->table_lock); |
| 417 | |
| 418 | rcu_read_lock(); |
| 419 | task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID); |
Chris Wilson | 3e05531 | 2019-03-21 14:07:10 +0000 | [diff] [blame] | 420 | snprintf(name, sizeof(name), "%s", |
| 421 | task ? task->comm : "<unknown>"); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 422 | rcu_read_unlock(); |
| 423 | |
| 424 | print_file_stats(m, name, stats); |
| 425 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 426 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 427 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 428 | print_file_stats(m, "[k]contexts", kstats); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 429 | } |
| 430 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 431 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 432 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 433 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 434 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 435 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 436 | u32 count, mapped_count, purgeable_count, dpy_count, huge_count; |
| 437 | u64 size, mapped_size, purgeable_size, dpy_size, huge_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 438 | struct drm_i915_gem_object *obj; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 439 | unsigned int page_sizes = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 440 | char buf[80]; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 441 | int ret; |
| 442 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 443 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 444 | dev_priv->mm.object_count, |
| 445 | dev_priv->mm.object_memory); |
| 446 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 447 | size = count = 0; |
| 448 | mapped_size = mapped_count = 0; |
| 449 | purgeable_size = purgeable_count = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 450 | huge_size = huge_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 451 | |
| 452 | spin_lock(&dev_priv->mm.obj_lock); |
| 453 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 454 | size += obj->base.size; |
| 455 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 456 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 457 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 458 | purgeable_size += obj->base.size; |
| 459 | ++purgeable_count; |
| 460 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 461 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 462 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 463 | mapped_count++; |
| 464 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 465 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 466 | |
| 467 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 468 | huge_count++; |
| 469 | huge_size += obj->base.size; |
| 470 | page_sizes |= obj->mm.page_sizes.sg; |
| 471 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 472 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 473 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 474 | |
| 475 | size = count = dpy_size = dpy_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 476 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 477 | size += obj->base.size; |
| 478 | ++count; |
| 479 | |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 480 | if (obj->pin_global) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 481 | dpy_size += obj->base.size; |
| 482 | ++dpy_count; |
| 483 | } |
| 484 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 485 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 486 | purgeable_size += obj->base.size; |
| 487 | ++purgeable_count; |
| 488 | } |
| 489 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 490 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 491 | mapped_count++; |
| 492 | mapped_size += obj->base.size; |
| 493 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 494 | |
| 495 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 496 | huge_count++; |
| 497 | huge_size += obj->base.size; |
| 498 | page_sizes |= obj->mm.page_sizes.sg; |
| 499 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 500 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 501 | spin_unlock(&dev_priv->mm.obj_lock); |
| 502 | |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 503 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 504 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 505 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 506 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 507 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 508 | mapped_count, mapped_size); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 509 | seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n", |
| 510 | huge_count, |
| 511 | stringify_page_sizes(page_sizes, buf, sizeof(buf)), |
| 512 | huge_size); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 513 | seq_printf(m, "%u display objects (globally pinned), %llu bytes\n", |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 514 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 515 | |
Matthew Auld | b7128ef | 2017-12-11 15:18:22 +0000 | [diff] [blame] | 516 | seq_printf(m, "%llu [%pa] gtt total\n", |
Chris Wilson | 82ad644 | 2018-06-05 16:37:58 +0100 | [diff] [blame] | 517 | ggtt->vm.total, &ggtt->mappable_end); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 518 | seq_printf(m, "Supported page sizes: %s\n", |
| 519 | stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes, |
| 520 | buf, sizeof(buf))); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 521 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 522 | seq_putc(m, '\n'); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 523 | |
| 524 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 525 | if (ret) |
| 526 | return ret; |
| 527 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 528 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 529 | print_context_stats(m, dev_priv); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 530 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 535 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 536 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 537 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 538 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 539 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 540 | struct drm_i915_gem_object **objects; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 541 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 542 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 543 | unsigned long nobject, n; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 544 | int count, ret; |
| 545 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 546 | nobject = READ_ONCE(dev_priv->mm.object_count); |
| 547 | objects = kvmalloc_array(nobject, sizeof(*objects), GFP_KERNEL); |
| 548 | if (!objects) |
| 549 | return -ENOMEM; |
| 550 | |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 551 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 552 | if (ret) |
| 553 | return ret; |
| 554 | |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 555 | count = 0; |
| 556 | spin_lock(&dev_priv->mm.obj_lock); |
| 557 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
| 558 | objects[count++] = obj; |
| 559 | if (count == nobject) |
| 560 | break; |
| 561 | } |
| 562 | spin_unlock(&dev_priv->mm.obj_lock); |
| 563 | |
| 564 | total_obj_size = total_gtt_size = 0; |
| 565 | for (n = 0; n < count; n++) { |
| 566 | obj = objects[n]; |
| 567 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 568 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 569 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 570 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 571 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 572 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | mutex_unlock(&dev->struct_mutex); |
| 576 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 577 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 578 | count, total_obj_size, total_gtt_size); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 579 | kvfree(objects); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 584 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 585 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 586 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 587 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 588 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 589 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 590 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 591 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 592 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 593 | |
| 594 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 595 | if (ret) |
| 596 | return ret; |
| 597 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 598 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 599 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 600 | int count; |
| 601 | |
| 602 | count = 0; |
| 603 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 604 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 605 | batch_pool_link) |
| 606 | count++; |
| 607 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 608 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 609 | |
| 610 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 611 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 612 | batch_pool_link) { |
| 613 | seq_puts(m, " "); |
| 614 | describe_obj(m, obj); |
| 615 | seq_putc(m, '\n'); |
| 616 | } |
| 617 | |
| 618 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 619 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 620 | } |
| 621 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 622 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 623 | |
| 624 | mutex_unlock(&dev->struct_mutex); |
| 625 | |
| 626 | return 0; |
| 627 | } |
| 628 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 629 | static void gen8_display_interrupt_info(struct seq_file *m) |
| 630 | { |
| 631 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 632 | int pipe; |
| 633 | |
| 634 | for_each_pipe(dev_priv, pipe) { |
| 635 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 636 | intel_wakeref_t wakeref; |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 637 | |
| 638 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 639 | wakeref = intel_display_power_get_if_enabled(dev_priv, |
| 640 | power_domain); |
| 641 | if (!wakeref) { |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 642 | seq_printf(m, "Pipe %c power disabled\n", |
| 643 | pipe_name(pipe)); |
| 644 | continue; |
| 645 | } |
| 646 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
| 647 | pipe_name(pipe), |
| 648 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
| 649 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
| 650 | pipe_name(pipe), |
| 651 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
| 652 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
| 653 | pipe_name(pipe), |
| 654 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
| 655 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 656 | intel_display_power_put(dev_priv, power_domain, wakeref); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 660 | I915_READ(GEN8_DE_PORT_IMR)); |
| 661 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 662 | I915_READ(GEN8_DE_PORT_IIR)); |
| 663 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 664 | I915_READ(GEN8_DE_PORT_IER)); |
| 665 | |
| 666 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 667 | I915_READ(GEN8_DE_MISC_IMR)); |
| 668 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 669 | I915_READ(GEN8_DE_MISC_IIR)); |
| 670 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 671 | I915_READ(GEN8_DE_MISC_IER)); |
| 672 | |
| 673 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 674 | I915_READ(GEN8_PCU_IMR)); |
| 675 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 676 | I915_READ(GEN8_PCU_IIR)); |
| 677 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 678 | I915_READ(GEN8_PCU_IER)); |
| 679 | } |
| 680 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 681 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 682 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 683 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 684 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 685 | enum intel_engine_id id; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 686 | intel_wakeref_t wakeref; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 687 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 688 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 689 | wakeref = intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 690 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 691 | if (IS_CHERRYVIEW(dev_priv)) { |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 692 | intel_wakeref_t pref; |
| 693 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 694 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 695 | I915_READ(GEN8_MASTER_IRQ)); |
| 696 | |
| 697 | seq_printf(m, "Display IER:\t%08x\n", |
| 698 | I915_READ(VLV_IER)); |
| 699 | seq_printf(m, "Display IIR:\t%08x\n", |
| 700 | I915_READ(VLV_IIR)); |
| 701 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 702 | I915_READ(VLV_IIR_RW)); |
| 703 | seq_printf(m, "Display IMR:\t%08x\n", |
| 704 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 705 | for_each_pipe(dev_priv, pipe) { |
| 706 | enum intel_display_power_domain power_domain; |
| 707 | |
| 708 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 709 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 710 | power_domain); |
| 711 | if (!pref) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 712 | seq_printf(m, "Pipe %c power disabled\n", |
| 713 | pipe_name(pipe)); |
| 714 | continue; |
| 715 | } |
| 716 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 717 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 718 | pipe_name(pipe), |
| 719 | I915_READ(PIPESTAT(pipe))); |
| 720 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 721 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 722 | } |
| 723 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 724 | pref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 725 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 726 | I915_READ(PORT_HOTPLUG_EN)); |
| 727 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 728 | I915_READ(VLV_DPFLIPSTAT)); |
| 729 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 730 | I915_READ(DPINVGTT)); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 731 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, pref); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 732 | |
| 733 | for (i = 0; i < 4; i++) { |
| 734 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 735 | i, I915_READ(GEN8_GT_IMR(i))); |
| 736 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 737 | i, I915_READ(GEN8_GT_IIR(i))); |
| 738 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 739 | i, I915_READ(GEN8_GT_IER(i))); |
| 740 | } |
| 741 | |
| 742 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 743 | I915_READ(GEN8_PCU_IMR)); |
| 744 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 745 | I915_READ(GEN8_PCU_IIR)); |
| 746 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 747 | I915_READ(GEN8_PCU_IER)); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 748 | } else if (INTEL_GEN(dev_priv) >= 11) { |
| 749 | seq_printf(m, "Master Interrupt Control: %08x\n", |
| 750 | I915_READ(GEN11_GFX_MSTR_IRQ)); |
| 751 | |
| 752 | seq_printf(m, "Render/Copy Intr Enable: %08x\n", |
| 753 | I915_READ(GEN11_RENDER_COPY_INTR_ENABLE)); |
| 754 | seq_printf(m, "VCS/VECS Intr Enable: %08x\n", |
| 755 | I915_READ(GEN11_VCS_VECS_INTR_ENABLE)); |
| 756 | seq_printf(m, "GUC/SG Intr Enable:\t %08x\n", |
| 757 | I915_READ(GEN11_GUC_SG_INTR_ENABLE)); |
| 758 | seq_printf(m, "GPM/WGBOXPERF Intr Enable: %08x\n", |
| 759 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE)); |
| 760 | seq_printf(m, "Crypto Intr Enable:\t %08x\n", |
| 761 | I915_READ(GEN11_CRYPTO_RSVD_INTR_ENABLE)); |
| 762 | seq_printf(m, "GUnit/CSME Intr Enable:\t %08x\n", |
| 763 | I915_READ(GEN11_GUNIT_CSME_INTR_ENABLE)); |
| 764 | |
| 765 | seq_printf(m, "Display Interrupt Control:\t%08x\n", |
| 766 | I915_READ(GEN11_DISPLAY_INT_CTL)); |
| 767 | |
| 768 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 769 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 770 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 771 | I915_READ(GEN8_MASTER_IRQ)); |
| 772 | |
| 773 | for (i = 0; i < 4; i++) { |
| 774 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 775 | i, I915_READ(GEN8_GT_IMR(i))); |
| 776 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 777 | i, I915_READ(GEN8_GT_IIR(i))); |
| 778 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 779 | i, I915_READ(GEN8_GT_IER(i))); |
| 780 | } |
| 781 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 782 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 783 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 784 | seq_printf(m, "Display IER:\t%08x\n", |
| 785 | I915_READ(VLV_IER)); |
| 786 | seq_printf(m, "Display IIR:\t%08x\n", |
| 787 | I915_READ(VLV_IIR)); |
| 788 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 789 | I915_READ(VLV_IIR_RW)); |
| 790 | seq_printf(m, "Display IMR:\t%08x\n", |
| 791 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 792 | for_each_pipe(dev_priv, pipe) { |
| 793 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 794 | intel_wakeref_t pref; |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 795 | |
| 796 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 797 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 798 | power_domain); |
| 799 | if (!pref) { |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 800 | seq_printf(m, "Pipe %c power disabled\n", |
| 801 | pipe_name(pipe)); |
| 802 | continue; |
| 803 | } |
| 804 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 805 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 806 | pipe_name(pipe), |
| 807 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 808 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 809 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 810 | |
| 811 | seq_printf(m, "Master IER:\t%08x\n", |
| 812 | I915_READ(VLV_MASTER_IER)); |
| 813 | |
| 814 | seq_printf(m, "Render IER:\t%08x\n", |
| 815 | I915_READ(GTIER)); |
| 816 | seq_printf(m, "Render IIR:\t%08x\n", |
| 817 | I915_READ(GTIIR)); |
| 818 | seq_printf(m, "Render IMR:\t%08x\n", |
| 819 | I915_READ(GTIMR)); |
| 820 | |
| 821 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 822 | I915_READ(GEN6_PMIER)); |
| 823 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 824 | I915_READ(GEN6_PMIIR)); |
| 825 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 826 | I915_READ(GEN6_PMIMR)); |
| 827 | |
| 828 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 829 | I915_READ(PORT_HOTPLUG_EN)); |
| 830 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 831 | I915_READ(VLV_DPFLIPSTAT)); |
| 832 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 833 | I915_READ(DPINVGTT)); |
| 834 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 835 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 836 | seq_printf(m, "Interrupt enable: %08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 837 | I915_READ(GEN2_IER)); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 838 | seq_printf(m, "Interrupt identity: %08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 839 | I915_READ(GEN2_IIR)); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 840 | seq_printf(m, "Interrupt mask: %08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 841 | I915_READ(GEN2_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 842 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 843 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 844 | pipe_name(pipe), |
| 845 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 846 | } else { |
| 847 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 848 | I915_READ(DEIER)); |
| 849 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 850 | I915_READ(DEIIR)); |
| 851 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 852 | I915_READ(DEIMR)); |
| 853 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 854 | I915_READ(SDEIER)); |
| 855 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 856 | I915_READ(SDEIIR)); |
| 857 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 858 | I915_READ(SDEIMR)); |
| 859 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 860 | I915_READ(GTIER)); |
| 861 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 862 | I915_READ(GTIIR)); |
| 863 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 864 | I915_READ(GTIMR)); |
| 865 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 866 | |
| 867 | if (INTEL_GEN(dev_priv) >= 11) { |
| 868 | seq_printf(m, "RCS Intr Mask:\t %08x\n", |
| 869 | I915_READ(GEN11_RCS0_RSVD_INTR_MASK)); |
| 870 | seq_printf(m, "BCS Intr Mask:\t %08x\n", |
| 871 | I915_READ(GEN11_BCS_RSVD_INTR_MASK)); |
| 872 | seq_printf(m, "VCS0/VCS1 Intr Mask:\t %08x\n", |
| 873 | I915_READ(GEN11_VCS0_VCS1_INTR_MASK)); |
| 874 | seq_printf(m, "VCS2/VCS3 Intr Mask:\t %08x\n", |
| 875 | I915_READ(GEN11_VCS2_VCS3_INTR_MASK)); |
| 876 | seq_printf(m, "VECS0/VECS1 Intr Mask:\t %08x\n", |
| 877 | I915_READ(GEN11_VECS0_VECS1_INTR_MASK)); |
| 878 | seq_printf(m, "GUC/SG Intr Mask:\t %08x\n", |
| 879 | I915_READ(GEN11_GUC_SG_INTR_MASK)); |
| 880 | seq_printf(m, "GPM/WGBOXPERF Intr Mask: %08x\n", |
| 881 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK)); |
| 882 | seq_printf(m, "Crypto Intr Mask:\t %08x\n", |
| 883 | I915_READ(GEN11_CRYPTO_RSVD_INTR_MASK)); |
| 884 | seq_printf(m, "Gunit/CSME Intr Mask:\t %08x\n", |
| 885 | I915_READ(GEN11_GUNIT_CSME_INTR_MASK)); |
| 886 | |
| 887 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | d5acadf | 2017-12-09 10:44:18 +0000 | [diff] [blame] | 888 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 889 | seq_printf(m, |
| 890 | "Graphics Interrupt mask (%s): %08x\n", |
Daniele Ceraolo Spurio | baba6e5 | 2019-03-25 14:49:40 -0700 | [diff] [blame] | 891 | engine->name, ENGINE_READ(engine, RING_IMR)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 892 | } |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 893 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 894 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 895 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 896 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 897 | return 0; |
| 898 | } |
| 899 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 900 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 901 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 902 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 903 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 904 | int i, ret; |
| 905 | |
| 906 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 907 | if (ret) |
| 908 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 909 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 910 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 911 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 912 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 913 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 914 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 915 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 916 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 917 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 918 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 919 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 920 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 921 | } |
| 922 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 923 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 924 | return 0; |
| 925 | } |
| 926 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 927 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 928 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 929 | size_t count, loff_t *pos) |
| 930 | { |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 931 | struct i915_gpu_state *error; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 932 | ssize_t ret; |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 933 | void *buf; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 934 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 935 | error = file->private_data; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 936 | if (!error) |
| 937 | return 0; |
| 938 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 939 | /* Bounce buffer required because of kernfs __user API convenience. */ |
| 940 | buf = kmalloc(count, GFP_KERNEL); |
| 941 | if (!buf) |
| 942 | return -ENOMEM; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 943 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 944 | ret = i915_gpu_state_copy_to_buffer(error, buf, *pos, count); |
| 945 | if (ret <= 0) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 946 | goto out; |
| 947 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 948 | if (!copy_to_user(ubuf, buf, ret)) |
| 949 | *pos += ret; |
| 950 | else |
| 951 | ret = -EFAULT; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 952 | |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 953 | out: |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 954 | kfree(buf); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 955 | return ret; |
| 956 | } |
| 957 | |
| 958 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 959 | { |
| 960 | i915_gpu_state_put(file->private_data); |
| 961 | return 0; |
| 962 | } |
| 963 | |
| 964 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 965 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 966 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 967 | struct i915_gpu_state *gpu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 968 | intel_wakeref_t wakeref; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 969 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 970 | gpu = NULL; |
| 971 | with_intel_runtime_pm(i915, wakeref) |
| 972 | gpu = i915_capture_gpu_state(i915); |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 973 | if (IS_ERR(gpu)) |
| 974 | return PTR_ERR(gpu); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 975 | |
| 976 | file->private_data = gpu; |
| 977 | return 0; |
| 978 | } |
| 979 | |
| 980 | static const struct file_operations i915_gpu_info_fops = { |
| 981 | .owner = THIS_MODULE, |
| 982 | .open = i915_gpu_info_open, |
| 983 | .read = gpu_state_read, |
| 984 | .llseek = default_llseek, |
| 985 | .release = gpu_state_release, |
| 986 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 987 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 988 | static ssize_t |
| 989 | i915_error_state_write(struct file *filp, |
| 990 | const char __user *ubuf, |
| 991 | size_t cnt, |
| 992 | loff_t *ppos) |
| 993 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 994 | struct i915_gpu_state *error = filp->private_data; |
| 995 | |
| 996 | if (!error) |
| 997 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 998 | |
| 999 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1000 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1001 | |
| 1002 | return cnt; |
| 1003 | } |
| 1004 | |
| 1005 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1006 | { |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 1007 | struct i915_gpu_state *error; |
| 1008 | |
| 1009 | error = i915_first_error_state(inode->i_private); |
| 1010 | if (IS_ERR(error)) |
| 1011 | return PTR_ERR(error); |
| 1012 | |
| 1013 | file->private_data = error; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1014 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1015 | } |
| 1016 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1017 | static const struct file_operations i915_error_state_fops = { |
| 1018 | .owner = THIS_MODULE, |
| 1019 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1020 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1021 | .write = i915_error_state_write, |
| 1022 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 1023 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1024 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1025 | #endif |
| 1026 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1027 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1028 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1029 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1030 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1031 | intel_wakeref_t wakeref; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1032 | int ret = 0; |
| 1033 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1034 | wakeref = intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1035 | |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 1036 | if (IS_GEN(dev_priv, 5)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1037 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1038 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1039 | |
| 1040 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1041 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1042 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1043 | MEMSTAT_VID_SHIFT); |
| 1044 | seq_printf(m, "Current P-state: %d\n", |
| 1045 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1046 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1047 | u32 rpmodectl, freq_sts; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1048 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1049 | mutex_lock(&dev_priv->pcu_lock); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1050 | |
| 1051 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1052 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1053 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1054 | seq_printf(m, "HW control enabled: %s\n", |
| 1055 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1056 | seq_printf(m, "SW control enabled: %s\n", |
| 1057 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1058 | GEN6_RP_MEDIA_SW_MODE)); |
| 1059 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1060 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1061 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1062 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1063 | |
| 1064 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1065 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1066 | |
| 1067 | seq_printf(m, "current GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1068 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1069 | |
| 1070 | seq_printf(m, "max GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1071 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1072 | |
| 1073 | seq_printf(m, "min GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1074 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1075 | |
| 1076 | seq_printf(m, "idle GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1077 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1078 | |
| 1079 | seq_printf(m, |
| 1080 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1081 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1082 | mutex_unlock(&dev_priv->pcu_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1083 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1084 | u32 rp_state_limits; |
| 1085 | u32 gt_perf_status; |
| 1086 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1087 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1088 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1089 | u32 rpupei, rpcurup, rpprevup; |
| 1090 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1091 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1092 | int max_freq; |
| 1093 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1094 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1095 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1096 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1097 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1098 | } else { |
| 1099 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1100 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1101 | } |
| 1102 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1103 | /* RPSTAT1 is in the GT power well */ |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 1104 | intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1105 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1106 | reqf = I915_READ(GEN6_RPNSWREQ); |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1107 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1108 | reqf >>= 23; |
| 1109 | else { |
| 1110 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1111 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1112 | reqf >>= 24; |
| 1113 | else |
| 1114 | reqf >>= 25; |
| 1115 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1116 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1117 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1118 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1119 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1120 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1121 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1122 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1123 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1124 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1125 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1126 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1127 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1128 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Tvrtko Ursulin | c84b270 | 2017-11-21 18:18:44 +0000 | [diff] [blame] | 1129 | cagf = intel_gpu_freq(dev_priv, |
| 1130 | intel_get_cagf(dev_priv, rpstat)); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1131 | |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 1132 | intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1133 | |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1134 | if (INTEL_GEN(dev_priv) >= 11) { |
| 1135 | pm_ier = I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE); |
| 1136 | pm_imr = I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK); |
| 1137 | /* |
| 1138 | * The equivalent to the PM ISR & IIR cannot be read |
| 1139 | * without affecting the current state of the system |
| 1140 | */ |
| 1141 | pm_isr = 0; |
| 1142 | pm_iir = 0; |
| 1143 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1144 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1145 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1146 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1147 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1148 | } else { |
| 1149 | pm_ier = I915_READ(GEN6_PMIER); |
| 1150 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1151 | pm_isr = I915_READ(GEN6_PMISR); |
| 1152 | pm_iir = I915_READ(GEN6_PMIIR); |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1153 | } |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1154 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1155 | |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1156 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1157 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1158 | seq_printf(m, "HW control enabled: %s\n", |
| 1159 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1160 | seq_printf(m, "SW control enabled: %s\n", |
| 1161 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1162 | GEN6_RP_MEDIA_SW_MODE)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1163 | |
| 1164 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x, MASK=0x%08x\n", |
| 1165 | pm_ier, pm_imr, pm_mask); |
| 1166 | if (INTEL_GEN(dev_priv) <= 10) |
| 1167 | seq_printf(m, "PM ISR=0x%08x IIR=0x%08x\n", |
| 1168 | pm_isr, pm_iir); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1169 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1170 | rps->pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1171 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1172 | seq_printf(m, "Render p-state ratio: %d\n", |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1173 | (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1174 | seq_printf(m, "Render p-state VID: %d\n", |
| 1175 | gt_perf_status & 0xff); |
| 1176 | seq_printf(m, "Render p-state limit: %d\n", |
| 1177 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1178 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1179 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1180 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1181 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1182 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1183 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1184 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1185 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1186 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1187 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1188 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1189 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1190 | seq_printf(m, "Up threshold: %d%%\n", |
| 1191 | rps->power.up_threshold); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1192 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1193 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1194 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1195 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1196 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1197 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1198 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1199 | seq_printf(m, "Down threshold: %d%%\n", |
| 1200 | rps->power.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1201 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1202 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1203 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1204 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1205 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1206 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1207 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1208 | |
| 1209 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1210 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1211 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1212 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1213 | intel_gpu_freq(dev_priv, max_freq)); |
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 >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1216 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1217 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1218 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1219 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1220 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1221 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1222 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1223 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1224 | seq_printf(m, "Current freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1225 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1226 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1227 | seq_printf(m, "Idle freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1228 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1229 | seq_printf(m, "Min freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1230 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1231 | seq_printf(m, "Boost freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1232 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1233 | seq_printf(m, "Max freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1234 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1235 | seq_printf(m, |
| 1236 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1237 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1238 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1239 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1240 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1241 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1242 | 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] | 1243 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1244 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1245 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1246 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1247 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1248 | } |
| 1249 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1250 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1251 | struct seq_file *m, |
| 1252 | struct intel_instdone *instdone) |
| 1253 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1254 | int slice; |
| 1255 | int subslice; |
| 1256 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1257 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1258 | instdone->instdone); |
| 1259 | |
| 1260 | if (INTEL_GEN(dev_priv) <= 3) |
| 1261 | return; |
| 1262 | |
| 1263 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1264 | instdone->slice_common); |
| 1265 | |
| 1266 | if (INTEL_GEN(dev_priv) <= 6) |
| 1267 | return; |
| 1268 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1269 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1270 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1271 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1272 | |
| 1273 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1274 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1275 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1276 | } |
| 1277 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1278 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1279 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1280 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1281 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1282 | u64 acthd[I915_NUM_ENGINES]; |
| 1283 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1284 | struct intel_instdone instdone; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1285 | intel_wakeref_t wakeref; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1286 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1287 | |
Chris Wilson | 2caffbf | 2019-02-08 15:37:03 +0000 | [diff] [blame] | 1288 | seq_printf(m, "Reset flags: %lx\n", dev_priv->gpu_error.flags); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1289 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 2caffbf | 2019-02-08 15:37:03 +0000 | [diff] [blame] | 1290 | seq_puts(m, "\tWedged\n"); |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1291 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
Chris Wilson | 2caffbf | 2019-02-08 15:37:03 +0000 | [diff] [blame] | 1292 | seq_puts(m, "\tDevice (global) reset in progress\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1293 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1294 | if (!i915_modparams.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1295 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1296 | return 0; |
| 1297 | } |
| 1298 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1299 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1300 | for_each_engine(engine, dev_priv, id) { |
| 1301 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 89531e7 | 2019-02-26 09:49:19 +0000 | [diff] [blame] | 1302 | seqno[id] = intel_engine_get_hangcheck_seqno(engine); |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1303 | } |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1304 | |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1305 | intel_engine_get_instdone(dev_priv->engine[RCS0], &instdone); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1306 | } |
| 1307 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1308 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1309 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1310 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1311 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1312 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1313 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1314 | else |
| 1315 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1316 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1317 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1318 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1319 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1320 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame] | 1321 | seq_printf(m, "\tseqno = %x [current %x, last %x], %dms ago\n", |
Chris Wilson | 89531e7 | 2019-02-26 09:49:19 +0000 | [diff] [blame] | 1322 | engine->hangcheck.last_seqno, |
| 1323 | seqno[id], |
| 1324 | engine->hangcheck.next_seqno, |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame] | 1325 | jiffies_to_msecs(jiffies - |
| 1326 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1327 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1328 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1329 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1330 | (long long)acthd[id]); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1331 | |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1332 | if (engine->id == RCS0) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1333 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1334 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1335 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1336 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1337 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1338 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1339 | i915_instdone_info(dev_priv, m, |
| 1340 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1341 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | return 0; |
| 1345 | } |
| 1346 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1347 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1348 | { |
| 1349 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1350 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1351 | struct intel_engine_cs *engine; |
| 1352 | enum intel_engine_id id; |
| 1353 | |
| 1354 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1355 | |
| 1356 | for_each_engine(engine, dev_priv, id) { |
| 1357 | seq_printf(m, "%s = %u\n", engine->name, |
| 1358 | i915_reset_engine_count(error, engine)); |
| 1359 | } |
| 1360 | |
| 1361 | return 0; |
| 1362 | } |
| 1363 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1364 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1365 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1366 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1367 | u32 rgvmodectl, rstdbyctl; |
| 1368 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1369 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1370 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1371 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1372 | crstandvid = I915_READ16(CRSTANDVID); |
| 1373 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1374 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1375 | seq_printf(m, "Boost freq: %d\n", |
| 1376 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1377 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1378 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1379 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1380 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1381 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1382 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1383 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1384 | seq_printf(m, "Starting frequency: P%d\n", |
| 1385 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1386 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1387 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1388 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1389 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1390 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1391 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1392 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1393 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1394 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1395 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1396 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1397 | break; |
| 1398 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1399 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1400 | break; |
| 1401 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1402 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1403 | break; |
| 1404 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1405 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1406 | break; |
| 1407 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1408 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1409 | break; |
| 1410 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1411 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1412 | break; |
| 1413 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1414 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1415 | break; |
| 1416 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1417 | |
| 1418 | return 0; |
| 1419 | } |
| 1420 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1421 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1422 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1423 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1424 | struct intel_uncore *uncore = &i915->uncore; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1425 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1426 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1427 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1428 | seq_printf(m, "user.bypass_count = %u\n", |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1429 | uncore->user_forcewake.count); |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1430 | |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1431 | for_each_fw_domain(fw_domain, uncore, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1432 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1433 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1434 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1435 | |
| 1436 | return 0; |
| 1437 | } |
| 1438 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1439 | static void print_rc6_res(struct seq_file *m, |
| 1440 | const char *title, |
| 1441 | const i915_reg_t reg) |
| 1442 | { |
| 1443 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1444 | |
| 1445 | seq_printf(m, "%s %u (%llu us)\n", |
| 1446 | title, I915_READ(reg), |
| 1447 | intel_rc6_residency_us(dev_priv, reg)); |
| 1448 | } |
| 1449 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1450 | static int vlv_drpc_info(struct seq_file *m) |
| 1451 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1452 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1453 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1454 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1455 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1456 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1457 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1458 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1459 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1460 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1461 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1462 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1463 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1464 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1465 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1466 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1467 | 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] | 1468 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1469 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1470 | } |
| 1471 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1472 | static int gen6_drpc_info(struct seq_file *m) |
| 1473 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1474 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1475 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1476 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1477 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1478 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1479 | 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] | 1480 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1481 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1482 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1483 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1484 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1485 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1486 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1487 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1488 | mutex_lock(&dev_priv->pcu_lock); |
| 1489 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, |
| 1490 | &rc6vids); |
| 1491 | mutex_unlock(&dev_priv->pcu_lock); |
| 1492 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1493 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1494 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1495 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1496 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1497 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1498 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1499 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1500 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1501 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1502 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1503 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1504 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1505 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1506 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1507 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1508 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1509 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1510 | case GEN6_RC0: |
| 1511 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1512 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1513 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1514 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1515 | break; |
| 1516 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1517 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1518 | break; |
| 1519 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1520 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1521 | break; |
| 1522 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1523 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1524 | break; |
| 1525 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1526 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1527 | break; |
| 1528 | } |
| 1529 | |
| 1530 | seq_printf(m, "Core Power Down: %s\n", |
| 1531 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1532 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1533 | seq_printf(m, "Render Power Well: %s\n", |
| 1534 | (gen9_powergate_status & |
| 1535 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1536 | seq_printf(m, "Media Power Well: %s\n", |
| 1537 | (gen9_powergate_status & |
| 1538 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1539 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1540 | |
| 1541 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1542 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1543 | GEN6_GT_GFX_RC6_LOCKED); |
| 1544 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1545 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1546 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1547 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1548 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1549 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1550 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1551 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1552 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1553 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1554 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
| 1555 | } |
| 1556 | |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1557 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1558 | } |
| 1559 | |
| 1560 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1561 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1562 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1563 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1564 | int err = -ENODEV; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1565 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1566 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1567 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 1568 | err = vlv_drpc_info(m); |
| 1569 | else if (INTEL_GEN(dev_priv) >= 6) |
| 1570 | err = gen6_drpc_info(m); |
| 1571 | else |
| 1572 | err = ironlake_drpc_info(m); |
| 1573 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1574 | |
| 1575 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1576 | } |
| 1577 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1578 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1579 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1580 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1581 | |
| 1582 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1583 | dev_priv->fb_tracking.busy_bits); |
| 1584 | |
| 1585 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1586 | dev_priv->fb_tracking.flip_bits); |
| 1587 | |
| 1588 | return 0; |
| 1589 | } |
| 1590 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1591 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1592 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1593 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1594 | struct intel_fbc *fbc = &dev_priv->fbc; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1595 | intel_wakeref_t wakeref; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1596 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1597 | if (!HAS_FBC(dev_priv)) |
| 1598 | return -ENODEV; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1599 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1600 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1601 | mutex_lock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1602 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1603 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1604 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1605 | else |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1606 | seq_printf(m, "FBC disabled: %s\n", fbc->no_fbc_reason); |
| 1607 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1608 | if (intel_fbc_is_active(dev_priv)) { |
| 1609 | u32 mask; |
| 1610 | |
| 1611 | if (INTEL_GEN(dev_priv) >= 8) |
| 1612 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1613 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1614 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1615 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1616 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1617 | else if (IS_G4X(dev_priv)) |
| 1618 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1619 | else |
| 1620 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1621 | FBC_STAT_COMPRESSED); |
| 1622 | |
| 1623 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1624 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1625 | |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1626 | mutex_unlock(&fbc->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1627 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1628 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1629 | return 0; |
| 1630 | } |
| 1631 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1632 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1633 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1634 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1635 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1636 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1637 | return -ENODEV; |
| 1638 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1639 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1640 | |
| 1641 | return 0; |
| 1642 | } |
| 1643 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1644 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1645 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1646 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1647 | u32 reg; |
| 1648 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1649 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1650 | return -ENODEV; |
| 1651 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1652 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1653 | |
| 1654 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1655 | dev_priv->fbc.false_color = val; |
| 1656 | |
| 1657 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1658 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1659 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1660 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1661 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1662 | return 0; |
| 1663 | } |
| 1664 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1665 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1666 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1667 | "%llu\n"); |
| 1668 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1669 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1670 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1671 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1672 | intel_wakeref_t wakeref; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1673 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1674 | if (!HAS_IPS(dev_priv)) |
| 1675 | return -ENODEV; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1676 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1677 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1678 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1679 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1680 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1681 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1682 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1683 | seq_puts(m, "Currently: unknown\n"); |
| 1684 | } else { |
| 1685 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1686 | seq_puts(m, "Currently: enabled\n"); |
| 1687 | else |
| 1688 | seq_puts(m, "Currently: disabled\n"); |
| 1689 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1690 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1691 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1692 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1693 | return 0; |
| 1694 | } |
| 1695 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1696 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1697 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1698 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1699 | intel_wakeref_t wakeref; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1700 | bool sr_enabled = false; |
| 1701 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1702 | wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1703 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1704 | if (INTEL_GEN(dev_priv) >= 9) |
| 1705 | /* no global SR status; inspect per-plane WM */; |
| 1706 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1707 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1708 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1709 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1710 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1711 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1712 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1713 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1714 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1715 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1716 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1717 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1718 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1719 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1720 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1721 | |
| 1722 | return 0; |
| 1723 | } |
| 1724 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1725 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1726 | { |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1727 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1728 | intel_wakeref_t wakeref; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1729 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1730 | if (!IS_GEN(i915, 5)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1731 | return -ENODEV; |
| 1732 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1733 | with_intel_runtime_pm(i915, wakeref) { |
| 1734 | unsigned long temp, chipset, gfx; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1735 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1736 | temp = i915_mch_val(i915); |
| 1737 | chipset = i915_chipset_val(i915); |
| 1738 | gfx = i915_gfx_val(i915); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1739 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1740 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1741 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1742 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1743 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1744 | } |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1745 | |
| 1746 | return 0; |
| 1747 | } |
| 1748 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1749 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1750 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1751 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1752 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1753 | unsigned int max_gpu_freq, min_gpu_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1754 | intel_wakeref_t wakeref; |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1755 | int gpu_freq, ia_freq; |
| 1756 | int ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1757 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1758 | if (!HAS_LLC(dev_priv)) |
| 1759 | return -ENODEV; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1760 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1761 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1762 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1763 | ret = mutex_lock_interruptible(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1764 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1765 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1766 | |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1767 | min_gpu_freq = rps->min_freq; |
| 1768 | max_gpu_freq = rps->max_freq; |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1769 | if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1770 | /* Convert GT frequency to 50 HZ units */ |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1771 | min_gpu_freq /= GEN9_FREQ_SCALER; |
| 1772 | max_gpu_freq /= GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1773 | } |
| 1774 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1775 | 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] | 1776 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1777 | 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] | 1778 | ia_freq = gpu_freq; |
| 1779 | sandybridge_pcode_read(dev_priv, |
| 1780 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1781 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1782 | 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] | 1783 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1784 | (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1785 | INTEL_GEN(dev_priv) >= 10 ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1786 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1787 | ((ia_freq >> 0) & 0xff) * 100, |
| 1788 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1789 | } |
| 1790 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1791 | mutex_unlock(&dev_priv->pcu_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1792 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1793 | out: |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1794 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1795 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1796 | } |
| 1797 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1798 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1799 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1800 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1801 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1802 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1803 | int ret; |
| 1804 | |
| 1805 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1806 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1807 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1808 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1809 | if (opregion->header) |
| 1810 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1811 | |
| 1812 | mutex_unlock(&dev->struct_mutex); |
| 1813 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1814 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1815 | return 0; |
| 1816 | } |
| 1817 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1818 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1819 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1820 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1821 | |
| 1822 | if (opregion->vbt) |
| 1823 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1824 | |
| 1825 | return 0; |
| 1826 | } |
| 1827 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1828 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1829 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1830 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1831 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1832 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1833 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1834 | int ret; |
| 1835 | |
| 1836 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1837 | if (ret) |
| 1838 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1839 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1840 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1841 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1842 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1843 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1844 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1845 | fbdev_fb->base.width, |
| 1846 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1847 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1848 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1849 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1850 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1851 | describe_obj(m, intel_fb_obj(&fbdev_fb->base)); |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1852 | seq_putc(m, '\n'); |
| 1853 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1854 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1855 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1856 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1857 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1858 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1859 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1860 | continue; |
| 1861 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1862 | 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] | 1863 | fb->base.width, |
| 1864 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1865 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1866 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1867 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1868 | drm_framebuffer_read_refcount(&fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1869 | describe_obj(m, intel_fb_obj(&fb->base)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1870 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1871 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1872 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1873 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1874 | |
| 1875 | return 0; |
| 1876 | } |
| 1877 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1878 | 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] | 1879 | { |
Chris Wilson | ef5032a | 2018-03-07 13:42:24 +0000 | [diff] [blame] | 1880 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", |
| 1881 | ring->space, ring->head, ring->tail, ring->emit); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1882 | } |
| 1883 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1884 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1885 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1886 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1887 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1888 | struct i915_gem_context *ctx; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1889 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1890 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1891 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1892 | if (ret) |
| 1893 | return ret; |
| 1894 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1895 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 1896 | struct intel_context *ce; |
| 1897 | |
Chris Wilson | 288f1ce | 2018-09-04 16:31:17 +0100 | [diff] [blame] | 1898 | seq_puts(m, "HW context "); |
| 1899 | if (!list_empty(&ctx->hw_id_link)) |
| 1900 | seq_printf(m, "%x [pin %u]", ctx->hw_id, |
| 1901 | atomic_read(&ctx->hw_id_pin_count)); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1902 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1903 | struct task_struct *task; |
| 1904 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1905 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1906 | if (task) { |
| 1907 | seq_printf(m, "(%s [%d]) ", |
| 1908 | task->comm, task->pid); |
| 1909 | put_task_struct(task); |
| 1910 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1911 | } else if (IS_ERR(ctx->file_priv)) { |
| 1912 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1913 | } else { |
| 1914 | seq_puts(m, "(kernel) "); |
| 1915 | } |
| 1916 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1917 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1918 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1919 | |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 1920 | list_for_each_entry(ce, &ctx->active_engines, active_link) { |
| 1921 | seq_printf(m, "%s: ", ce->engine->name); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1922 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1923 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1924 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1925 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1926 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1927 | } |
| 1928 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1929 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1930 | } |
| 1931 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1932 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1933 | |
| 1934 | return 0; |
| 1935 | } |
| 1936 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1937 | static const char *swizzle_string(unsigned swizzle) |
| 1938 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1939 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1940 | case I915_BIT_6_SWIZZLE_NONE: |
| 1941 | return "none"; |
| 1942 | case I915_BIT_6_SWIZZLE_9: |
| 1943 | return "bit9"; |
| 1944 | case I915_BIT_6_SWIZZLE_9_10: |
| 1945 | return "bit9/bit10"; |
| 1946 | case I915_BIT_6_SWIZZLE_9_11: |
| 1947 | return "bit9/bit11"; |
| 1948 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1949 | return "bit9/bit10/bit11"; |
| 1950 | case I915_BIT_6_SWIZZLE_9_17: |
| 1951 | return "bit9/bit17"; |
| 1952 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1953 | return "bit9/bit10/bit17"; |
| 1954 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1955 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1956 | } |
| 1957 | |
| 1958 | return "bug"; |
| 1959 | } |
| 1960 | |
| 1961 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1962 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1963 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1964 | intel_wakeref_t wakeref; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1965 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1966 | wakeref = intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1967 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1968 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1969 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1970 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1971 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1972 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 1973 | if (IS_GEN_RANGE(dev_priv, 3, 4)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1974 | seq_printf(m, "DDC = 0x%08x\n", |
| 1975 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1976 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 1977 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1978 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1979 | I915_READ16(C0DRB3)); |
| 1980 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1981 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1982 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1983 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1984 | I915_READ(MAD_DIMM_C0)); |
| 1985 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1986 | I915_READ(MAD_DIMM_C1)); |
| 1987 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1988 | I915_READ(MAD_DIMM_C2)); |
| 1989 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1990 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1991 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 1992 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 1993 | I915_READ(GAMTARBMODE)); |
| 1994 | else |
| 1995 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 1996 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1997 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 1998 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1999 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2000 | |
| 2001 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2002 | seq_puts(m, "L-shaped memory detected\n"); |
| 2003 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2004 | intel_runtime_pm_put(dev_priv, wakeref); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2005 | |
| 2006 | return 0; |
| 2007 | } |
| 2008 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2009 | static const char *rps_power_to_str(unsigned int power) |
| 2010 | { |
| 2011 | static const char * const strings[] = { |
| 2012 | [LOW_POWER] = "low power", |
| 2013 | [BETWEEN] = "mixed", |
| 2014 | [HIGH_POWER] = "high power", |
| 2015 | }; |
| 2016 | |
| 2017 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2018 | return "unknown"; |
| 2019 | |
| 2020 | return strings[power]; |
| 2021 | } |
| 2022 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2023 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2024 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2025 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2026 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2027 | u32 act_freq = rps->cur_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2028 | intel_wakeref_t wakeref; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2029 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2030 | with_intel_runtime_pm_if_in_use(dev_priv, wakeref) { |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2031 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 2032 | mutex_lock(&dev_priv->pcu_lock); |
| 2033 | act_freq = vlv_punit_read(dev_priv, |
| 2034 | PUNIT_REG_GPU_FREQ_STS); |
| 2035 | act_freq = (act_freq >> 8) & 0xff; |
| 2036 | mutex_unlock(&dev_priv->pcu_lock); |
| 2037 | } else { |
| 2038 | act_freq = intel_get_cagf(dev_priv, |
| 2039 | I915_READ(GEN6_RPSTAT1)); |
| 2040 | } |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2041 | } |
| 2042 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2043 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame^] | 2044 | seq_printf(m, "GPU busy? %s\n", yesno(dev_priv->gt.awake)); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2045 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2046 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2047 | seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2048 | seq_printf(m, "Frequency requested %d, actual %d\n", |
| 2049 | intel_gpu_freq(dev_priv, rps->cur_freq), |
| 2050 | intel_gpu_freq(dev_priv, act_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2051 | 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] | 2052 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2053 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2054 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2055 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2056 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2057 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2058 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2059 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2060 | |
Chris Wilson | 62eb3c2 | 2019-02-13 09:25:04 +0000 | [diff] [blame] | 2061 | seq_printf(m, "Wait boosts: %d\n", atomic_read(&rps->boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2062 | |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame^] | 2063 | if (INTEL_GEN(dev_priv) >= 6 && rps->enabled && dev_priv->gt.awake) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2064 | u32 rpup, rpupei; |
| 2065 | u32 rpdown, rpdownei; |
| 2066 | |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 2067 | intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2068 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2069 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2070 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2071 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 2072 | intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2073 | |
| 2074 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2075 | rps_power_to_str(rps->power.mode)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2076 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2077 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2078 | rps->power.up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2079 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2080 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2081 | rps->power.down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2082 | } else { |
| 2083 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2084 | } |
| 2085 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2086 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2087 | } |
| 2088 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2089 | static int i915_llc(struct seq_file *m, void *data) |
| 2090 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2091 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2092 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2093 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2094 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Daniele Ceraolo Spurio | f6ac993 | 2019-03-28 10:45:32 -0700 | [diff] [blame] | 2095 | seq_printf(m, "%s: %uMB\n", edram ? "eDRAM" : "eLLC", |
| 2096 | dev_priv->edram_size_mb); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2097 | |
| 2098 | return 0; |
| 2099 | } |
| 2100 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2101 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2102 | { |
| 2103 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2104 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2105 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2106 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2107 | if (!HAS_HUC(dev_priv)) |
| 2108 | return -ENODEV; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2109 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2110 | p = drm_seq_file_printer(m); |
| 2111 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2112 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2113 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2114 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2115 | |
| 2116 | return 0; |
| 2117 | } |
| 2118 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2119 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2120 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2121 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2122 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2123 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2124 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2125 | if (!HAS_GUC(dev_priv)) |
| 2126 | return -ENODEV; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2127 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2128 | p = drm_seq_file_printer(m); |
| 2129 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2130 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2131 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 2132 | u32 tmp = I915_READ(GUC_STATUS); |
| 2133 | u32 i; |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2134 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2135 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2136 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2137 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2138 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2139 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2140 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2141 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2142 | seq_puts(m, "\nScratch registers:\n"); |
| 2143 | for (i = 0; i < 16; i++) { |
| 2144 | seq_printf(m, "\t%2d: \t0x%x\n", |
| 2145 | i, I915_READ(SOFT_SCRATCH(i))); |
| 2146 | } |
| 2147 | } |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2148 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2149 | return 0; |
| 2150 | } |
| 2151 | |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2152 | static const char * |
| 2153 | stringify_guc_log_type(enum guc_log_buffer_type type) |
| 2154 | { |
| 2155 | switch (type) { |
| 2156 | case GUC_ISR_LOG_BUFFER: |
| 2157 | return "ISR"; |
| 2158 | case GUC_DPC_LOG_BUFFER: |
| 2159 | return "DPC"; |
| 2160 | case GUC_CRASH_DUMP_LOG_BUFFER: |
| 2161 | return "CRASH"; |
| 2162 | default: |
| 2163 | MISSING_CASE(type); |
| 2164 | } |
| 2165 | |
| 2166 | return ""; |
| 2167 | } |
| 2168 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2169 | static void i915_guc_log_info(struct seq_file *m, |
| 2170 | struct drm_i915_private *dev_priv) |
| 2171 | { |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2172 | struct intel_guc_log *log = &dev_priv->guc.log; |
| 2173 | enum guc_log_buffer_type type; |
| 2174 | |
| 2175 | if (!intel_guc_log_relay_enabled(log)) { |
| 2176 | seq_puts(m, "GuC log relay disabled\n"); |
| 2177 | return; |
| 2178 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2179 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2180 | seq_puts(m, "GuC logging stats:\n"); |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2181 | |
Michał Winiarski | 6a96be2 | 2018-03-19 10:53:42 +0100 | [diff] [blame] | 2182 | seq_printf(m, "\tRelay full count: %u\n", |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2183 | log->relay.full_count); |
| 2184 | |
| 2185 | for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { |
| 2186 | seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", |
| 2187 | stringify_guc_log_type(type), |
| 2188 | log->stats[type].flush, |
| 2189 | log->stats[type].sampled_overflow); |
| 2190 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2191 | } |
| 2192 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2193 | static void i915_guc_client_info(struct seq_file *m, |
| 2194 | struct drm_i915_private *dev_priv, |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2195 | struct intel_guc_client *client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2196 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2197 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2198 | enum intel_engine_id id; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 2199 | u64 tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2200 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2201 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2202 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2203 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2204 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2205 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2206 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2207 | u64 submissions = client->submissions[id]; |
| 2208 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2209 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2210 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2211 | } |
| 2212 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2213 | } |
| 2214 | |
| 2215 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2216 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2217 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2218 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2219 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2220 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2221 | return -ENODEV; |
| 2222 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2223 | i915_guc_log_info(m, dev_priv); |
| 2224 | |
| 2225 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2226 | return 0; |
| 2227 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2228 | GEM_BUG_ON(!guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2229 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2230 | seq_printf(m, "\nDoorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2231 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2232 | seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2233 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2234 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2235 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Chris Wilson | e78c917 | 2018-02-07 21:05:42 +0000 | [diff] [blame] | 2236 | if (guc->preempt_client) { |
| 2237 | seq_printf(m, "\nGuC preempt client @ %p:\n", |
| 2238 | guc->preempt_client); |
| 2239 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
| 2240 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2241 | |
| 2242 | /* Add more as required ... */ |
| 2243 | |
| 2244 | return 0; |
| 2245 | } |
| 2246 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2247 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2248 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2249 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2250 | const struct intel_guc *guc = &dev_priv->guc; |
| 2251 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2252 | struct intel_guc_client *client = guc->execbuf_client; |
Chris Wilson | 3a891a6 | 2019-04-01 17:26:39 +0100 | [diff] [blame] | 2253 | intel_engine_mask_t tmp; |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2254 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2255 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2256 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2257 | return -ENODEV; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2258 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2259 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2260 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2261 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2262 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2263 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2264 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2265 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2266 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2267 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2268 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2269 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2270 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2271 | desc->engines_used); |
| 2272 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2273 | desc->db_trigger_phy, |
| 2274 | desc->db_trigger_cpu, |
| 2275 | desc->db_trigger_uk); |
| 2276 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2277 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2278 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2279 | desc->wq_addr, desc->wq_size); |
| 2280 | seq_putc(m, '\n'); |
| 2281 | |
| 2282 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2283 | u32 guc_engine_id = engine->guc_id; |
| 2284 | struct guc_execlist_context *lrc = |
| 2285 | &desc->lrc[guc_engine_id]; |
| 2286 | |
| 2287 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2288 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2289 | lrc->context_desc); |
| 2290 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2291 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2292 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2293 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2294 | seq_putc(m, '\n'); |
| 2295 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2296 | } |
| 2297 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2298 | return 0; |
| 2299 | } |
| 2300 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2301 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2302 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2303 | struct drm_info_node *node = m->private; |
| 2304 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2305 | bool dump_load_err = !!node->info_ent->data; |
| 2306 | struct drm_i915_gem_object *obj = NULL; |
| 2307 | u32 *log; |
| 2308 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2309 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2310 | if (!HAS_GUC(dev_priv)) |
| 2311 | return -ENODEV; |
| 2312 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2313 | if (dump_load_err) |
| 2314 | obj = dev_priv->guc.load_err_log; |
| 2315 | else if (dev_priv->guc.log.vma) |
| 2316 | obj = dev_priv->guc.log.vma->obj; |
| 2317 | |
| 2318 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2319 | return 0; |
| 2320 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2321 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2322 | if (IS_ERR(log)) { |
| 2323 | DRM_DEBUG("Failed to pin object\n"); |
| 2324 | seq_puts(m, "(log data unaccessible)\n"); |
| 2325 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2326 | } |
| 2327 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2328 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2329 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2330 | *(log + i), *(log + i + 1), |
| 2331 | *(log + i + 2), *(log + i + 3)); |
| 2332 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2333 | seq_putc(m, '\n'); |
| 2334 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2335 | i915_gem_object_unpin_map(obj); |
| 2336 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2337 | return 0; |
| 2338 | } |
| 2339 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2340 | static int i915_guc_log_level_get(void *data, u64 *val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2341 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2342 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2343 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2344 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2345 | return -ENODEV; |
| 2346 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2347 | *val = intel_guc_log_get_level(&dev_priv->guc.log); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2348 | |
| 2349 | return 0; |
| 2350 | } |
| 2351 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2352 | static int i915_guc_log_level_set(void *data, u64 val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2353 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2354 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2355 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2356 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2357 | return -ENODEV; |
| 2358 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2359 | return intel_guc_log_set_level(&dev_priv->guc.log, val); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2360 | } |
| 2361 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2362 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, |
| 2363 | i915_guc_log_level_get, i915_guc_log_level_set, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2364 | "%lld\n"); |
| 2365 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2366 | static int i915_guc_log_relay_open(struct inode *inode, struct file *file) |
| 2367 | { |
| 2368 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2369 | |
| 2370 | if (!USES_GUC(dev_priv)) |
| 2371 | return -ENODEV; |
| 2372 | |
| 2373 | file->private_data = &dev_priv->guc.log; |
| 2374 | |
| 2375 | return intel_guc_log_relay_open(&dev_priv->guc.log); |
| 2376 | } |
| 2377 | |
| 2378 | static ssize_t |
| 2379 | i915_guc_log_relay_write(struct file *filp, |
| 2380 | const char __user *ubuf, |
| 2381 | size_t cnt, |
| 2382 | loff_t *ppos) |
| 2383 | { |
| 2384 | struct intel_guc_log *log = filp->private_data; |
| 2385 | |
| 2386 | intel_guc_log_relay_flush(log); |
| 2387 | |
| 2388 | return cnt; |
| 2389 | } |
| 2390 | |
| 2391 | static int i915_guc_log_relay_release(struct inode *inode, struct file *file) |
| 2392 | { |
| 2393 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2394 | |
| 2395 | intel_guc_log_relay_close(&dev_priv->guc.log); |
| 2396 | |
| 2397 | return 0; |
| 2398 | } |
| 2399 | |
| 2400 | static const struct file_operations i915_guc_log_relay_fops = { |
| 2401 | .owner = THIS_MODULE, |
| 2402 | .open = i915_guc_log_relay_open, |
| 2403 | .write = i915_guc_log_relay_write, |
| 2404 | .release = i915_guc_log_relay_release, |
| 2405 | }; |
| 2406 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2407 | static int i915_psr_sink_status_show(struct seq_file *m, void *data) |
| 2408 | { |
| 2409 | u8 val; |
| 2410 | static const char * const sink_status[] = { |
| 2411 | "inactive", |
| 2412 | "transition to active, capture and display", |
| 2413 | "active, display from RFB", |
| 2414 | "active, capture and display on sink device timings", |
| 2415 | "transition to inactive, capture and display, timing re-sync", |
| 2416 | "reserved", |
| 2417 | "reserved", |
| 2418 | "sink internal error", |
| 2419 | }; |
| 2420 | struct drm_connector *connector = m->private; |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2421 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2422 | struct intel_dp *intel_dp = |
| 2423 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2424 | int ret; |
| 2425 | |
| 2426 | if (!CAN_PSR(dev_priv)) { |
| 2427 | seq_puts(m, "PSR Unsupported\n"); |
| 2428 | return -ENODEV; |
| 2429 | } |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2430 | |
| 2431 | if (connector->status != connector_status_connected) |
| 2432 | return -ENODEV; |
| 2433 | |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2434 | ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val); |
| 2435 | |
| 2436 | if (ret == 1) { |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2437 | const char *str = "unknown"; |
| 2438 | |
| 2439 | val &= DP_PSR_SINK_STATE_MASK; |
| 2440 | if (val < ARRAY_SIZE(sink_status)) |
| 2441 | str = sink_status[val]; |
| 2442 | seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str); |
| 2443 | } else { |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2444 | return ret; |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2445 | } |
| 2446 | |
| 2447 | return 0; |
| 2448 | } |
| 2449 | DEFINE_SHOW_ATTRIBUTE(i915_psr_sink_status); |
| 2450 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2451 | static void |
| 2452 | psr_source_status(struct drm_i915_private *dev_priv, struct seq_file *m) |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2453 | { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2454 | u32 val, status_val; |
| 2455 | const char *status = "unknown"; |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2456 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2457 | if (dev_priv->psr.psr2_enabled) { |
| 2458 | static const char * const live_status[] = { |
| 2459 | "IDLE", |
| 2460 | "CAPTURE", |
| 2461 | "CAPTURE_FS", |
| 2462 | "SLEEP", |
| 2463 | "BUFON_FW", |
| 2464 | "ML_UP", |
| 2465 | "SU_STANDBY", |
| 2466 | "FAST_SLEEP", |
| 2467 | "DEEP_SLEEP", |
| 2468 | "BUF_ON", |
| 2469 | "TG_ON" |
| 2470 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2471 | val = I915_READ(EDP_PSR2_STATUS); |
| 2472 | status_val = (val & EDP_PSR2_STATUS_STATE_MASK) >> |
| 2473 | EDP_PSR2_STATUS_STATE_SHIFT; |
| 2474 | if (status_val < ARRAY_SIZE(live_status)) |
| 2475 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2476 | } else { |
| 2477 | static const char * const live_status[] = { |
| 2478 | "IDLE", |
| 2479 | "SRDONACK", |
| 2480 | "SRDENT", |
| 2481 | "BUFOFF", |
| 2482 | "BUFON", |
| 2483 | "AUXACK", |
| 2484 | "SRDOFFACK", |
| 2485 | "SRDENT_ON", |
| 2486 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2487 | val = I915_READ(EDP_PSR_STATUS); |
| 2488 | status_val = (val & EDP_PSR_STATUS_STATE_MASK) >> |
| 2489 | EDP_PSR_STATUS_STATE_SHIFT; |
| 2490 | if (status_val < ARRAY_SIZE(live_status)) |
| 2491 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2492 | } |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2493 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2494 | seq_printf(m, "Source PSR status: %s [0x%08x]\n", status, val); |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2495 | } |
| 2496 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2497 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2498 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2499 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2500 | struct i915_psr *psr = &dev_priv->psr; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2501 | intel_wakeref_t wakeref; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2502 | const char *status; |
| 2503 | bool enabled; |
| 2504 | u32 val; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2505 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2506 | if (!HAS_PSR(dev_priv)) |
| 2507 | return -ENODEV; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2508 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2509 | seq_printf(m, "Sink support: %s", yesno(psr->sink_support)); |
| 2510 | if (psr->dp) |
| 2511 | seq_printf(m, " [0x%02x]", psr->dp->psr_dpcd[0]); |
| 2512 | seq_puts(m, "\n"); |
| 2513 | |
| 2514 | if (!psr->sink_support) |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2515 | return 0; |
| 2516 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2517 | wakeref = intel_runtime_pm_get(dev_priv); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2518 | mutex_lock(&psr->lock); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2519 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2520 | if (psr->enabled) |
| 2521 | status = psr->psr2_enabled ? "PSR2 enabled" : "PSR1 enabled"; |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2522 | else |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2523 | status = "disabled"; |
| 2524 | seq_printf(m, "PSR mode: %s\n", status); |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2525 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2526 | if (!psr->enabled) |
| 2527 | goto unlock; |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2528 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2529 | if (psr->psr2_enabled) { |
| 2530 | val = I915_READ(EDP_PSR2_CTL); |
| 2531 | enabled = val & EDP_PSR2_ENABLE; |
| 2532 | } else { |
| 2533 | val = I915_READ(EDP_PSR_CTL); |
| 2534 | enabled = val & EDP_PSR_ENABLE; |
| 2535 | } |
| 2536 | seq_printf(m, "Source PSR ctl: %s [0x%08x]\n", |
| 2537 | enableddisabled(enabled), val); |
| 2538 | psr_source_status(dev_priv, m); |
| 2539 | seq_printf(m, "Busy frontbuffer bits: 0x%08x\n", |
| 2540 | psr->busy_frontbuffer_bits); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2541 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2542 | /* |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2543 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2544 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2545 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2546 | val = I915_READ(EDP_PSR_PERF_CNT) & EDP_PSR_PERF_CNT_MASK; |
| 2547 | seq_printf(m, "Performance counter: %u\n", val); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2548 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2549 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2550 | if (psr->debug & I915_PSR_DEBUG_IRQ) { |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2551 | seq_printf(m, "Last attempted entry at: %lld\n", |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2552 | psr->last_entry_attempt); |
| 2553 | seq_printf(m, "Last exit at: %lld\n", psr->last_exit); |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2554 | } |
| 2555 | |
José Roberto de Souza | a81f781 | 2019-01-17 12:55:48 -0800 | [diff] [blame] | 2556 | if (psr->psr2_enabled) { |
| 2557 | u32 su_frames_val[3]; |
| 2558 | int frame; |
| 2559 | |
| 2560 | /* |
| 2561 | * Reading all 3 registers before hand to minimize crossing a |
| 2562 | * frame boundary between register reads |
| 2563 | */ |
| 2564 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame += 3) |
| 2565 | su_frames_val[frame / 3] = I915_READ(PSR2_SU_STATUS(frame)); |
| 2566 | |
| 2567 | seq_puts(m, "Frame:\tPSR2 SU blocks:\n"); |
| 2568 | |
| 2569 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame++) { |
| 2570 | u32 su_blocks; |
| 2571 | |
| 2572 | su_blocks = su_frames_val[frame / 3] & |
| 2573 | PSR2_SU_STATUS_MASK(frame); |
| 2574 | su_blocks = su_blocks >> PSR2_SU_STATUS_SHIFT(frame); |
| 2575 | seq_printf(m, "%d\t%d\n", frame, su_blocks); |
| 2576 | } |
| 2577 | } |
| 2578 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2579 | unlock: |
| 2580 | mutex_unlock(&psr->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2581 | intel_runtime_pm_put(dev_priv, wakeref); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2582 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2583 | return 0; |
| 2584 | } |
| 2585 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2586 | static int |
| 2587 | i915_edp_psr_debug_set(void *data, u64 val) |
| 2588 | { |
| 2589 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2590 | intel_wakeref_t wakeref; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2591 | int ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2592 | |
| 2593 | if (!CAN_PSR(dev_priv)) |
| 2594 | return -ENODEV; |
| 2595 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2596 | DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2597 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2598 | wakeref = intel_runtime_pm_get(dev_priv); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2599 | |
José Roberto de Souza | 23ec9f5 | 2019-02-06 13:18:45 -0800 | [diff] [blame] | 2600 | ret = intel_psr_debug_set(dev_priv, val); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2601 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2602 | intel_runtime_pm_put(dev_priv, wakeref); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2603 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2604 | return ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2605 | } |
| 2606 | |
| 2607 | static int |
| 2608 | i915_edp_psr_debug_get(void *data, u64 *val) |
| 2609 | { |
| 2610 | struct drm_i915_private *dev_priv = data; |
| 2611 | |
| 2612 | if (!CAN_PSR(dev_priv)) |
| 2613 | return -ENODEV; |
| 2614 | |
| 2615 | *val = READ_ONCE(dev_priv->psr.debug); |
| 2616 | return 0; |
| 2617 | } |
| 2618 | |
| 2619 | DEFINE_SIMPLE_ATTRIBUTE(i915_edp_psr_debug_fops, |
| 2620 | i915_edp_psr_debug_get, i915_edp_psr_debug_set, |
| 2621 | "%llu\n"); |
| 2622 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2623 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2624 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2625 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2626 | unsigned long long power; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2627 | intel_wakeref_t wakeref; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2628 | u32 units; |
| 2629 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2630 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2631 | return -ENODEV; |
| 2632 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2633 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2634 | return -ENODEV; |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2635 | |
| 2636 | units = (power & 0x1f00) >> 8; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2637 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2638 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2639 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2640 | power = (1000000 * power) >> units; /* convert to uJ */ |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2641 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2642 | |
| 2643 | return 0; |
| 2644 | } |
| 2645 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2646 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2647 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2648 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2649 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2650 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2651 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2652 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2653 | |
Chris Wilson | 25c896bd | 2019-01-14 14:21:25 +0000 | [diff] [blame] | 2654 | seq_printf(m, "Runtime power status: %s\n", |
| 2655 | enableddisabled(!dev_priv->power_domains.wakeref)); |
| 2656 | |
Chris Wilson | d9948a1 | 2019-02-28 10:20:35 +0000 | [diff] [blame] | 2657 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2658 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2659 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2660 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2661 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2662 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2663 | #else |
| 2664 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2665 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2666 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2667 | pci_power_name(pdev->current_state), |
| 2668 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2669 | |
Chris Wilson | bd780f3 | 2019-01-14 14:21:09 +0000 | [diff] [blame] | 2670 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) { |
| 2671 | struct drm_printer p = drm_seq_file_printer(m); |
| 2672 | |
| 2673 | print_intel_runtime_pm_wakeref(dev_priv, &p); |
| 2674 | } |
| 2675 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2676 | return 0; |
| 2677 | } |
| 2678 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2679 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2680 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2681 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2682 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2683 | int i; |
| 2684 | |
| 2685 | mutex_lock(&power_domains->lock); |
| 2686 | |
| 2687 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2688 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2689 | struct i915_power_well *power_well; |
| 2690 | enum intel_display_power_domain power_domain; |
| 2691 | |
| 2692 | power_well = &power_domains->power_wells[i]; |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2693 | seq_printf(m, "%-25s %d\n", power_well->desc->name, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2694 | power_well->count); |
| 2695 | |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2696 | for_each_power_domain(power_domain, power_well->desc->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2697 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2698 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2699 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2700 | } |
| 2701 | |
| 2702 | mutex_unlock(&power_domains->lock); |
| 2703 | |
| 2704 | return 0; |
| 2705 | } |
| 2706 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2707 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2708 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2709 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2710 | intel_wakeref_t wakeref; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2711 | struct intel_csr *csr; |
| 2712 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2713 | if (!HAS_CSR(dev_priv)) |
| 2714 | return -ENODEV; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2715 | |
| 2716 | csr = &dev_priv->csr; |
| 2717 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2718 | wakeref = intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2719 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2720 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2721 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2722 | |
| 2723 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2724 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2725 | |
| 2726 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2727 | CSR_VERSION_MINOR(csr->version)); |
| 2728 | |
Imre Deak | 34b2f8d | 2018-10-31 22:02:20 +0200 | [diff] [blame] | 2729 | if (WARN_ON(INTEL_GEN(dev_priv) > 11)) |
| 2730 | goto out; |
| 2731 | |
| 2732 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2733 | I915_READ(IS_BROXTON(dev_priv) ? BXT_CSR_DC3_DC5_COUNT : |
| 2734 | SKL_CSR_DC3_DC5_COUNT)); |
| 2735 | if (!IS_GEN9_LP(dev_priv)) |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2736 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2737 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2738 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2739 | out: |
| 2740 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2741 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2742 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2743 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2744 | intel_runtime_pm_put(dev_priv, wakeref); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2745 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2746 | return 0; |
| 2747 | } |
| 2748 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2749 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2750 | struct drm_display_mode *mode) |
| 2751 | { |
| 2752 | int i; |
| 2753 | |
| 2754 | for (i = 0; i < tabs; i++) |
| 2755 | seq_putc(m, '\t'); |
| 2756 | |
Shayenne Moura | 4fb6bb8 | 2018-12-20 10:27:57 -0200 | [diff] [blame] | 2757 | seq_printf(m, DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2758 | } |
| 2759 | |
| 2760 | static void intel_encoder_info(struct seq_file *m, |
| 2761 | struct intel_crtc *intel_crtc, |
| 2762 | struct intel_encoder *intel_encoder) |
| 2763 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2764 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2765 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2766 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2767 | struct intel_connector *intel_connector; |
| 2768 | struct drm_encoder *encoder; |
| 2769 | |
| 2770 | encoder = &intel_encoder->base; |
| 2771 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2772 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2773 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2774 | struct drm_connector *connector = &intel_connector->base; |
| 2775 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2776 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2777 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2778 | drm_get_connector_status_name(connector->status)); |
| 2779 | if (connector->status == connector_status_connected) { |
| 2780 | struct drm_display_mode *mode = &crtc->mode; |
| 2781 | seq_printf(m, ", mode:\n"); |
| 2782 | intel_seq_print_mode(m, 2, mode); |
| 2783 | } else { |
| 2784 | seq_putc(m, '\n'); |
| 2785 | } |
| 2786 | } |
| 2787 | } |
| 2788 | |
| 2789 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2790 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2791 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2792 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2793 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2794 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2795 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2796 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2797 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2798 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2799 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2800 | fb->base.id, plane_state->src_x >> 16, |
| 2801 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2802 | else |
| 2803 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2804 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2805 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2806 | } |
| 2807 | |
| 2808 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2809 | { |
| 2810 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2811 | |
| 2812 | seq_printf(m, "\tfixed mode:\n"); |
| 2813 | intel_seq_print_mode(m, 2, mode); |
| 2814 | } |
| 2815 | |
| 2816 | static void intel_dp_info(struct seq_file *m, |
| 2817 | struct intel_connector *intel_connector) |
| 2818 | { |
| 2819 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2820 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2821 | |
| 2822 | 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] | 2823 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2824 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2825 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2826 | |
| 2827 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2828 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2829 | } |
| 2830 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2831 | static void intel_dp_mst_info(struct seq_file *m, |
| 2832 | struct intel_connector *intel_connector) |
| 2833 | { |
| 2834 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2835 | struct intel_dp_mst_encoder *intel_mst = |
| 2836 | enc_to_mst(&intel_encoder->base); |
| 2837 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2838 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2839 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2840 | intel_connector->port); |
| 2841 | |
| 2842 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2843 | } |
| 2844 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2845 | static void intel_hdmi_info(struct seq_file *m, |
| 2846 | struct intel_connector *intel_connector) |
| 2847 | { |
| 2848 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2849 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2850 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2851 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | static void intel_lvds_info(struct seq_file *m, |
| 2855 | struct intel_connector *intel_connector) |
| 2856 | { |
| 2857 | intel_panel_info(m, &intel_connector->panel); |
| 2858 | } |
| 2859 | |
| 2860 | static void intel_connector_info(struct seq_file *m, |
| 2861 | struct drm_connector *connector) |
| 2862 | { |
| 2863 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2864 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2865 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2866 | |
| 2867 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2868 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2869 | drm_get_connector_status_name(connector->status)); |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame] | 2870 | |
| 2871 | if (connector->status == connector_status_disconnected) |
| 2872 | return; |
| 2873 | |
| 2874 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2875 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2876 | connector->display_info.width_mm, |
| 2877 | connector->display_info.height_mm); |
| 2878 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2879 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2880 | seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2881 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 2882 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2883 | return; |
| 2884 | |
| 2885 | switch (connector->connector_type) { |
| 2886 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2887 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2888 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2889 | intel_dp_mst_info(m, intel_connector); |
| 2890 | else |
| 2891 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2892 | break; |
| 2893 | case DRM_MODE_CONNECTOR_LVDS: |
| 2894 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2895 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2896 | break; |
| 2897 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2898 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 2899 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2900 | intel_hdmi_info(m, intel_connector); |
| 2901 | break; |
| 2902 | default: |
| 2903 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2904 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2905 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2906 | seq_printf(m, "\tmodes:\n"); |
| 2907 | list_for_each_entry(mode, &connector->modes, head) |
| 2908 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2909 | } |
| 2910 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2911 | static const char *plane_type(enum drm_plane_type type) |
| 2912 | { |
| 2913 | switch (type) { |
| 2914 | case DRM_PLANE_TYPE_OVERLAY: |
| 2915 | return "OVL"; |
| 2916 | case DRM_PLANE_TYPE_PRIMARY: |
| 2917 | return "PRI"; |
| 2918 | case DRM_PLANE_TYPE_CURSOR: |
| 2919 | return "CUR"; |
| 2920 | /* |
| 2921 | * Deliberately omitting default: to generate compiler warnings |
| 2922 | * when a new drm_plane_type gets added. |
| 2923 | */ |
| 2924 | } |
| 2925 | |
| 2926 | return "unknown"; |
| 2927 | } |
| 2928 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2929 | static void plane_rotation(char *buf, size_t bufsize, unsigned int rotation) |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2930 | { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2931 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2932 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2933 | * will print them all to visualize if the values are misused |
| 2934 | */ |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2935 | snprintf(buf, bufsize, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2936 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2937 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 2938 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 2939 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 2940 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 2941 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 2942 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2943 | rotation); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2944 | } |
| 2945 | |
| 2946 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2947 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2948 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2949 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2950 | struct intel_plane *intel_plane; |
| 2951 | |
| 2952 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 2953 | struct drm_plane_state *state; |
| 2954 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2955 | struct drm_format_name_buf format_name; |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2956 | char rot_str[48]; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2957 | |
| 2958 | if (!plane->state) { |
| 2959 | seq_puts(m, "plane->state is NULL!\n"); |
| 2960 | continue; |
| 2961 | } |
| 2962 | |
| 2963 | state = plane->state; |
| 2964 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2965 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 2966 | drm_get_format_name(state->fb->format->format, |
| 2967 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2968 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2969 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2970 | } |
| 2971 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2972 | plane_rotation(rot_str, sizeof(rot_str), state->rotation); |
| 2973 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2974 | 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", |
| 2975 | plane->base.id, |
| 2976 | plane_type(intel_plane->base.type), |
| 2977 | state->crtc_x, state->crtc_y, |
| 2978 | state->crtc_w, state->crtc_h, |
| 2979 | (state->src_x >> 16), |
| 2980 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 2981 | (state->src_y >> 16), |
| 2982 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 2983 | (state->src_w >> 16), |
| 2984 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 2985 | (state->src_h >> 16), |
| 2986 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2987 | format_name.str, |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2988 | rot_str); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2989 | } |
| 2990 | } |
| 2991 | |
| 2992 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2993 | { |
| 2994 | struct intel_crtc_state *pipe_config; |
| 2995 | int num_scalers = intel_crtc->num_scalers; |
| 2996 | int i; |
| 2997 | |
| 2998 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 2999 | |
| 3000 | /* Not all platformas have a scaler */ |
| 3001 | if (num_scalers) { |
| 3002 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3003 | num_scalers, |
| 3004 | pipe_config->scaler_state.scaler_users, |
| 3005 | pipe_config->scaler_state.scaler_id); |
| 3006 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3007 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3008 | struct intel_scaler *sc = |
| 3009 | &pipe_config->scaler_state.scalers[i]; |
| 3010 | |
| 3011 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3012 | i, yesno(sc->in_use), sc->mode); |
| 3013 | } |
| 3014 | seq_puts(m, "\n"); |
| 3015 | } else { |
| 3016 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3017 | } |
| 3018 | } |
| 3019 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3020 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3021 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3022 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3023 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3024 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3025 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3026 | struct drm_connector_list_iter conn_iter; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3027 | intel_wakeref_t wakeref; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3028 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3029 | wakeref = intel_runtime_pm_get(dev_priv); |
| 3030 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3031 | seq_printf(m, "CRTC info\n"); |
| 3032 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3033 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3034 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3035 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3036 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3037 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3038 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3039 | 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] | 3040 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3041 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3042 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3043 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3044 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3045 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3046 | struct intel_plane *cursor = |
| 3047 | to_intel_plane(crtc->base.cursor); |
| 3048 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3049 | intel_crtc_info(m, crtc); |
| 3050 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3051 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3052 | yesno(cursor->base.state->visible), |
| 3053 | cursor->base.state->crtc_x, |
| 3054 | cursor->base.state->crtc_y, |
| 3055 | cursor->base.state->crtc_w, |
| 3056 | cursor->base.state->crtc_h, |
| 3057 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3058 | intel_scaler_info(m, crtc); |
| 3059 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3060 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3061 | |
| 3062 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3063 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3064 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3065 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3066 | } |
| 3067 | |
| 3068 | seq_printf(m, "\n"); |
| 3069 | seq_printf(m, "Connector info\n"); |
| 3070 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3071 | mutex_lock(&dev->mode_config.mutex); |
| 3072 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3073 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3074 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3075 | drm_connector_list_iter_end(&conn_iter); |
| 3076 | mutex_unlock(&dev->mode_config.mutex); |
| 3077 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3078 | intel_runtime_pm_put(dev_priv, wakeref); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3079 | |
| 3080 | return 0; |
| 3081 | } |
| 3082 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3083 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3084 | { |
| 3085 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3086 | struct intel_engine_cs *engine; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3087 | intel_wakeref_t wakeref; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3088 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3089 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3090 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3091 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3092 | |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame^] | 3093 | seq_printf(m, "GT awake? %s [%d]\n", |
| 3094 | yesno(dev_priv->gt.awake), |
| 3095 | atomic_read(&dev_priv->gt.wakeref.count)); |
Lionel Landwerlin | f577a03 | 2017-11-13 23:34:53 +0000 | [diff] [blame] | 3096 | seq_printf(m, "CS timestamp frequency: %u kHz\n", |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3097 | RUNTIME_INFO(dev_priv)->cs_timestamp_frequency_khz); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3098 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3099 | p = drm_seq_file_printer(m); |
| 3100 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 0db18b1 | 2017-12-08 01:23:00 +0000 | [diff] [blame] | 3101 | intel_engine_dump(engine, &p, "%s\n", engine->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3102 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3103 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3104 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3105 | return 0; |
| 3106 | } |
| 3107 | |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3108 | static int i915_rcs_topology(struct seq_file *m, void *unused) |
| 3109 | { |
| 3110 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3111 | struct drm_printer p = drm_seq_file_printer(m); |
| 3112 | |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3113 | intel_device_info_dump_topology(&RUNTIME_INFO(dev_priv)->sseu, &p); |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3114 | |
| 3115 | return 0; |
| 3116 | } |
| 3117 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3118 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3119 | { |
| 3120 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3121 | |
| 3122 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3123 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3124 | |
| 3125 | return 0; |
| 3126 | } |
| 3127 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3128 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3129 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3130 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3131 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3132 | int i; |
| 3133 | |
| 3134 | drm_modeset_lock_all(dev); |
| 3135 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3136 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3137 | |
Lucas De Marchi | 72f775f | 2018-03-20 15:06:34 -0700 | [diff] [blame] | 3138 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->info->name, |
Lucas De Marchi | 0823eb9 | 2018-03-20 15:06:35 -0700 | [diff] [blame] | 3139 | pll->info->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3140 | 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] | 3141 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3142 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3143 | 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] | 3144 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3145 | pll->state.hw_state.dpll_md); |
| 3146 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3147 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3148 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Paulo Zanoni | c27e917 | 2018-04-27 16:14:36 -0700 | [diff] [blame] | 3149 | seq_printf(m, " cfgcr0: 0x%08x\n", pll->state.hw_state.cfgcr0); |
| 3150 | seq_printf(m, " cfgcr1: 0x%08x\n", pll->state.hw_state.cfgcr1); |
| 3151 | seq_printf(m, " mg_refclkin_ctl: 0x%08x\n", |
| 3152 | pll->state.hw_state.mg_refclkin_ctl); |
| 3153 | seq_printf(m, " mg_clktop2_coreclkctl1: 0x%08x\n", |
| 3154 | pll->state.hw_state.mg_clktop2_coreclkctl1); |
| 3155 | seq_printf(m, " mg_clktop2_hsclkctl: 0x%08x\n", |
| 3156 | pll->state.hw_state.mg_clktop2_hsclkctl); |
| 3157 | seq_printf(m, " mg_pll_div0: 0x%08x\n", |
| 3158 | pll->state.hw_state.mg_pll_div0); |
| 3159 | seq_printf(m, " mg_pll_div1: 0x%08x\n", |
| 3160 | pll->state.hw_state.mg_pll_div1); |
| 3161 | seq_printf(m, " mg_pll_lf: 0x%08x\n", |
| 3162 | pll->state.hw_state.mg_pll_lf); |
| 3163 | seq_printf(m, " mg_pll_frac_lock: 0x%08x\n", |
| 3164 | pll->state.hw_state.mg_pll_frac_lock); |
| 3165 | seq_printf(m, " mg_pll_ssc: 0x%08x\n", |
| 3166 | pll->state.hw_state.mg_pll_ssc); |
| 3167 | seq_printf(m, " mg_pll_bias: 0x%08x\n", |
| 3168 | pll->state.hw_state.mg_pll_bias); |
| 3169 | seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", |
| 3170 | pll->state.hw_state.mg_pll_tdc_coldst_bias); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3171 | } |
| 3172 | drm_modeset_unlock_all(dev); |
| 3173 | |
| 3174 | return 0; |
| 3175 | } |
| 3176 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3177 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3178 | { |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3179 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 3180 | const struct i915_wa_list *wal = &i915->engine[RCS0]->ctx_wa_list; |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3181 | struct i915_wa *wa; |
| 3182 | unsigned int i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3183 | |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3184 | seq_printf(m, "Workarounds applied: %u\n", wal->count); |
| 3185 | for (i = 0, wa = wal->list; i < wal->count; i++, wa++) |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3186 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n", |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3187 | i915_mmio_reg_offset(wa->reg), wa->val, wa->mask); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3188 | |
| 3189 | return 0; |
| 3190 | } |
| 3191 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3192 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3193 | { |
| 3194 | struct drm_i915_private *dev_priv = m->private; |
| 3195 | |
| 3196 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3197 | yesno(dev_priv->ipc_enabled)); |
| 3198 | return 0; |
| 3199 | } |
| 3200 | |
| 3201 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3202 | { |
| 3203 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3204 | |
| 3205 | if (!HAS_IPC(dev_priv)) |
| 3206 | return -ENODEV; |
| 3207 | |
| 3208 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3209 | } |
| 3210 | |
| 3211 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3212 | size_t len, loff_t *offp) |
| 3213 | { |
| 3214 | struct seq_file *m = file->private_data; |
| 3215 | struct drm_i915_private *dev_priv = m->private; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3216 | intel_wakeref_t wakeref; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3217 | bool enable; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3218 | int ret; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3219 | |
| 3220 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3221 | if (ret < 0) |
| 3222 | return ret; |
| 3223 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3224 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3225 | if (!dev_priv->ipc_enabled && enable) |
| 3226 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3227 | dev_priv->wm.distrust_bios_wm = true; |
| 3228 | dev_priv->ipc_enabled = enable; |
| 3229 | intel_enable_ipc(dev_priv); |
| 3230 | } |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3231 | |
| 3232 | return len; |
| 3233 | } |
| 3234 | |
| 3235 | static const struct file_operations i915_ipc_status_fops = { |
| 3236 | .owner = THIS_MODULE, |
| 3237 | .open = i915_ipc_status_open, |
| 3238 | .read = seq_read, |
| 3239 | .llseek = seq_lseek, |
| 3240 | .release = single_release, |
| 3241 | .write = i915_ipc_status_write |
| 3242 | }; |
| 3243 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3244 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3245 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3246 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3247 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3248 | struct skl_ddb_entry *entry; |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3249 | struct intel_crtc *crtc; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3250 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3251 | if (INTEL_GEN(dev_priv) < 9) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 3252 | return -ENODEV; |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3253 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3254 | drm_modeset_lock_all(dev); |
| 3255 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3256 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3257 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3258 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
| 3259 | struct intel_crtc_state *crtc_state = |
| 3260 | to_intel_crtc_state(crtc->base.state); |
| 3261 | enum pipe pipe = crtc->pipe; |
| 3262 | enum plane_id plane_id; |
| 3263 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3264 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3265 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3266 | for_each_plane_id_on_crtc(crtc, plane_id) { |
| 3267 | entry = &crtc_state->wm.skl.plane_ddb_y[plane_id]; |
| 3268 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane_id + 1, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3269 | entry->start, entry->end, |
| 3270 | skl_ddb_entry_size(entry)); |
| 3271 | } |
| 3272 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3273 | entry = &crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3274 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3275 | entry->end, skl_ddb_entry_size(entry)); |
| 3276 | } |
| 3277 | |
| 3278 | drm_modeset_unlock_all(dev); |
| 3279 | |
| 3280 | return 0; |
| 3281 | } |
| 3282 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3283 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3284 | struct drm_device *dev, |
| 3285 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3286 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3287 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3288 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3289 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3290 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3291 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3292 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3293 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3294 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3295 | if (connector->state->crtc != &intel_crtc->base) |
| 3296 | continue; |
| 3297 | |
| 3298 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3299 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3300 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3301 | |
| 3302 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3303 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3304 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3305 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3306 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3307 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3308 | else |
| 3309 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3310 | |
| 3311 | seq_puts(m, "\n\n"); |
| 3312 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3313 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3314 | struct intel_panel *panel; |
| 3315 | |
| 3316 | mutex_lock(&drrs->mutex); |
| 3317 | /* DRRS Supported */ |
| 3318 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3319 | |
| 3320 | /* disable_drrs() will make drrs->dp NULL */ |
| 3321 | if (!drrs->dp) { |
C, Ramalingam | ce6e213 | 2017-11-20 09:53:47 +0530 | [diff] [blame] | 3322 | seq_puts(m, "Idleness DRRS: Disabled\n"); |
| 3323 | if (dev_priv->psr.enabled) |
| 3324 | seq_puts(m, |
| 3325 | "\tAs PSR is enabled, DRRS is not enabled\n"); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3326 | mutex_unlock(&drrs->mutex); |
| 3327 | return; |
| 3328 | } |
| 3329 | |
| 3330 | panel = &drrs->dp->attached_connector->panel; |
| 3331 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3332 | drrs->busy_frontbuffer_bits); |
| 3333 | |
| 3334 | seq_puts(m, "\n\t\t"); |
| 3335 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3336 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3337 | vrefresh = panel->fixed_mode->vrefresh; |
| 3338 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3339 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3340 | vrefresh = panel->downclock_mode->vrefresh; |
| 3341 | } else { |
| 3342 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3343 | drrs->refresh_rate_type); |
| 3344 | mutex_unlock(&drrs->mutex); |
| 3345 | return; |
| 3346 | } |
| 3347 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3348 | |
| 3349 | seq_puts(m, "\n\t\t"); |
| 3350 | mutex_unlock(&drrs->mutex); |
| 3351 | } else { |
| 3352 | /* DRRS not supported. Print the VBT parameter*/ |
| 3353 | seq_puts(m, "\tDRRS Supported : No"); |
| 3354 | } |
| 3355 | seq_puts(m, "\n"); |
| 3356 | } |
| 3357 | |
| 3358 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3359 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3360 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3361 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3362 | struct intel_crtc *intel_crtc; |
| 3363 | int active_crtc_cnt = 0; |
| 3364 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3365 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3366 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3367 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3368 | active_crtc_cnt++; |
| 3369 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3370 | |
| 3371 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3372 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3373 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3374 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3375 | |
| 3376 | if (!active_crtc_cnt) |
| 3377 | seq_puts(m, "No active crtc found\n"); |
| 3378 | |
| 3379 | return 0; |
| 3380 | } |
| 3381 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3382 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3383 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3384 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3385 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3386 | struct intel_encoder *intel_encoder; |
| 3387 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3388 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3389 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3390 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3391 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3392 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3393 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3394 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3395 | |
| 3396 | intel_encoder = intel_attached_encoder(connector); |
| 3397 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3398 | continue; |
| 3399 | |
| 3400 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3401 | if (!intel_dig_port->dp.can_mst) |
| 3402 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3403 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3404 | seq_printf(m, "MST Source Port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3405 | port_name(intel_dig_port->base.port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3406 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3407 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3408 | drm_connector_list_iter_end(&conn_iter); |
| 3409 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3410 | return 0; |
| 3411 | } |
| 3412 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3413 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3414 | const char __user *ubuf, |
| 3415 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3416 | { |
| 3417 | char *input_buffer; |
| 3418 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3419 | struct drm_device *dev; |
| 3420 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3421 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3422 | struct intel_dp *intel_dp; |
| 3423 | int val = 0; |
| 3424 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3425 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3426 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3427 | if (len == 0) |
| 3428 | return 0; |
| 3429 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3430 | input_buffer = memdup_user_nul(ubuf, len); |
| 3431 | if (IS_ERR(input_buffer)) |
| 3432 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3433 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3434 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3435 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3436 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3437 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3438 | struct intel_encoder *encoder; |
| 3439 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3440 | if (connector->connector_type != |
| 3441 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3442 | continue; |
| 3443 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3444 | encoder = to_intel_encoder(connector->encoder); |
| 3445 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3446 | continue; |
| 3447 | |
| 3448 | if (encoder && connector->status == connector_status_connected) { |
| 3449 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3450 | status = kstrtoint(input_buffer, 10, &val); |
| 3451 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3452 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3453 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3454 | /* To prevent erroneous activation of the compliance |
| 3455 | * testing code, only accept an actual value of 1 here |
| 3456 | */ |
| 3457 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3458 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3459 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3460 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3461 | } |
| 3462 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3463 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3464 | kfree(input_buffer); |
| 3465 | if (status < 0) |
| 3466 | return status; |
| 3467 | |
| 3468 | *offp += len; |
| 3469 | return len; |
| 3470 | } |
| 3471 | |
| 3472 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3473 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3474 | struct drm_i915_private *dev_priv = m->private; |
| 3475 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3476 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3477 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3478 | struct intel_dp *intel_dp; |
| 3479 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3480 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3481 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3482 | struct intel_encoder *encoder; |
| 3483 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3484 | if (connector->connector_type != |
| 3485 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3486 | continue; |
| 3487 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3488 | encoder = to_intel_encoder(connector->encoder); |
| 3489 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3490 | continue; |
| 3491 | |
| 3492 | if (encoder && connector->status == connector_status_connected) { |
| 3493 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3494 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3495 | seq_puts(m, "1"); |
| 3496 | else |
| 3497 | seq_puts(m, "0"); |
| 3498 | } else |
| 3499 | seq_puts(m, "0"); |
| 3500 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3501 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3502 | |
| 3503 | return 0; |
| 3504 | } |
| 3505 | |
| 3506 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3507 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3508 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3509 | return single_open(file, i915_displayport_test_active_show, |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3510 | inode->i_private); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3511 | } |
| 3512 | |
| 3513 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3514 | .owner = THIS_MODULE, |
| 3515 | .open = i915_displayport_test_active_open, |
| 3516 | .read = seq_read, |
| 3517 | .llseek = seq_lseek, |
| 3518 | .release = single_release, |
| 3519 | .write = i915_displayport_test_active_write |
| 3520 | }; |
| 3521 | |
| 3522 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3523 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3524 | struct drm_i915_private *dev_priv = m->private; |
| 3525 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3526 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3527 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3528 | struct intel_dp *intel_dp; |
| 3529 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3530 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3531 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3532 | struct intel_encoder *encoder; |
| 3533 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3534 | if (connector->connector_type != |
| 3535 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3536 | continue; |
| 3537 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3538 | encoder = to_intel_encoder(connector->encoder); |
| 3539 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3540 | continue; |
| 3541 | |
| 3542 | if (encoder && connector->status == connector_status_connected) { |
| 3543 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3544 | if (intel_dp->compliance.test_type == |
| 3545 | DP_TEST_LINK_EDID_READ) |
| 3546 | seq_printf(m, "%lx", |
| 3547 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3548 | else if (intel_dp->compliance.test_type == |
| 3549 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3550 | seq_printf(m, "hdisplay: %d\n", |
| 3551 | intel_dp->compliance.test_data.hdisplay); |
| 3552 | seq_printf(m, "vdisplay: %d\n", |
| 3553 | intel_dp->compliance.test_data.vdisplay); |
| 3554 | seq_printf(m, "bpc: %u\n", |
| 3555 | intel_dp->compliance.test_data.bpc); |
| 3556 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3557 | } else |
| 3558 | seq_puts(m, "0"); |
| 3559 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3560 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3561 | |
| 3562 | return 0; |
| 3563 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3564 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3565 | |
| 3566 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3567 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3568 | struct drm_i915_private *dev_priv = m->private; |
| 3569 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3570 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3571 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3572 | struct intel_dp *intel_dp; |
| 3573 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3574 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3575 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3576 | struct intel_encoder *encoder; |
| 3577 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3578 | if (connector->connector_type != |
| 3579 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3580 | continue; |
| 3581 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3582 | encoder = to_intel_encoder(connector->encoder); |
| 3583 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3584 | continue; |
| 3585 | |
| 3586 | if (encoder && connector->status == connector_status_connected) { |
| 3587 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3588 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3589 | } else |
| 3590 | seq_puts(m, "0"); |
| 3591 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3592 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3593 | |
| 3594 | return 0; |
| 3595 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3596 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3597 | |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3598 | static void wm_latency_show(struct seq_file *m, const u16 wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3599 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3600 | struct drm_i915_private *dev_priv = m->private; |
| 3601 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3602 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3603 | int num_levels; |
| 3604 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3605 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3606 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3607 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3608 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3609 | else if (IS_G4X(dev_priv)) |
| 3610 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3611 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3612 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3613 | |
| 3614 | drm_modeset_lock_all(dev); |
| 3615 | |
| 3616 | for (level = 0; level < num_levels; level++) { |
| 3617 | unsigned int latency = wm[level]; |
| 3618 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3619 | /* |
| 3620 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3621 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3622 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3623 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3624 | IS_VALLEYVIEW(dev_priv) || |
| 3625 | IS_CHERRYVIEW(dev_priv) || |
| 3626 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3627 | latency *= 10; |
| 3628 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3629 | latency *= 5; |
| 3630 | |
| 3631 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3632 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3633 | } |
| 3634 | |
| 3635 | drm_modeset_unlock_all(dev); |
| 3636 | } |
| 3637 | |
| 3638 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3639 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3640 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3641 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3642 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3643 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3644 | latencies = dev_priv->wm.skl_latency; |
| 3645 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3646 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3647 | |
| 3648 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3649 | |
| 3650 | return 0; |
| 3651 | } |
| 3652 | |
| 3653 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3654 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3655 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3656 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3657 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3658 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3659 | latencies = dev_priv->wm.skl_latency; |
| 3660 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3661 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3662 | |
| 3663 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3664 | |
| 3665 | return 0; |
| 3666 | } |
| 3667 | |
| 3668 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3669 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3670 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3671 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3672 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3673 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3674 | latencies = dev_priv->wm.skl_latency; |
| 3675 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3676 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3677 | |
| 3678 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3679 | |
| 3680 | return 0; |
| 3681 | } |
| 3682 | |
| 3683 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3684 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3685 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3686 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3687 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3688 | return -ENODEV; |
| 3689 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3690 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3691 | } |
| 3692 | |
| 3693 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3694 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3695 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3696 | |
Rodrigo Vivi | b2ae318 | 2019-02-04 14:25:38 -0800 | [diff] [blame] | 3697 | if (HAS_GMCH(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3698 | return -ENODEV; |
| 3699 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3700 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3701 | } |
| 3702 | |
| 3703 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3704 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3705 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3706 | |
Rodrigo Vivi | b2ae318 | 2019-02-04 14:25:38 -0800 | [diff] [blame] | 3707 | if (HAS_GMCH(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3708 | return -ENODEV; |
| 3709 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3710 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3711 | } |
| 3712 | |
| 3713 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3714 | size_t len, loff_t *offp, u16 wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3715 | { |
| 3716 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3717 | struct drm_i915_private *dev_priv = m->private; |
| 3718 | struct drm_device *dev = &dev_priv->drm; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3719 | u16 new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3720 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3721 | int level; |
| 3722 | int ret; |
| 3723 | char tmp[32]; |
| 3724 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3725 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3726 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3727 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3728 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3729 | else if (IS_G4X(dev_priv)) |
| 3730 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3731 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3732 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3733 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3734 | if (len >= sizeof(tmp)) |
| 3735 | return -EINVAL; |
| 3736 | |
| 3737 | if (copy_from_user(tmp, ubuf, len)) |
| 3738 | return -EFAULT; |
| 3739 | |
| 3740 | tmp[len] = '\0'; |
| 3741 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3742 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3743 | &new[0], &new[1], &new[2], &new[3], |
| 3744 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3745 | if (ret != num_levels) |
| 3746 | return -EINVAL; |
| 3747 | |
| 3748 | drm_modeset_lock_all(dev); |
| 3749 | |
| 3750 | for (level = 0; level < num_levels; level++) |
| 3751 | wm[level] = new[level]; |
| 3752 | |
| 3753 | drm_modeset_unlock_all(dev); |
| 3754 | |
| 3755 | return len; |
| 3756 | } |
| 3757 | |
| 3758 | |
| 3759 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3760 | size_t len, loff_t *offp) |
| 3761 | { |
| 3762 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3763 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3764 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3765 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3766 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3767 | latencies = dev_priv->wm.skl_latency; |
| 3768 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3769 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3770 | |
| 3771 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3772 | } |
| 3773 | |
| 3774 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3775 | size_t len, loff_t *offp) |
| 3776 | { |
| 3777 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3778 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3779 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3780 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3781 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3782 | latencies = dev_priv->wm.skl_latency; |
| 3783 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3784 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3785 | |
| 3786 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3790 | size_t len, loff_t *offp) |
| 3791 | { |
| 3792 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3793 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3794 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3795 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3796 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3797 | latencies = dev_priv->wm.skl_latency; |
| 3798 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3799 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3800 | |
| 3801 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3802 | } |
| 3803 | |
| 3804 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3805 | .owner = THIS_MODULE, |
| 3806 | .open = pri_wm_latency_open, |
| 3807 | .read = seq_read, |
| 3808 | .llseek = seq_lseek, |
| 3809 | .release = single_release, |
| 3810 | .write = pri_wm_latency_write |
| 3811 | }; |
| 3812 | |
| 3813 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3814 | .owner = THIS_MODULE, |
| 3815 | .open = spr_wm_latency_open, |
| 3816 | .read = seq_read, |
| 3817 | .llseek = seq_lseek, |
| 3818 | .release = single_release, |
| 3819 | .write = spr_wm_latency_write |
| 3820 | }; |
| 3821 | |
| 3822 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3823 | .owner = THIS_MODULE, |
| 3824 | .open = cur_wm_latency_open, |
| 3825 | .read = seq_read, |
| 3826 | .llseek = seq_lseek, |
| 3827 | .release = single_release, |
| 3828 | .write = cur_wm_latency_write |
| 3829 | }; |
| 3830 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3831 | static int |
| 3832 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3833 | { |
Chris Wilson | c41166f | 2019-02-20 14:56:37 +0000 | [diff] [blame] | 3834 | int ret = i915_terminally_wedged(data); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3835 | |
Chris Wilson | c41166f | 2019-02-20 14:56:37 +0000 | [diff] [blame] | 3836 | switch (ret) { |
| 3837 | case -EIO: |
| 3838 | *val = 1; |
| 3839 | return 0; |
| 3840 | case 0: |
| 3841 | *val = 0; |
| 3842 | return 0; |
| 3843 | default: |
| 3844 | return ret; |
| 3845 | } |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3846 | } |
| 3847 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3848 | static int |
| 3849 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3850 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3851 | struct drm_i915_private *i915 = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3852 | |
Chris Wilson | 15cbf00 | 2019-02-08 15:37:06 +0000 | [diff] [blame] | 3853 | /* Flush any previous reset before applying for a new one */ |
| 3854 | wait_event(i915->gpu_error.reset_queue, |
| 3855 | !test_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags)); |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3856 | |
Chris Wilson | ce80075 | 2018-03-20 10:04:49 +0000 | [diff] [blame] | 3857 | i915_handle_error(i915, val, I915_ERROR_CAPTURE, |
| 3858 | "Manually set wedged engine mask = %llx", val); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3859 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3860 | } |
| 3861 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3862 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3863 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3864 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3865 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3866 | #define DROP_UNBOUND BIT(0) |
| 3867 | #define DROP_BOUND BIT(1) |
| 3868 | #define DROP_RETIRE BIT(2) |
| 3869 | #define DROP_ACTIVE BIT(3) |
| 3870 | #define DROP_FREED BIT(4) |
| 3871 | #define DROP_SHRINK_ALL BIT(5) |
| 3872 | #define DROP_IDLE BIT(6) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3873 | #define DROP_RESET_ACTIVE BIT(7) |
| 3874 | #define DROP_RESET_SEQNO BIT(8) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 3875 | #define DROP_ALL (DROP_UNBOUND | \ |
| 3876 | DROP_BOUND | \ |
| 3877 | DROP_RETIRE | \ |
| 3878 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3879 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3880 | DROP_SHRINK_ALL |\ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3881 | DROP_IDLE | \ |
| 3882 | DROP_RESET_ACTIVE | \ |
| 3883 | DROP_RESET_SEQNO) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3884 | static int |
| 3885 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3886 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3887 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3888 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3889 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3890 | } |
| 3891 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3892 | static int |
| 3893 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3894 | { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3895 | struct drm_i915_private *i915 = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3896 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3897 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 3898 | val, val & DROP_ALL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3899 | |
Chris Wilson | ad4062d | 2019-01-28 01:02:18 +0000 | [diff] [blame] | 3900 | if (val & DROP_RESET_ACTIVE && |
| 3901 | wait_for(intel_engines_are_idle(i915), I915_IDLE_ENGINES_TIMEOUT)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3902 | i915_gem_set_wedged(i915); |
| 3903 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3904 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 3905 | * on ioctls on -EAGAIN. */ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3906 | if (val & (DROP_ACTIVE | DROP_RETIRE | DROP_RESET_SEQNO)) { |
Chris Wilson | 6cffeb8 | 2019-03-18 09:51:49 +0000 | [diff] [blame] | 3907 | int ret; |
| 3908 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3909 | ret = mutex_lock_interruptible(&i915->drm.struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3910 | if (ret) |
Chris Wilson | 6cffeb8 | 2019-03-18 09:51:49 +0000 | [diff] [blame] | 3911 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3912 | |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3913 | if (val & DROP_ACTIVE) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3914 | ret = i915_gem_wait_for_idle(i915, |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3915 | I915_WAIT_INTERRUPTIBLE | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 3916 | I915_WAIT_LOCKED, |
| 3917 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3918 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3919 | if (val & DROP_RETIRE) |
| 3920 | i915_retire_requests(i915); |
| 3921 | |
| 3922 | mutex_unlock(&i915->drm.struct_mutex); |
| 3923 | } |
| 3924 | |
Chris Wilson | c41166f | 2019-02-20 14:56:37 +0000 | [diff] [blame] | 3925 | if (val & DROP_RESET_ACTIVE && i915_terminally_wedged(i915)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3926 | i915_handle_error(i915, ALL_ENGINES, 0, NULL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3927 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 3928 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3929 | if (val & DROP_BOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3930 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 3931 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3932 | if (val & DROP_UNBOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3933 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3934 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3935 | if (val & DROP_SHRINK_ALL) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3936 | i915_gem_shrink_all(i915); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 3937 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3938 | |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 3939 | if (val & DROP_IDLE) { |
| 3940 | do { |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame^] | 3941 | flush_delayed_work(&i915->gem.retire_work); |
Chris Wilson | 23c3c3d | 2019-04-24 21:07:14 +0100 | [diff] [blame] | 3942 | drain_delayed_work(&i915->gem.idle_work); |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3943 | } while (READ_ONCE(i915->gt.awake)); |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 3944 | } |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3945 | |
Chris Wilson | c9c70471 | 2018-02-19 22:06:31 +0000 | [diff] [blame] | 3946 | if (val & DROP_FREED) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3947 | i915_gem_drain_freed_objects(i915); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 3948 | |
Chris Wilson | 6cffeb8 | 2019-03-18 09:51:49 +0000 | [diff] [blame] | 3949 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3950 | } |
| 3951 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3952 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 3953 | i915_drop_caches_get, i915_drop_caches_set, |
| 3954 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3955 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3956 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3957 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3958 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3959 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3960 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3961 | u32 snpcr = 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3962 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 3963 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3964 | return -ENODEV; |
| 3965 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3966 | with_intel_runtime_pm(dev_priv, wakeref) |
| 3967 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3968 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3969 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3970 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3971 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3972 | } |
| 3973 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3974 | static int |
| 3975 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3976 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3977 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3978 | intel_wakeref_t wakeref; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3979 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 3980 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3981 | return -ENODEV; |
| 3982 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3983 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3984 | return -EINVAL; |
| 3985 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3986 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3987 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3988 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3989 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3990 | /* Update the cache sharing policy here as well */ |
| 3991 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 3992 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 3993 | snpcr |= val << GEN6_MBC_SNPCR_SHIFT; |
| 3994 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 3995 | } |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3996 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3997 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3998 | } |
| 3999 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4000 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4001 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4002 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4003 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4004 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4005 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4006 | { |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4007 | #define SS_MAX 2 |
| 4008 | const int ss_max = SS_MAX; |
| 4009 | u32 sig1[SS_MAX], sig2[SS_MAX]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4010 | int ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4011 | |
| 4012 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4013 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4014 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4015 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4016 | |
| 4017 | for (ss = 0; ss < ss_max; ss++) { |
| 4018 | unsigned int eu_cnt; |
| 4019 | |
| 4020 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4021 | /* skip disabled subslice */ |
| 4022 | continue; |
| 4023 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4024 | sseu->slice_mask = BIT(0); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4025 | sseu->subslice_mask[0] |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4026 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4027 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4028 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4029 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4030 | sseu->eu_total += eu_cnt; |
| 4031 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4032 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4033 | } |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4034 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4035 | } |
| 4036 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4037 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4038 | struct sseu_dev_info *sseu) |
| 4039 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4040 | #define SS_MAX 6 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4041 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4042 | 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] | 4043 | int s, ss; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4044 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4045 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4046 | /* |
| 4047 | * FIXME: Valid SS Mask respects the spec and read |
Alexandre Belloni | 3c64ea8 | 2018-11-20 16:14:15 +0100 | [diff] [blame] | 4048 | * only valid bits for those registers, excluding reserved |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4049 | * although this seems wrong because it would leave many |
| 4050 | * subslices without ACK. |
| 4051 | */ |
| 4052 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4053 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4054 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4055 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4056 | } |
| 4057 | |
| 4058 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4059 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4060 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4061 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4062 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4063 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4064 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4065 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4066 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4067 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4068 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4069 | /* skip disabled slice */ |
| 4070 | continue; |
| 4071 | |
| 4072 | sseu->slice_mask |= BIT(s); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4073 | sseu->subslice_mask[s] = info->sseu.subslice_mask[s]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4074 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4075 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4076 | unsigned int eu_cnt; |
| 4077 | |
| 4078 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4079 | /* skip disabled subslice */ |
| 4080 | continue; |
| 4081 | |
| 4082 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4083 | eu_mask[ss % 2]); |
| 4084 | sseu->eu_total += eu_cnt; |
| 4085 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4086 | sseu->eu_per_subslice, |
| 4087 | eu_cnt); |
| 4088 | } |
| 4089 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4090 | #undef SS_MAX |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4091 | } |
| 4092 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4093 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4094 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4095 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4096 | #define SS_MAX 3 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4097 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4098 | 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] | 4099 | int s, ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4100 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4101 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4102 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4103 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4104 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4105 | } |
| 4106 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4107 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4108 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4109 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4110 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4111 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4112 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4113 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4114 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4115 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4116 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4117 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4118 | /* skip disabled slice */ |
| 4119 | continue; |
| 4120 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4121 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4122 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4123 | if (IS_GEN9_BC(dev_priv)) |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4124 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4125 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4126 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4127 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4128 | unsigned int eu_cnt; |
| 4129 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4130 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4131 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4132 | /* skip disabled subslice */ |
| 4133 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4134 | |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4135 | sseu->subslice_mask[s] |= BIT(ss); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4136 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4137 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4138 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4139 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4140 | sseu->eu_total += eu_cnt; |
| 4141 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4142 | sseu->eu_per_subslice, |
| 4143 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4144 | } |
| 4145 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4146 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4147 | } |
| 4148 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4149 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4150 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4151 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4152 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4153 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4154 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4155 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4156 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4157 | if (sseu->slice_mask) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4158 | sseu->eu_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4159 | RUNTIME_INFO(dev_priv)->sseu.eu_per_subslice; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4160 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4161 | sseu->subslice_mask[s] = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4162 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4163 | } |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4164 | sseu->eu_total = sseu->eu_per_subslice * |
| 4165 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4166 | |
| 4167 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4168 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 4169 | u8 subslice_7eu = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4170 | RUNTIME_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4171 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4172 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4173 | } |
| 4174 | } |
| 4175 | } |
| 4176 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4177 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4178 | const struct sseu_dev_info *sseu) |
| 4179 | { |
| 4180 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4181 | const char *type = is_available_info ? "Available" : "Enabled"; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4182 | int s; |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4183 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4184 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4185 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4186 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4187 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4188 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4189 | sseu_subslice_total(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4190 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4191 | seq_printf(m, " %s Slice%i subslices: %u\n", type, |
| 4192 | s, hweight8(sseu->subslice_mask[s])); |
| 4193 | } |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4194 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4195 | sseu->eu_total); |
| 4196 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4197 | sseu->eu_per_subslice); |
| 4198 | |
| 4199 | if (!is_available_info) |
| 4200 | return; |
| 4201 | |
| 4202 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4203 | if (HAS_POOLED_EU(dev_priv)) |
| 4204 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4205 | |
| 4206 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4207 | yesno(sseu->has_slice_pg)); |
| 4208 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4209 | yesno(sseu->has_subslice_pg)); |
| 4210 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4211 | yesno(sseu->has_eu_pg)); |
| 4212 | } |
| 4213 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4214 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4215 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4216 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4217 | struct sseu_dev_info sseu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4218 | intel_wakeref_t wakeref; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4219 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4220 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4221 | return -ENODEV; |
| 4222 | |
| 4223 | seq_puts(m, "SSEU Device Info\n"); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4224 | i915_print_sseu_info(m, true, &RUNTIME_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4225 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4226 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4227 | memset(&sseu, 0, sizeof(sseu)); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4228 | sseu.max_slices = RUNTIME_INFO(dev_priv)->sseu.max_slices; |
| 4229 | sseu.max_subslices = RUNTIME_INFO(dev_priv)->sseu.max_subslices; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4230 | sseu.max_eus_per_subslice = |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4231 | RUNTIME_INFO(dev_priv)->sseu.max_eus_per_subslice; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4232 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4233 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4234 | if (IS_CHERRYVIEW(dev_priv)) |
| 4235 | cherryview_sseu_device_status(dev_priv, &sseu); |
| 4236 | else if (IS_BROADWELL(dev_priv)) |
| 4237 | broadwell_sseu_device_status(dev_priv, &sseu); |
| 4238 | else if (IS_GEN(dev_priv, 9)) |
| 4239 | gen9_sseu_device_status(dev_priv, &sseu); |
| 4240 | else if (INTEL_GEN(dev_priv) >= 10) |
| 4241 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4242 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4243 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4244 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4245 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4246 | return 0; |
| 4247 | } |
| 4248 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4249 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4250 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4251 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4252 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4253 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4254 | return 0; |
| 4255 | |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4256 | file->private_data = (void *)(uintptr_t)intel_runtime_pm_get(i915); |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 4257 | intel_uncore_forcewake_user_get(&i915->uncore); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4258 | |
| 4259 | return 0; |
| 4260 | } |
| 4261 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4262 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4263 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4264 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4265 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4266 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4267 | return 0; |
| 4268 | |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 4269 | intel_uncore_forcewake_user_put(&i915->uncore); |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4270 | intel_runtime_pm_put(i915, |
| 4271 | (intel_wakeref_t)(uintptr_t)file->private_data); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4272 | |
| 4273 | return 0; |
| 4274 | } |
| 4275 | |
| 4276 | static const struct file_operations i915_forcewake_fops = { |
| 4277 | .owner = THIS_MODULE, |
| 4278 | .open = i915_forcewake_open, |
| 4279 | .release = i915_forcewake_release, |
| 4280 | }; |
| 4281 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4282 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4283 | { |
| 4284 | struct drm_i915_private *dev_priv = m->private; |
| 4285 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4286 | |
Lyude Paul | 6fc5d78 | 2018-11-20 19:37:17 -0500 | [diff] [blame] | 4287 | /* Synchronize with everything first in case there's been an HPD |
| 4288 | * storm, but we haven't finished handling it in the kernel yet |
| 4289 | */ |
| 4290 | synchronize_irq(dev_priv->drm.irq); |
| 4291 | flush_work(&dev_priv->hotplug.dig_port_work); |
| 4292 | flush_work(&dev_priv->hotplug.hotplug_work); |
| 4293 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4294 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4295 | seq_printf(m, "Detected: %s\n", |
| 4296 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4297 | |
| 4298 | return 0; |
| 4299 | } |
| 4300 | |
| 4301 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4302 | const char __user *ubuf, size_t len, |
| 4303 | loff_t *offp) |
| 4304 | { |
| 4305 | struct seq_file *m = file->private_data; |
| 4306 | struct drm_i915_private *dev_priv = m->private; |
| 4307 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4308 | unsigned int new_threshold; |
| 4309 | int i; |
| 4310 | char *newline; |
| 4311 | char tmp[16]; |
| 4312 | |
| 4313 | if (len >= sizeof(tmp)) |
| 4314 | return -EINVAL; |
| 4315 | |
| 4316 | if (copy_from_user(tmp, ubuf, len)) |
| 4317 | return -EFAULT; |
| 4318 | |
| 4319 | tmp[len] = '\0'; |
| 4320 | |
| 4321 | /* Strip newline, if any */ |
| 4322 | newline = strchr(tmp, '\n'); |
| 4323 | if (newline) |
| 4324 | *newline = '\0'; |
| 4325 | |
| 4326 | if (strcmp(tmp, "reset") == 0) |
| 4327 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4328 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4329 | return -EINVAL; |
| 4330 | |
| 4331 | if (new_threshold > 0) |
| 4332 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4333 | new_threshold); |
| 4334 | else |
| 4335 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4336 | |
| 4337 | spin_lock_irq(&dev_priv->irq_lock); |
| 4338 | hotplug->hpd_storm_threshold = new_threshold; |
| 4339 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4340 | for_each_hpd_pin(i) |
| 4341 | hotplug->stats[i].count = 0; |
| 4342 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4343 | |
| 4344 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4345 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4346 | |
| 4347 | return len; |
| 4348 | } |
| 4349 | |
| 4350 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4351 | { |
| 4352 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4353 | } |
| 4354 | |
| 4355 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4356 | .owner = THIS_MODULE, |
| 4357 | .open = i915_hpd_storm_ctl_open, |
| 4358 | .read = seq_read, |
| 4359 | .llseek = seq_lseek, |
| 4360 | .release = single_release, |
| 4361 | .write = i915_hpd_storm_ctl_write |
| 4362 | }; |
| 4363 | |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4364 | static int i915_hpd_short_storm_ctl_show(struct seq_file *m, void *data) |
| 4365 | { |
| 4366 | struct drm_i915_private *dev_priv = m->private; |
| 4367 | |
| 4368 | seq_printf(m, "Enabled: %s\n", |
| 4369 | yesno(dev_priv->hotplug.hpd_short_storm_enabled)); |
| 4370 | |
| 4371 | return 0; |
| 4372 | } |
| 4373 | |
| 4374 | static int |
| 4375 | i915_hpd_short_storm_ctl_open(struct inode *inode, struct file *file) |
| 4376 | { |
| 4377 | return single_open(file, i915_hpd_short_storm_ctl_show, |
| 4378 | inode->i_private); |
| 4379 | } |
| 4380 | |
| 4381 | static ssize_t i915_hpd_short_storm_ctl_write(struct file *file, |
| 4382 | const char __user *ubuf, |
| 4383 | size_t len, loff_t *offp) |
| 4384 | { |
| 4385 | struct seq_file *m = file->private_data; |
| 4386 | struct drm_i915_private *dev_priv = m->private; |
| 4387 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4388 | char *newline; |
| 4389 | char tmp[16]; |
| 4390 | int i; |
| 4391 | bool new_state; |
| 4392 | |
| 4393 | if (len >= sizeof(tmp)) |
| 4394 | return -EINVAL; |
| 4395 | |
| 4396 | if (copy_from_user(tmp, ubuf, len)) |
| 4397 | return -EFAULT; |
| 4398 | |
| 4399 | tmp[len] = '\0'; |
| 4400 | |
| 4401 | /* Strip newline, if any */ |
| 4402 | newline = strchr(tmp, '\n'); |
| 4403 | if (newline) |
| 4404 | *newline = '\0'; |
| 4405 | |
| 4406 | /* Reset to the "default" state for this system */ |
| 4407 | if (strcmp(tmp, "reset") == 0) |
| 4408 | new_state = !HAS_DP_MST(dev_priv); |
| 4409 | else if (kstrtobool(tmp, &new_state) != 0) |
| 4410 | return -EINVAL; |
| 4411 | |
| 4412 | DRM_DEBUG_KMS("%sabling HPD short storm detection\n", |
| 4413 | new_state ? "En" : "Dis"); |
| 4414 | |
| 4415 | spin_lock_irq(&dev_priv->irq_lock); |
| 4416 | hotplug->hpd_short_storm_enabled = new_state; |
| 4417 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4418 | for_each_hpd_pin(i) |
| 4419 | hotplug->stats[i].count = 0; |
| 4420 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4421 | |
| 4422 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4423 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4424 | |
| 4425 | return len; |
| 4426 | } |
| 4427 | |
| 4428 | static const struct file_operations i915_hpd_short_storm_ctl_fops = { |
| 4429 | .owner = THIS_MODULE, |
| 4430 | .open = i915_hpd_short_storm_ctl_open, |
| 4431 | .read = seq_read, |
| 4432 | .llseek = seq_lseek, |
| 4433 | .release = single_release, |
| 4434 | .write = i915_hpd_short_storm_ctl_write, |
| 4435 | }; |
| 4436 | |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4437 | static int i915_drrs_ctl_set(void *data, u64 val) |
| 4438 | { |
| 4439 | struct drm_i915_private *dev_priv = data; |
| 4440 | struct drm_device *dev = &dev_priv->drm; |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4441 | struct intel_crtc *crtc; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4442 | |
| 4443 | if (INTEL_GEN(dev_priv) < 7) |
| 4444 | return -ENODEV; |
| 4445 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4446 | for_each_intel_crtc(dev, crtc) { |
| 4447 | struct drm_connector_list_iter conn_iter; |
| 4448 | struct intel_crtc_state *crtc_state; |
| 4449 | struct drm_connector *connector; |
| 4450 | struct drm_crtc_commit *commit; |
| 4451 | int ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4452 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4453 | ret = drm_modeset_lock_single_interruptible(&crtc->base.mutex); |
| 4454 | if (ret) |
| 4455 | return ret; |
| 4456 | |
| 4457 | crtc_state = to_intel_crtc_state(crtc->base.state); |
| 4458 | |
| 4459 | if (!crtc_state->base.active || |
| 4460 | !crtc_state->has_drrs) |
| 4461 | goto out; |
| 4462 | |
| 4463 | commit = crtc_state->base.commit; |
| 4464 | if (commit) { |
| 4465 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4466 | if (ret) |
| 4467 | goto out; |
| 4468 | } |
| 4469 | |
| 4470 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 4471 | drm_for_each_connector_iter(connector, &conn_iter) { |
| 4472 | struct intel_encoder *encoder; |
| 4473 | struct intel_dp *intel_dp; |
| 4474 | |
| 4475 | if (!(crtc_state->base.connector_mask & |
| 4476 | drm_connector_mask(connector))) |
| 4477 | continue; |
| 4478 | |
| 4479 | encoder = intel_attached_encoder(connector); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4480 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 4481 | continue; |
| 4482 | |
| 4483 | DRM_DEBUG_DRIVER("Manually %sabling DRRS. %llu\n", |
| 4484 | val ? "en" : "dis", val); |
| 4485 | |
| 4486 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 4487 | if (val) |
| 4488 | intel_edp_drrs_enable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4489 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4490 | else |
| 4491 | intel_edp_drrs_disable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4492 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4493 | } |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4494 | drm_connector_list_iter_end(&conn_iter); |
| 4495 | |
| 4496 | out: |
| 4497 | drm_modeset_unlock(&crtc->base.mutex); |
| 4498 | if (ret) |
| 4499 | return ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4500 | } |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4501 | |
| 4502 | return 0; |
| 4503 | } |
| 4504 | |
| 4505 | DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); |
| 4506 | |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4507 | static ssize_t |
| 4508 | i915_fifo_underrun_reset_write(struct file *filp, |
| 4509 | const char __user *ubuf, |
| 4510 | size_t cnt, loff_t *ppos) |
| 4511 | { |
| 4512 | struct drm_i915_private *dev_priv = filp->private_data; |
| 4513 | struct intel_crtc *intel_crtc; |
| 4514 | struct drm_device *dev = &dev_priv->drm; |
| 4515 | int ret; |
| 4516 | bool reset; |
| 4517 | |
| 4518 | ret = kstrtobool_from_user(ubuf, cnt, &reset); |
| 4519 | if (ret) |
| 4520 | return ret; |
| 4521 | |
| 4522 | if (!reset) |
| 4523 | return cnt; |
| 4524 | |
| 4525 | for_each_intel_crtc(dev, intel_crtc) { |
| 4526 | struct drm_crtc_commit *commit; |
| 4527 | struct intel_crtc_state *crtc_state; |
| 4528 | |
| 4529 | ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); |
| 4530 | if (ret) |
| 4531 | return ret; |
| 4532 | |
| 4533 | crtc_state = to_intel_crtc_state(intel_crtc->base.state); |
| 4534 | commit = crtc_state->base.commit; |
| 4535 | if (commit) { |
| 4536 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4537 | if (!ret) |
| 4538 | ret = wait_for_completion_interruptible(&commit->flip_done); |
| 4539 | } |
| 4540 | |
| 4541 | if (!ret && crtc_state->base.active) { |
| 4542 | DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", |
| 4543 | pipe_name(intel_crtc->pipe)); |
| 4544 | |
| 4545 | intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); |
| 4546 | } |
| 4547 | |
| 4548 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 4549 | |
| 4550 | if (ret) |
| 4551 | return ret; |
| 4552 | } |
| 4553 | |
| 4554 | ret = intel_fbc_reset_underrun(dev_priv); |
| 4555 | if (ret) |
| 4556 | return ret; |
| 4557 | |
| 4558 | return cnt; |
| 4559 | } |
| 4560 | |
| 4561 | static const struct file_operations i915_fifo_underrun_reset_ops = { |
| 4562 | .owner = THIS_MODULE, |
| 4563 | .open = simple_open, |
| 4564 | .write = i915_fifo_underrun_reset_write, |
| 4565 | .llseek = default_llseek, |
| 4566 | }; |
| 4567 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4568 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4569 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4570 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4571 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4572 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4573 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4574 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4575 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4576 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4577 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4578 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4579 | {"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] | 4580 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4581 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4582 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4583 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4584 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4585 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4586 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4587 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4588 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4589 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4590 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4591 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4592 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4593 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4594 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4595 | {"i915_context_status", i915_context_status, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4596 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4597 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4598 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4599 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4600 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4601 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4602 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4603 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4604 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4605 | {"i915_engine_info", i915_engine_info, 0}, |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 4606 | {"i915_rcs_topology", i915_rcs_topology, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4607 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4608 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4609 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4610 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4611 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4612 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4613 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4614 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4615 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4616 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4617 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4618 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4619 | const char *name; |
| 4620 | const struct file_operations *fops; |
| 4621 | } i915_debugfs_files[] = { |
| 4622 | {"i915_wedged", &i915_wedged_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4623 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4624 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4625 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4626 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4627 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4628 | #endif |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4629 | {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4630 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4631 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4632 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4633 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4634 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4635 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4636 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 4637 | {"i915_guc_log_level", &i915_guc_log_level_fops}, |
| 4638 | {"i915_guc_log_relay", &i915_guc_log_relay_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4639 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4640 | {"i915_hpd_short_storm_ctl", &i915_hpd_short_storm_ctl_fops}, |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4641 | {"i915_ipc_status", &i915_ipc_status_fops}, |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4642 | {"i915_drrs_ctl", &i915_drrs_ctl_fops}, |
| 4643 | {"i915_edp_psr_debug", &i915_edp_psr_debug_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4644 | }; |
| 4645 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4646 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4647 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4648 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4649 | struct dentry *ent; |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 4650 | int i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4651 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4652 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4653 | minor->debugfs_root, to_i915(minor->dev), |
| 4654 | &i915_forcewake_fops); |
| 4655 | if (!ent) |
| 4656 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4657 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4658 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4659 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4660 | S_IRUGO | S_IWUSR, |
| 4661 | minor->debugfs_root, |
| 4662 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4663 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4664 | if (!ent) |
| 4665 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4666 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4667 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4668 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4669 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4670 | minor->debugfs_root, minor); |
| 4671 | } |
| 4672 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4673 | struct dpcd_block { |
| 4674 | /* DPCD dump start address. */ |
| 4675 | unsigned int offset; |
| 4676 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4677 | unsigned int end; |
| 4678 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4679 | size_t size; |
| 4680 | /* Only valid for eDP. */ |
| 4681 | bool edp; |
| 4682 | }; |
| 4683 | |
| 4684 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4685 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4686 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4687 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4688 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4689 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4690 | { .offset = DP_SET_POWER }, |
| 4691 | { .offset = DP_EDP_DPCD_REV }, |
| 4692 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4693 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4694 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4695 | }; |
| 4696 | |
| 4697 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4698 | { |
| 4699 | struct drm_connector *connector = m->private; |
| 4700 | struct intel_dp *intel_dp = |
| 4701 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 4702 | u8 buf[16]; |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4703 | ssize_t err; |
| 4704 | int i; |
| 4705 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4706 | if (connector->status != connector_status_connected) |
| 4707 | return -ENODEV; |
| 4708 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4709 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4710 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4711 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4712 | |
| 4713 | if (b->edp && |
| 4714 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4715 | continue; |
| 4716 | |
| 4717 | /* low tech for now */ |
| 4718 | if (WARN_ON(size > sizeof(buf))) |
| 4719 | continue; |
| 4720 | |
| 4721 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
Chris Wilson | 65404c8 | 2018-10-10 09:17:06 +0100 | [diff] [blame] | 4722 | if (err < 0) |
| 4723 | seq_printf(m, "%04x: ERROR %d\n", b->offset, (int)err); |
| 4724 | else |
| 4725 | seq_printf(m, "%04x: %*ph\n", b->offset, (int)err, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4726 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4727 | |
| 4728 | return 0; |
| 4729 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4730 | DEFINE_SHOW_ATTRIBUTE(i915_dpcd); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4731 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4732 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4733 | { |
| 4734 | struct drm_connector *connector = m->private; |
| 4735 | struct intel_dp *intel_dp = |
| 4736 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4737 | |
| 4738 | if (connector->status != connector_status_connected) |
| 4739 | return -ENODEV; |
| 4740 | |
| 4741 | seq_printf(m, "Panel power up delay: %d\n", |
| 4742 | intel_dp->panel_power_up_delay); |
| 4743 | seq_printf(m, "Panel power down delay: %d\n", |
| 4744 | intel_dp->panel_power_down_delay); |
| 4745 | seq_printf(m, "Backlight on delay: %d\n", |
| 4746 | intel_dp->backlight_on_delay); |
| 4747 | seq_printf(m, "Backlight off delay: %d\n", |
| 4748 | intel_dp->backlight_off_delay); |
| 4749 | |
| 4750 | return 0; |
| 4751 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4752 | DEFINE_SHOW_ATTRIBUTE(i915_panel); |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4753 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4754 | static int i915_hdcp_sink_capability_show(struct seq_file *m, void *data) |
| 4755 | { |
| 4756 | struct drm_connector *connector = m->private; |
| 4757 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 4758 | |
| 4759 | if (connector->status != connector_status_connected) |
| 4760 | return -ENODEV; |
| 4761 | |
| 4762 | /* HDCP is supported by connector */ |
Ramalingam C | d3dacc7 | 2018-10-29 15:15:46 +0530 | [diff] [blame] | 4763 | if (!intel_connector->hdcp.shim) |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4764 | return -EINVAL; |
| 4765 | |
| 4766 | seq_printf(m, "%s:%d HDCP version: ", connector->name, |
| 4767 | connector->base.id); |
| 4768 | seq_printf(m, "%s ", !intel_hdcp_capable(intel_connector) ? |
| 4769 | "None" : "HDCP1.4"); |
| 4770 | seq_puts(m, "\n"); |
| 4771 | |
| 4772 | return 0; |
| 4773 | } |
| 4774 | DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability); |
| 4775 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4776 | static int i915_dsc_fec_support_show(struct seq_file *m, void *data) |
| 4777 | { |
| 4778 | struct drm_connector *connector = m->private; |
| 4779 | struct drm_device *dev = connector->dev; |
| 4780 | struct drm_crtc *crtc; |
| 4781 | struct intel_dp *intel_dp; |
| 4782 | struct drm_modeset_acquire_ctx ctx; |
| 4783 | struct intel_crtc_state *crtc_state = NULL; |
| 4784 | int ret = 0; |
| 4785 | bool try_again = false; |
| 4786 | |
| 4787 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 4788 | |
| 4789 | do { |
Manasi Navare | 6afe892 | 2018-12-19 15:51:20 -0800 | [diff] [blame] | 4790 | try_again = false; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4791 | ret = drm_modeset_lock(&dev->mode_config.connection_mutex, |
| 4792 | &ctx); |
| 4793 | if (ret) { |
Chris Wilson | ee6df56 | 2019-03-29 16:51:52 +0000 | [diff] [blame] | 4794 | if (ret == -EDEADLK && !drm_modeset_backoff(&ctx)) { |
| 4795 | try_again = true; |
| 4796 | continue; |
| 4797 | } |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4798 | break; |
| 4799 | } |
| 4800 | crtc = connector->state->crtc; |
| 4801 | if (connector->status != connector_status_connected || !crtc) { |
| 4802 | ret = -ENODEV; |
| 4803 | break; |
| 4804 | } |
| 4805 | ret = drm_modeset_lock(&crtc->mutex, &ctx); |
| 4806 | if (ret == -EDEADLK) { |
| 4807 | ret = drm_modeset_backoff(&ctx); |
| 4808 | if (!ret) { |
| 4809 | try_again = true; |
| 4810 | continue; |
| 4811 | } |
| 4812 | break; |
| 4813 | } else if (ret) { |
| 4814 | break; |
| 4815 | } |
| 4816 | intel_dp = enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4817 | crtc_state = to_intel_crtc_state(crtc->state); |
| 4818 | seq_printf(m, "DSC_Enabled: %s\n", |
| 4819 | yesno(crtc_state->dsc_params.compression_enable)); |
Radhakrishna Sripada | fed8569 | 2019-01-09 13:14:14 -0800 | [diff] [blame] | 4820 | seq_printf(m, "DSC_Sink_Support: %s\n", |
| 4821 | yesno(drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd))); |
Manasi Navare | feb8846 | 2019-04-05 15:48:21 -0700 | [diff] [blame] | 4822 | seq_printf(m, "Force_DSC_Enable: %s\n", |
| 4823 | yesno(intel_dp->force_dsc_en)); |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4824 | if (!intel_dp_is_edp(intel_dp)) |
| 4825 | seq_printf(m, "FEC_Sink_Support: %s\n", |
| 4826 | yesno(drm_dp_sink_supports_fec(intel_dp->fec_capable))); |
| 4827 | } while (try_again); |
| 4828 | |
| 4829 | drm_modeset_drop_locks(&ctx); |
| 4830 | drm_modeset_acquire_fini(&ctx); |
| 4831 | |
| 4832 | return ret; |
| 4833 | } |
| 4834 | |
| 4835 | static ssize_t i915_dsc_fec_support_write(struct file *file, |
| 4836 | const char __user *ubuf, |
| 4837 | size_t len, loff_t *offp) |
| 4838 | { |
| 4839 | bool dsc_enable = false; |
| 4840 | int ret; |
| 4841 | struct drm_connector *connector = |
| 4842 | ((struct seq_file *)file->private_data)->private; |
| 4843 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
| 4844 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 4845 | |
| 4846 | if (len == 0) |
| 4847 | return 0; |
| 4848 | |
| 4849 | DRM_DEBUG_DRIVER("Copied %zu bytes from user to force DSC\n", |
| 4850 | len); |
| 4851 | |
| 4852 | ret = kstrtobool_from_user(ubuf, len, &dsc_enable); |
| 4853 | if (ret < 0) |
| 4854 | return ret; |
| 4855 | |
| 4856 | DRM_DEBUG_DRIVER("Got %s for DSC Enable\n", |
| 4857 | (dsc_enable) ? "true" : "false"); |
| 4858 | intel_dp->force_dsc_en = dsc_enable; |
| 4859 | |
| 4860 | *offp += len; |
| 4861 | return len; |
| 4862 | } |
| 4863 | |
| 4864 | static int i915_dsc_fec_support_open(struct inode *inode, |
| 4865 | struct file *file) |
| 4866 | { |
| 4867 | return single_open(file, i915_dsc_fec_support_show, |
| 4868 | inode->i_private); |
| 4869 | } |
| 4870 | |
| 4871 | static const struct file_operations i915_dsc_fec_support_fops = { |
| 4872 | .owner = THIS_MODULE, |
| 4873 | .open = i915_dsc_fec_support_open, |
| 4874 | .read = seq_read, |
| 4875 | .llseek = seq_lseek, |
| 4876 | .release = single_release, |
| 4877 | .write = i915_dsc_fec_support_write |
| 4878 | }; |
| 4879 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4880 | /** |
| 4881 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4882 | * @connector: pointer to a registered drm_connector |
| 4883 | * |
| 4884 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4885 | * drm_debugfs_connector_remove(). |
| 4886 | * |
| 4887 | * Returns 0 on success, negative error codes on error. |
| 4888 | */ |
| 4889 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 4890 | { |
| 4891 | struct dentry *root = connector->debugfs_entry; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4892 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4893 | |
| 4894 | /* The connector must have been registered beforehands. */ |
| 4895 | if (!root) |
| 4896 | return -ENODEV; |
| 4897 | |
| 4898 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4899 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4900 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 4901 | connector, &i915_dpcd_fops); |
| 4902 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 4903 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4904 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 4905 | connector, &i915_panel_fops); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 4906 | debugfs_create_file("i915_psr_sink_status", S_IRUGO, root, |
| 4907 | connector, &i915_psr_sink_status_fops); |
| 4908 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4909 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4910 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4911 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || |
| 4912 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { |
| 4913 | debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, |
| 4914 | connector, &i915_hdcp_sink_capability_fops); |
| 4915 | } |
| 4916 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4917 | if (INTEL_GEN(dev_priv) >= 10 && |
| 4918 | (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4919 | connector->connector_type == DRM_MODE_CONNECTOR_eDP)) |
| 4920 | debugfs_create_file("i915_dsc_fec_support", S_IRUGO, root, |
| 4921 | connector, &i915_dsc_fec_support_fops); |
| 4922 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4923 | return 0; |
| 4924 | } |