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 | 10be98a | 2019-05-28 10:29:49 +0100 | [diff] [blame] | 35 | #include "gem/i915_gem_context.h" |
Chris Wilson | 112ed2d | 2019-04-24 18:48:39 +0100 | [diff] [blame] | 36 | #include "gt/intel_reset.h" |
| 37 | |
Jani Nikula | 2126d3e | 2019-05-02 18:02:43 +0300 | [diff] [blame] | 38 | #include "i915_debugfs.h" |
Jani Nikula | 440e2b3 | 2019-04-29 15:29:27 +0300 | [diff] [blame] | 39 | #include "i915_irq.h" |
Jani Nikula | 6176490 | 2019-05-02 18:02:39 +0300 | [diff] [blame] | 40 | #include "intel_csr.h" |
Jani Nikula | 27fec1f | 2019-04-05 14:00:17 +0300 | [diff] [blame] | 41 | #include "intel_dp.h" |
Jani Nikula | 98afa31 | 2019-04-05 14:00:08 +0300 | [diff] [blame] | 42 | #include "intel_drv.h" |
| 43 | #include "intel_fbc.h" |
| 44 | #include "intel_guc_submission.h" |
Jani Nikula | 408bd91 | 2019-04-05 14:00:13 +0300 | [diff] [blame] | 45 | #include "intel_hdcp.h" |
Jani Nikula | 0550691 | 2019-04-05 14:00:18 +0300 | [diff] [blame] | 46 | #include "intel_hdmi.h" |
Jani Nikula | 696173b | 2019-04-05 14:00:15 +0300 | [diff] [blame] | 47 | #include "intel_pm.h" |
Jani Nikula | 55367a2 | 2019-04-05 14:00:09 +0300 | [diff] [blame] | 48 | #include "intel_psr.h" |
Chris Wilson | 56c5098 | 2019-04-26 09:17:22 +0100 | [diff] [blame] | 49 | #include "intel_sideband.h" |
Chris Wilson | 9f58892 | 2019-01-16 15:33:04 +0000 | [diff] [blame] | 50 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 51 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 52 | { |
| 53 | return to_i915(node->minor->dev); |
| 54 | } |
| 55 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 56 | static int i915_capabilities(struct seq_file *m, void *data) |
| 57 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 58 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 59 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 60 | struct drm_printer p = drm_seq_file_printer(m); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 61 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 62 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
Jani Nikula | 2e0d26f | 2016-12-01 14:49:55 +0200 | [diff] [blame] | 63 | seq_printf(m, "platform: %s\n", intel_platform_name(info->platform)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 64 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 65 | |
Michal Wajdeczko | a8c9b84 | 2017-12-19 11:43:44 +0000 | [diff] [blame] | 66 | intel_device_info_dump_flags(info, &p); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 67 | intel_device_info_dump_runtime(RUNTIME_INFO(dev_priv), &p); |
Chris Wilson | 3fed180 | 2018-02-07 21:05:43 +0000 | [diff] [blame] | 68 | intel_driver_caps_print(&dev_priv->caps, &p); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 69 | |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 70 | kernel_param_lock(THIS_MODULE); |
Michal Wajdeczko | acfb997 | 2017-12-19 11:43:46 +0000 | [diff] [blame] | 71 | i915_params_dump(&i915_modparams, &p); |
Chris Wilson | 418e3cd | 2017-02-06 21:36:08 +0000 | [diff] [blame] | 72 | kernel_param_unlock(THIS_MODULE); |
| 73 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 74 | return 0; |
| 75 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 76 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 77 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 78 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 79 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 82 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 83 | { |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 84 | return obj->pin_global ? 'p' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 85 | } |
| 86 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 87 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 88 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 89 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 90 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 91 | case I915_TILING_NONE: return ' '; |
| 92 | case I915_TILING_X: return 'X'; |
| 93 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 94 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 97 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 98 | { |
Chris Wilson | a65adaf | 2017-10-09 09:43:57 +0100 | [diff] [blame] | 99 | return obj->userfault_count ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 102 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 103 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 104 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 107 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 108 | { |
| 109 | u64 size = 0; |
| 110 | struct i915_vma *vma; |
| 111 | |
Chris Wilson | e2189dd | 2017-12-07 21:14:07 +0000 | [diff] [blame] | 112 | for_each_ggtt_vma(vma, obj) { |
| 113 | if (drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 114 | size += vma->node.size; |
| 115 | } |
| 116 | |
| 117 | return size; |
| 118 | } |
| 119 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 120 | static const char * |
| 121 | stringify_page_sizes(unsigned int page_sizes, char *buf, size_t len) |
| 122 | { |
| 123 | size_t x = 0; |
| 124 | |
| 125 | switch (page_sizes) { |
| 126 | case 0: |
| 127 | return ""; |
| 128 | case I915_GTT_PAGE_SIZE_4K: |
| 129 | return "4K"; |
| 130 | case I915_GTT_PAGE_SIZE_64K: |
| 131 | return "64K"; |
| 132 | case I915_GTT_PAGE_SIZE_2M: |
| 133 | return "2M"; |
| 134 | default: |
| 135 | if (!buf) |
| 136 | return "M"; |
| 137 | |
| 138 | if (page_sizes & I915_GTT_PAGE_SIZE_2M) |
| 139 | x += snprintf(buf + x, len - x, "2M, "); |
| 140 | if (page_sizes & I915_GTT_PAGE_SIZE_64K) |
| 141 | x += snprintf(buf + x, len - x, "64K, "); |
| 142 | if (page_sizes & I915_GTT_PAGE_SIZE_4K) |
| 143 | x += snprintf(buf + x, len - x, "4K, "); |
| 144 | buf[x-2] = '\0'; |
| 145 | |
| 146 | return buf; |
| 147 | } |
| 148 | } |
| 149 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 150 | static void |
| 151 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 152 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 153 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 154 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 155 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 156 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 157 | int pin_count = 0; |
| 158 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 159 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 160 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 161 | 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] | 162 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 163 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 164 | get_pin_flag(obj), |
| 165 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 166 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 167 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 168 | obj->base.size / 1024, |
Christian König | c0a51fd | 2018-02-16 13:43:38 +0100 | [diff] [blame] | 169 | obj->read_domains, |
| 170 | obj->write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 171 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 172 | obj->mm.dirty ? " dirty" : "", |
| 173 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 174 | if (obj->base.name) |
| 175 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 176 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 177 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 178 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 179 | } |
| 180 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 181 | if (obj->pin_global) |
| 182 | seq_printf(m, " (global)"); |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 183 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 184 | if (!drm_mm_node_allocated(&vma->node)) |
| 185 | continue; |
| 186 | |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 187 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx, pages: %s", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 188 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 189 | vma->node.start, vma->node.size, |
| 190 | stringify_page_sizes(vma->page_sizes.gtt, NULL, 0)); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 191 | if (i915_vma_is_ggtt(vma)) { |
| 192 | switch (vma->ggtt_view.type) { |
| 193 | case I915_GGTT_VIEW_NORMAL: |
| 194 | seq_puts(m, ", normal"); |
| 195 | break; |
| 196 | |
| 197 | case I915_GGTT_VIEW_PARTIAL: |
| 198 | seq_printf(m, ", partial [%08llx+%x]", |
Chris Wilson | 8bab1193 | 2017-01-14 00:28:25 +0000 | [diff] [blame] | 199 | vma->ggtt_view.partial.offset << PAGE_SHIFT, |
| 200 | vma->ggtt_view.partial.size << PAGE_SHIFT); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 201 | break; |
| 202 | |
| 203 | case I915_GGTT_VIEW_ROTATED: |
| 204 | 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] | 205 | vma->ggtt_view.rotated.plane[0].width, |
| 206 | vma->ggtt_view.rotated.plane[0].height, |
| 207 | vma->ggtt_view.rotated.plane[0].stride, |
| 208 | vma->ggtt_view.rotated.plane[0].offset, |
| 209 | vma->ggtt_view.rotated.plane[1].width, |
| 210 | vma->ggtt_view.rotated.plane[1].height, |
| 211 | vma->ggtt_view.rotated.plane[1].stride, |
| 212 | vma->ggtt_view.rotated.plane[1].offset); |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 213 | break; |
| 214 | |
Ville Syrjälä | 1a74fc0 | 2019-05-09 15:21:52 +0300 | [diff] [blame] | 215 | case I915_GGTT_VIEW_REMAPPED: |
| 216 | seq_printf(m, ", remapped [(%ux%u, stride=%u, offset=%u), (%ux%u, stride=%u, offset=%u)]", |
| 217 | vma->ggtt_view.remapped.plane[0].width, |
| 218 | vma->ggtt_view.remapped.plane[0].height, |
| 219 | vma->ggtt_view.remapped.plane[0].stride, |
| 220 | vma->ggtt_view.remapped.plane[0].offset, |
| 221 | vma->ggtt_view.remapped.plane[1].width, |
| 222 | vma->ggtt_view.remapped.plane[1].height, |
| 223 | vma->ggtt_view.remapped.plane[1].stride, |
| 224 | vma->ggtt_view.remapped.plane[1].offset); |
| 225 | break; |
| 226 | |
Chris Wilson | 2197685 | 2017-01-12 11:21:08 +0000 | [diff] [blame] | 227 | default: |
| 228 | MISSING_CASE(vma->ggtt_view.type); |
| 229 | break; |
| 230 | } |
| 231 | } |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 232 | if (vma->fence) |
| 233 | seq_printf(m, " , fence: %d%s", |
| 234 | vma->fence->id, |
Chris Wilson | 21950ee | 2019-02-05 13:00:05 +0000 | [diff] [blame] | 235 | i915_active_request_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 236 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 237 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 238 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 239 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 240 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 241 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 242 | if (engine) |
| 243 | seq_printf(m, " (%s)", engine->name); |
| 244 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 245 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 246 | if (frontbuffer_bits) |
| 247 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 248 | } |
| 249 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 250 | static int obj_rank_by_stolen(const void *A, const void *B) |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 251 | { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 252 | const struct drm_i915_gem_object *a = |
| 253 | *(const struct drm_i915_gem_object **)A; |
| 254 | const struct drm_i915_gem_object *b = |
| 255 | *(const struct drm_i915_gem_object **)B; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 256 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 257 | if (a->stolen->start < b->stolen->start) |
| 258 | return -1; |
| 259 | if (a->stolen->start > b->stolen->start) |
| 260 | return 1; |
| 261 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 265 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 266 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 267 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 268 | struct drm_i915_gem_object **objects; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 269 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 270 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 271 | unsigned long total, count, n; |
Chris Wilson | a8cff4c8 | 2019-06-10 15:54:30 +0100 | [diff] [blame] | 272 | unsigned long flags; |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 273 | int ret; |
| 274 | |
Chris Wilson | d82b4b2 | 2019-05-30 21:35:00 +0100 | [diff] [blame] | 275 | total = READ_ONCE(dev_priv->mm.shrink_count); |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 276 | objects = kvmalloc_array(total, sizeof(*objects), GFP_KERNEL); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 277 | if (!objects) |
| 278 | return -ENOMEM; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 279 | |
| 280 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 281 | if (ret) |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 282 | goto out; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 283 | |
| 284 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 285 | |
Chris Wilson | a8cff4c8 | 2019-06-10 15:54:30 +0100 | [diff] [blame] | 286 | spin_lock_irqsave(&dev_priv->mm.obj_lock, flags); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 287 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 288 | if (count == total) |
| 289 | break; |
| 290 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 291 | if (obj->stolen == NULL) |
| 292 | continue; |
| 293 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 294 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 295 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 296 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 297 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 298 | } |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 299 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 300 | if (count == total) |
| 301 | break; |
| 302 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 303 | if (obj->stolen == NULL) |
| 304 | continue; |
| 305 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 306 | objects[count++] = obj; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 307 | total_obj_size += obj->base.size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 308 | } |
Chris Wilson | a8cff4c8 | 2019-06-10 15:54:30 +0100 | [diff] [blame] | 309 | spin_unlock_irqrestore(&dev_priv->mm.obj_lock, flags); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 310 | |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 311 | sort(objects, count, sizeof(*objects), obj_rank_by_stolen, NULL); |
| 312 | |
| 313 | seq_puts(m, "Stolen:\n"); |
| 314 | for (n = 0; n < count; n++) { |
| 315 | seq_puts(m, " "); |
| 316 | describe_obj(m, objects[n]); |
| 317 | seq_putc(m, '\n'); |
| 318 | } |
| 319 | seq_printf(m, "Total %lu objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 320 | count, total_obj_size, total_gtt_size); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 321 | |
| 322 | mutex_unlock(&dev->struct_mutex); |
| 323 | out: |
Michal Hocko | 2098105 | 2017-05-17 14:23:12 +0200 | [diff] [blame] | 324 | kvfree(objects); |
Chris Wilson | e637d2c | 2017-03-16 13:19:57 +0000 | [diff] [blame] | 325 | return ret; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 328 | struct file_stats { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 329 | struct i915_address_space *vm; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 330 | unsigned long count; |
| 331 | u64 total, unbound; |
| 332 | u64 global, shared; |
| 333 | u64 active, inactive; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 334 | u64 closed; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 335 | }; |
| 336 | |
| 337 | static int per_file_stats(int id, void *ptr, void *data) |
| 338 | { |
| 339 | struct drm_i915_gem_object *obj = ptr; |
| 340 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 341 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 342 | |
Chris Wilson | 0caf81b | 2017-06-17 12:57:44 +0100 | [diff] [blame] | 343 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 344 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 345 | stats->count++; |
| 346 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 347 | if (!obj->bind_count) |
| 348 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 349 | if (obj->base.name || obj->base.dma_buf) |
| 350 | stats->shared += obj->base.size; |
| 351 | |
Chris Wilson | 528cbd1 | 2019-01-28 10:23:54 +0000 | [diff] [blame] | 352 | list_for_each_entry(vma, &obj->vma.list, obj_link) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 353 | if (!drm_mm_node_allocated(&vma->node)) |
| 354 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 355 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 356 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 357 | stats->global += vma->node.size; |
| 358 | } else { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 359 | if (vma->vm != stats->vm) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 360 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 361 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 362 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 363 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 364 | stats->active += vma->node.size; |
| 365 | else |
| 366 | stats->inactive += vma->node.size; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 367 | |
| 368 | if (i915_vma_is_closed(vma)) |
| 369 | stats->closed += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 375 | #define print_file_stats(m, name, stats) do { \ |
| 376 | if (stats.count) \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 377 | 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] | 378 | name, \ |
| 379 | stats.count, \ |
| 380 | stats.total, \ |
| 381 | stats.active, \ |
| 382 | stats.inactive, \ |
| 383 | stats.global, \ |
| 384 | stats.shared, \ |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 385 | stats.unbound, \ |
| 386 | stats.closed); \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 387 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 388 | |
| 389 | static void print_batch_pool_stats(struct seq_file *m, |
| 390 | struct drm_i915_private *dev_priv) |
| 391 | { |
| 392 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 393 | struct intel_engine_cs *engine; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 394 | struct file_stats stats = {}; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 395 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 396 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 397 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 398 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 399 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 400 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 401 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 402 | batch_pool_link) |
| 403 | per_file_stats(0, obj, &stats); |
| 404 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 405 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 406 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 407 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 408 | } |
| 409 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 410 | static void print_context_stats(struct seq_file *m, |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 411 | struct drm_i915_private *i915) |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 412 | { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 413 | struct file_stats kstats = {}; |
| 414 | struct i915_gem_context *ctx; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 415 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 416 | list_for_each_entry(ctx, &i915->contexts.list, link) { |
Chris Wilson | 0268444 | 2019-04-26 17:33:35 +0100 | [diff] [blame] | 417 | struct i915_gem_engines_iter it; |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 418 | struct intel_context *ce; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 419 | |
Chris Wilson | 0268444 | 2019-04-26 17:33:35 +0100 | [diff] [blame] | 420 | for_each_gem_engine(ce, |
| 421 | i915_gem_context_lock_engines(ctx), it) { |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 422 | if (ce->state) |
| 423 | per_file_stats(0, ce->state->obj, &kstats); |
| 424 | if (ce->ring) |
| 425 | per_file_stats(0, ce->ring->vma->obj, &kstats); |
| 426 | } |
Chris Wilson | 0268444 | 2019-04-26 17:33:35 +0100 | [diff] [blame] | 427 | i915_gem_context_unlock_engines(ctx); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 428 | |
| 429 | if (!IS_ERR_OR_NULL(ctx->file_priv)) { |
Chris Wilson | e568ac3 | 2019-06-11 10:12:37 +0100 | [diff] [blame] | 430 | struct file_stats stats = { .vm = ctx->vm, }; |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 431 | struct drm_file *file = ctx->file_priv->file; |
| 432 | struct task_struct *task; |
| 433 | char name[80]; |
| 434 | |
| 435 | spin_lock(&file->table_lock); |
| 436 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
| 437 | spin_unlock(&file->table_lock); |
| 438 | |
| 439 | rcu_read_lock(); |
| 440 | task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID); |
Chris Wilson | 3e05531 | 2019-03-21 14:07:10 +0000 | [diff] [blame] | 441 | snprintf(name, sizeof(name), "%s", |
| 442 | task ? task->comm : "<unknown>"); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 443 | rcu_read_unlock(); |
| 444 | |
| 445 | print_file_stats(m, name, stats); |
| 446 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 447 | } |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 448 | |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 449 | print_file_stats(m, "[k]contexts", kstats); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 450 | } |
| 451 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 452 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 453 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 454 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 455 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 456 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 457 | u32 count, mapped_count, purgeable_count, dpy_count, huge_count; |
| 458 | u64 size, mapped_size, purgeable_size, dpy_size, huge_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 459 | struct drm_i915_gem_object *obj; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 460 | unsigned int page_sizes = 0; |
Chris Wilson | a8cff4c8 | 2019-06-10 15:54:30 +0100 | [diff] [blame] | 461 | unsigned long flags; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 462 | char buf[80]; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 463 | int ret; |
| 464 | |
Chris Wilson | d82b4b2 | 2019-05-30 21:35:00 +0100 | [diff] [blame] | 465 | seq_printf(m, "%u shrinkable objects, %llu bytes\n", |
| 466 | dev_priv->mm.shrink_count, |
| 467 | dev_priv->mm.shrink_memory); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 468 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 469 | size = count = 0; |
| 470 | mapped_size = mapped_count = 0; |
| 471 | purgeable_size = purgeable_count = 0; |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 472 | huge_size = huge_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 473 | |
Chris Wilson | a8cff4c8 | 2019-06-10 15:54:30 +0100 | [diff] [blame] | 474 | spin_lock_irqsave(&dev_priv->mm.obj_lock, flags); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 475 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 476 | size += obj->base.size; |
| 477 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 478 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 479 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 480 | purgeable_size += obj->base.size; |
| 481 | ++purgeable_count; |
| 482 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 483 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 484 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 485 | mapped_count++; |
| 486 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 487 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 488 | |
| 489 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 490 | huge_count++; |
| 491 | huge_size += obj->base.size; |
| 492 | page_sizes |= obj->mm.page_sizes.sg; |
| 493 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 494 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 495 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 496 | |
| 497 | size = count = dpy_size = dpy_count = 0; |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 498 | list_for_each_entry(obj, &dev_priv->mm.bound_list, mm.link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 499 | size += obj->base.size; |
| 500 | ++count; |
| 501 | |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 502 | if (obj->pin_global) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 503 | dpy_size += obj->base.size; |
| 504 | ++dpy_count; |
| 505 | } |
| 506 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 507 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 508 | purgeable_size += obj->base.size; |
| 509 | ++purgeable_count; |
| 510 | } |
| 511 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 512 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 513 | mapped_count++; |
| 514 | mapped_size += obj->base.size; |
| 515 | } |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 516 | |
| 517 | if (obj->mm.page_sizes.sg > I915_GTT_PAGE_SIZE) { |
| 518 | huge_count++; |
| 519 | huge_size += obj->base.size; |
| 520 | page_sizes |= obj->mm.page_sizes.sg; |
| 521 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 522 | } |
Chris Wilson | a8cff4c8 | 2019-06-10 15:54:30 +0100 | [diff] [blame] | 523 | spin_unlock_irqrestore(&dev_priv->mm.obj_lock, flags); |
Chris Wilson | f212381 | 2017-10-16 12:40:37 +0100 | [diff] [blame] | 524 | |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 525 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 526 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 527 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 528 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 529 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 530 | mapped_count, mapped_size); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 531 | seq_printf(m, "%u huge-paged objects (%s) %llu bytes\n", |
| 532 | huge_count, |
| 533 | stringify_page_sizes(page_sizes, buf, sizeof(buf)), |
| 534 | huge_size); |
Chris Wilson | bd3d225 | 2017-10-13 21:26:14 +0100 | [diff] [blame] | 535 | seq_printf(m, "%u display objects (globally pinned), %llu bytes\n", |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 536 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 537 | |
Matthew Auld | b7128ef | 2017-12-11 15:18:22 +0000 | [diff] [blame] | 538 | seq_printf(m, "%llu [%pa] gtt total\n", |
Chris Wilson | 82ad644 | 2018-06-05 16:37:58 +0100 | [diff] [blame] | 539 | ggtt->vm.total, &ggtt->mappable_end); |
Matthew Auld | 7393b7e | 2017-10-06 23:18:28 +0100 | [diff] [blame] | 540 | seq_printf(m, "Supported page sizes: %s\n", |
| 541 | stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes, |
| 542 | buf, sizeof(buf))); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 543 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 544 | seq_putc(m, '\n'); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 545 | |
| 546 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 547 | if (ret) |
| 548 | return ret; |
| 549 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 550 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 551 | print_context_stats(m, dev_priv); |
Chris Wilson | f6e8aa3 | 2019-01-07 11:54:25 +0000 | [diff] [blame] | 552 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 553 | |
| 554 | return 0; |
| 555 | } |
| 556 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 557 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 558 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 559 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 560 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 561 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 562 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 563 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 564 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 565 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 566 | |
| 567 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 568 | if (ret) |
| 569 | return ret; |
| 570 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 571 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 572 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 573 | int count; |
| 574 | |
| 575 | count = 0; |
| 576 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 577 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 578 | batch_pool_link) |
| 579 | count++; |
| 580 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 581 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 582 | |
| 583 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 584 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 585 | batch_pool_link) { |
| 586 | seq_puts(m, " "); |
| 587 | describe_obj(m, obj); |
| 588 | seq_putc(m, '\n'); |
| 589 | } |
| 590 | |
| 591 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 592 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 593 | } |
| 594 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 595 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 596 | |
| 597 | mutex_unlock(&dev->struct_mutex); |
| 598 | |
| 599 | return 0; |
| 600 | } |
| 601 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 602 | static void gen8_display_interrupt_info(struct seq_file *m) |
| 603 | { |
| 604 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 605 | int pipe; |
| 606 | |
| 607 | for_each_pipe(dev_priv, pipe) { |
| 608 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 609 | intel_wakeref_t wakeref; |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 610 | |
| 611 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 612 | wakeref = intel_display_power_get_if_enabled(dev_priv, |
| 613 | power_domain); |
| 614 | if (!wakeref) { |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 615 | seq_printf(m, "Pipe %c power disabled\n", |
| 616 | pipe_name(pipe)); |
| 617 | continue; |
| 618 | } |
| 619 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
| 620 | pipe_name(pipe), |
| 621 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
| 622 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
| 623 | pipe_name(pipe), |
| 624 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
| 625 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
| 626 | pipe_name(pipe), |
| 627 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
| 628 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 629 | intel_display_power_put(dev_priv, power_domain, wakeref); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 633 | I915_READ(GEN8_DE_PORT_IMR)); |
| 634 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 635 | I915_READ(GEN8_DE_PORT_IIR)); |
| 636 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 637 | I915_READ(GEN8_DE_PORT_IER)); |
| 638 | |
| 639 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 640 | I915_READ(GEN8_DE_MISC_IMR)); |
| 641 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 642 | I915_READ(GEN8_DE_MISC_IIR)); |
| 643 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 644 | I915_READ(GEN8_DE_MISC_IER)); |
| 645 | |
| 646 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 647 | I915_READ(GEN8_PCU_IMR)); |
| 648 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 649 | I915_READ(GEN8_PCU_IIR)); |
| 650 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 651 | I915_READ(GEN8_PCU_IER)); |
| 652 | } |
| 653 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 654 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 655 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 656 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 657 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 658 | enum intel_engine_id id; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 659 | intel_wakeref_t wakeref; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 660 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 661 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 662 | wakeref = intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 663 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 664 | if (IS_CHERRYVIEW(dev_priv)) { |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 665 | intel_wakeref_t pref; |
| 666 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 667 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 668 | I915_READ(GEN8_MASTER_IRQ)); |
| 669 | |
| 670 | seq_printf(m, "Display IER:\t%08x\n", |
| 671 | I915_READ(VLV_IER)); |
| 672 | seq_printf(m, "Display IIR:\t%08x\n", |
| 673 | I915_READ(VLV_IIR)); |
| 674 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 675 | I915_READ(VLV_IIR_RW)); |
| 676 | seq_printf(m, "Display IMR:\t%08x\n", |
| 677 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 678 | for_each_pipe(dev_priv, pipe) { |
| 679 | enum intel_display_power_domain power_domain; |
| 680 | |
| 681 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 682 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 683 | power_domain); |
| 684 | if (!pref) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 685 | seq_printf(m, "Pipe %c power disabled\n", |
| 686 | pipe_name(pipe)); |
| 687 | continue; |
| 688 | } |
| 689 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 690 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 691 | pipe_name(pipe), |
| 692 | I915_READ(PIPESTAT(pipe))); |
| 693 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 694 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 695 | } |
| 696 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 697 | pref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 698 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 699 | I915_READ(PORT_HOTPLUG_EN)); |
| 700 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 701 | I915_READ(VLV_DPFLIPSTAT)); |
| 702 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 703 | I915_READ(DPINVGTT)); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 704 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, pref); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 705 | |
| 706 | for (i = 0; i < 4; i++) { |
| 707 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 708 | i, I915_READ(GEN8_GT_IMR(i))); |
| 709 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 710 | i, I915_READ(GEN8_GT_IIR(i))); |
| 711 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 712 | i, I915_READ(GEN8_GT_IER(i))); |
| 713 | } |
| 714 | |
| 715 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 716 | I915_READ(GEN8_PCU_IMR)); |
| 717 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 718 | I915_READ(GEN8_PCU_IIR)); |
| 719 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 720 | I915_READ(GEN8_PCU_IER)); |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 721 | } else if (INTEL_GEN(dev_priv) >= 11) { |
| 722 | seq_printf(m, "Master Interrupt Control: %08x\n", |
| 723 | I915_READ(GEN11_GFX_MSTR_IRQ)); |
| 724 | |
| 725 | seq_printf(m, "Render/Copy Intr Enable: %08x\n", |
| 726 | I915_READ(GEN11_RENDER_COPY_INTR_ENABLE)); |
| 727 | seq_printf(m, "VCS/VECS Intr Enable: %08x\n", |
| 728 | I915_READ(GEN11_VCS_VECS_INTR_ENABLE)); |
| 729 | seq_printf(m, "GUC/SG Intr Enable:\t %08x\n", |
| 730 | I915_READ(GEN11_GUC_SG_INTR_ENABLE)); |
| 731 | seq_printf(m, "GPM/WGBOXPERF Intr Enable: %08x\n", |
| 732 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE)); |
| 733 | seq_printf(m, "Crypto Intr Enable:\t %08x\n", |
| 734 | I915_READ(GEN11_CRYPTO_RSVD_INTR_ENABLE)); |
| 735 | seq_printf(m, "GUnit/CSME Intr Enable:\t %08x\n", |
| 736 | I915_READ(GEN11_GUNIT_CSME_INTR_ENABLE)); |
| 737 | |
| 738 | seq_printf(m, "Display Interrupt Control:\t%08x\n", |
| 739 | I915_READ(GEN11_DISPLAY_INT_CTL)); |
| 740 | |
| 741 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 742 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 743 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 744 | I915_READ(GEN8_MASTER_IRQ)); |
| 745 | |
| 746 | for (i = 0; i < 4; i++) { |
| 747 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 748 | i, I915_READ(GEN8_GT_IMR(i))); |
| 749 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 750 | i, I915_READ(GEN8_GT_IIR(i))); |
| 751 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 752 | i, I915_READ(GEN8_GT_IER(i))); |
| 753 | } |
| 754 | |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 755 | gen8_display_interrupt_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 756 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 757 | seq_printf(m, "Display IER:\t%08x\n", |
| 758 | I915_READ(VLV_IER)); |
| 759 | seq_printf(m, "Display IIR:\t%08x\n", |
| 760 | I915_READ(VLV_IIR)); |
| 761 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 762 | I915_READ(VLV_IIR_RW)); |
| 763 | seq_printf(m, "Display IMR:\t%08x\n", |
| 764 | I915_READ(VLV_IMR)); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 765 | for_each_pipe(dev_priv, pipe) { |
| 766 | enum intel_display_power_domain power_domain; |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 767 | intel_wakeref_t pref; |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 768 | |
| 769 | power_domain = POWER_DOMAIN_PIPE(pipe); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 770 | pref = intel_display_power_get_if_enabled(dev_priv, |
| 771 | power_domain); |
| 772 | if (!pref) { |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 773 | seq_printf(m, "Pipe %c power disabled\n", |
| 774 | pipe_name(pipe)); |
| 775 | continue; |
| 776 | } |
| 777 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 778 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 779 | pipe_name(pipe), |
| 780 | I915_READ(PIPESTAT(pipe))); |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 781 | intel_display_power_put(dev_priv, power_domain, pref); |
Chris Wilson | 4f4631a | 2017-02-10 13:36:32 +0000 | [diff] [blame] | 782 | } |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 783 | |
| 784 | seq_printf(m, "Master IER:\t%08x\n", |
| 785 | I915_READ(VLV_MASTER_IER)); |
| 786 | |
| 787 | seq_printf(m, "Render IER:\t%08x\n", |
| 788 | I915_READ(GTIER)); |
| 789 | seq_printf(m, "Render IIR:\t%08x\n", |
| 790 | I915_READ(GTIIR)); |
| 791 | seq_printf(m, "Render IMR:\t%08x\n", |
| 792 | I915_READ(GTIMR)); |
| 793 | |
| 794 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 795 | I915_READ(GEN6_PMIER)); |
| 796 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 797 | I915_READ(GEN6_PMIIR)); |
| 798 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 799 | I915_READ(GEN6_PMIMR)); |
| 800 | |
| 801 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 802 | I915_READ(PORT_HOTPLUG_EN)); |
| 803 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 804 | I915_READ(VLV_DPFLIPSTAT)); |
| 805 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 806 | I915_READ(DPINVGTT)); |
| 807 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 808 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 809 | seq_printf(m, "Interrupt enable: %08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 810 | I915_READ(GEN2_IER)); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 811 | seq_printf(m, "Interrupt identity: %08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 812 | I915_READ(GEN2_IIR)); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 813 | seq_printf(m, "Interrupt mask: %08x\n", |
Paulo Zanoni | 9d9523d | 2019-04-10 16:53:42 -0700 | [diff] [blame] | 814 | I915_READ(GEN2_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 815 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 816 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 817 | pipe_name(pipe), |
| 818 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 819 | } else { |
| 820 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 821 | I915_READ(DEIER)); |
| 822 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 823 | I915_READ(DEIIR)); |
| 824 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 825 | I915_READ(DEIMR)); |
| 826 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 827 | I915_READ(SDEIER)); |
| 828 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 829 | I915_READ(SDEIIR)); |
| 830 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 831 | I915_READ(SDEIMR)); |
| 832 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 833 | I915_READ(GTIER)); |
| 834 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 835 | I915_READ(GTIIR)); |
| 836 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 837 | I915_READ(GTIMR)); |
| 838 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 839 | |
| 840 | if (INTEL_GEN(dev_priv) >= 11) { |
| 841 | seq_printf(m, "RCS Intr Mask:\t %08x\n", |
| 842 | I915_READ(GEN11_RCS0_RSVD_INTR_MASK)); |
| 843 | seq_printf(m, "BCS Intr Mask:\t %08x\n", |
| 844 | I915_READ(GEN11_BCS_RSVD_INTR_MASK)); |
| 845 | seq_printf(m, "VCS0/VCS1 Intr Mask:\t %08x\n", |
| 846 | I915_READ(GEN11_VCS0_VCS1_INTR_MASK)); |
| 847 | seq_printf(m, "VCS2/VCS3 Intr Mask:\t %08x\n", |
| 848 | I915_READ(GEN11_VCS2_VCS3_INTR_MASK)); |
| 849 | seq_printf(m, "VECS0/VECS1 Intr Mask:\t %08x\n", |
| 850 | I915_READ(GEN11_VECS0_VECS1_INTR_MASK)); |
| 851 | seq_printf(m, "GUC/SG Intr Mask:\t %08x\n", |
| 852 | I915_READ(GEN11_GUC_SG_INTR_MASK)); |
| 853 | seq_printf(m, "GPM/WGBOXPERF Intr Mask: %08x\n", |
| 854 | I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK)); |
| 855 | seq_printf(m, "Crypto Intr Mask:\t %08x\n", |
| 856 | I915_READ(GEN11_CRYPTO_RSVD_INTR_MASK)); |
| 857 | seq_printf(m, "Gunit/CSME Intr Mask:\t %08x\n", |
| 858 | I915_READ(GEN11_GUNIT_CSME_INTR_MASK)); |
| 859 | |
| 860 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | d5acadf | 2017-12-09 10:44:18 +0000 | [diff] [blame] | 861 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 862 | seq_printf(m, |
| 863 | "Graphics Interrupt mask (%s): %08x\n", |
Daniele Ceraolo Spurio | baba6e5 | 2019-03-25 14:49:40 -0700 | [diff] [blame] | 864 | engine->name, ENGINE_READ(engine, RING_IMR)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 865 | } |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 866 | } |
Tvrtko Ursulin | 80d8935 | 2018-02-20 17:37:53 +0200 | [diff] [blame] | 867 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 868 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 869 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 870 | return 0; |
| 871 | } |
| 872 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 873 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 874 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 875 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 876 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 877 | int i, ret; |
| 878 | |
| 879 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 880 | if (ret) |
| 881 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 882 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 883 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 884 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 885 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 886 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 887 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 888 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 889 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 890 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 891 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 892 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 893 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 894 | } |
| 895 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 896 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 897 | return 0; |
| 898 | } |
| 899 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 900 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 901 | static ssize_t gpu_state_read(struct file *file, char __user *ubuf, |
| 902 | size_t count, loff_t *pos) |
| 903 | { |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 904 | struct i915_gpu_state *error; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 905 | ssize_t ret; |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 906 | void *buf; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 907 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 908 | error = file->private_data; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 909 | if (!error) |
| 910 | return 0; |
| 911 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 912 | /* Bounce buffer required because of kernfs __user API convenience. */ |
| 913 | buf = kmalloc(count, GFP_KERNEL); |
| 914 | if (!buf) |
| 915 | return -ENOMEM; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 916 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 917 | ret = i915_gpu_state_copy_to_buffer(error, buf, *pos, count); |
| 918 | if (ret <= 0) |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 919 | goto out; |
| 920 | |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 921 | if (!copy_to_user(ubuf, buf, ret)) |
| 922 | *pos += ret; |
| 923 | else |
| 924 | ret = -EFAULT; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 925 | |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 926 | out: |
Chris Wilson | 0e39037 | 2018-11-23 13:23:25 +0000 | [diff] [blame] | 927 | kfree(buf); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 928 | return ret; |
| 929 | } |
| 930 | |
| 931 | static int gpu_state_release(struct inode *inode, struct file *file) |
| 932 | { |
| 933 | i915_gpu_state_put(file->private_data); |
| 934 | return 0; |
| 935 | } |
| 936 | |
| 937 | static int i915_gpu_info_open(struct inode *inode, struct file *file) |
| 938 | { |
Chris Wilson | 090e5fe | 2017-03-28 14:14:07 +0100 | [diff] [blame] | 939 | struct drm_i915_private *i915 = inode->i_private; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 940 | struct i915_gpu_state *gpu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 941 | intel_wakeref_t wakeref; |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 942 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 943 | gpu = NULL; |
| 944 | with_intel_runtime_pm(i915, wakeref) |
| 945 | gpu = i915_capture_gpu_state(i915); |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 946 | if (IS_ERR(gpu)) |
| 947 | return PTR_ERR(gpu); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 948 | |
| 949 | file->private_data = gpu; |
| 950 | return 0; |
| 951 | } |
| 952 | |
| 953 | static const struct file_operations i915_gpu_info_fops = { |
| 954 | .owner = THIS_MODULE, |
| 955 | .open = i915_gpu_info_open, |
| 956 | .read = gpu_state_read, |
| 957 | .llseek = default_llseek, |
| 958 | .release = gpu_state_release, |
| 959 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 960 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 961 | static ssize_t |
| 962 | i915_error_state_write(struct file *filp, |
| 963 | const char __user *ubuf, |
| 964 | size_t cnt, |
| 965 | loff_t *ppos) |
| 966 | { |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 967 | struct i915_gpu_state *error = filp->private_data; |
| 968 | |
| 969 | if (!error) |
| 970 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 971 | |
| 972 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 973 | i915_reset_error_state(error->i915); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 974 | |
| 975 | return cnt; |
| 976 | } |
| 977 | |
| 978 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 979 | { |
Chris Wilson | e6154e4 | 2018-12-07 11:05:54 +0000 | [diff] [blame] | 980 | struct i915_gpu_state *error; |
| 981 | |
| 982 | error = i915_first_error_state(inode->i_private); |
| 983 | if (IS_ERR(error)) |
| 984 | return PTR_ERR(error); |
| 985 | |
| 986 | file->private_data = error; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 987 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 988 | } |
| 989 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 990 | static const struct file_operations i915_error_state_fops = { |
| 991 | .owner = THIS_MODULE, |
| 992 | .open = i915_error_state_open, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 993 | .read = gpu_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 994 | .write = i915_error_state_write, |
| 995 | .llseek = default_llseek, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 996 | .release = gpu_state_release, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 997 | }; |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 998 | #endif |
| 999 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1000 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1001 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1002 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1003 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1004 | intel_wakeref_t wakeref; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1005 | int ret = 0; |
| 1006 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1007 | wakeref = intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1008 | |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 1009 | if (IS_GEN(dev_priv, 5)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1010 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1011 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1012 | |
| 1013 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1014 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1015 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1016 | MEMSTAT_VID_SHIFT); |
| 1017 | seq_printf(m, "Current P-state: %d\n", |
| 1018 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1019 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1020 | u32 rpmodectl, freq_sts; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1021 | |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1022 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1023 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1024 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1025 | seq_printf(m, "HW control enabled: %s\n", |
| 1026 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1027 | seq_printf(m, "SW control enabled: %s\n", |
| 1028 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1029 | GEN6_RP_MEDIA_SW_MODE)); |
| 1030 | |
Chris Wilson | 337fa6e | 2019-04-26 09:17:20 +0100 | [diff] [blame] | 1031 | vlv_punit_get(dev_priv); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1032 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
Chris Wilson | 337fa6e | 2019-04-26 09:17:20 +0100 | [diff] [blame] | 1033 | vlv_punit_put(dev_priv); |
| 1034 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1035 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1036 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1037 | |
| 1038 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1039 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1040 | |
| 1041 | seq_printf(m, "current GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1042 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1043 | |
| 1044 | seq_printf(m, "max GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1045 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1046 | |
| 1047 | seq_printf(m, "min GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1048 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1049 | |
| 1050 | seq_printf(m, "idle GPU freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1051 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1052 | |
| 1053 | seq_printf(m, |
| 1054 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1055 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1056 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1057 | u32 rp_state_limits; |
| 1058 | u32 gt_perf_status; |
| 1059 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1060 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1061 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1062 | u32 rpupei, rpcurup, rpprevup; |
| 1063 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1064 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1065 | int max_freq; |
| 1066 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1067 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1068 | if (IS_GEN9_LP(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1069 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1070 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1071 | } else { |
| 1072 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1073 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1074 | } |
| 1075 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1076 | /* RPSTAT1 is in the GT power well */ |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 1077 | intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1078 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1079 | reqf = I915_READ(GEN6_RPNSWREQ); |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1080 | if (INTEL_GEN(dev_priv) >= 9) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1081 | reqf >>= 23; |
| 1082 | else { |
| 1083 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1084 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1085 | reqf >>= 24; |
| 1086 | else |
| 1087 | reqf >>= 25; |
| 1088 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1089 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1090 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1091 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1092 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1093 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1094 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1095 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1096 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1097 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1098 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1099 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1100 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1101 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Tvrtko Ursulin | c84b270 | 2017-11-21 18:18:44 +0000 | [diff] [blame] | 1102 | cagf = intel_gpu_freq(dev_priv, |
| 1103 | intel_get_cagf(dev_priv, rpstat)); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1104 | |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 1105 | intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1106 | |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1107 | if (INTEL_GEN(dev_priv) >= 11) { |
| 1108 | pm_ier = I915_READ(GEN11_GPM_WGBOXPERF_INTR_ENABLE); |
| 1109 | pm_imr = I915_READ(GEN11_GPM_WGBOXPERF_INTR_MASK); |
| 1110 | /* |
| 1111 | * The equivalent to the PM ISR & IIR cannot be read |
| 1112 | * without affecting the current state of the system |
| 1113 | */ |
| 1114 | pm_isr = 0; |
| 1115 | pm_iir = 0; |
| 1116 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1117 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1118 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1119 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1120 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1121 | } else { |
| 1122 | pm_ier = I915_READ(GEN6_PMIER); |
| 1123 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1124 | pm_isr = I915_READ(GEN6_PMISR); |
| 1125 | pm_iir = I915_READ(GEN6_PMIIR); |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1126 | } |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1127 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1128 | |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1129 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1130 | yesno(rpmodectl & GEN6_RP_MEDIA_TURBO)); |
| 1131 | seq_printf(m, "HW control enabled: %s\n", |
| 1132 | yesno(rpmodectl & GEN6_RP_ENABLE)); |
| 1133 | seq_printf(m, "SW control enabled: %s\n", |
| 1134 | yesno((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == |
| 1135 | GEN6_RP_MEDIA_SW_MODE)); |
Oscar Mateo | 6b7a6a7 | 2018-05-10 14:59:55 -0700 | [diff] [blame] | 1136 | |
| 1137 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x, MASK=0x%08x\n", |
| 1138 | pm_ier, pm_imr, pm_mask); |
| 1139 | if (INTEL_GEN(dev_priv) <= 10) |
| 1140 | seq_printf(m, "PM ISR=0x%08x IIR=0x%08x\n", |
| 1141 | pm_isr, pm_iir); |
Sagar Arun Kamble | 5dd0455 | 2017-03-11 08:07:00 +0530 | [diff] [blame] | 1142 | seq_printf(m, "pm_intrmsk_mbz: 0x%08x\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1143 | rps->pm_intrmsk_mbz); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1144 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1145 | seq_printf(m, "Render p-state ratio: %d\n", |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1146 | (gt_perf_status & (INTEL_GEN(dev_priv) >= 9 ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1147 | seq_printf(m, "Render p-state VID: %d\n", |
| 1148 | gt_perf_status & 0xff); |
| 1149 | seq_printf(m, "Render p-state limit: %d\n", |
| 1150 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1151 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1152 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1153 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1154 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1155 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1156 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1157 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1158 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1159 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1160 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1161 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1162 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1163 | seq_printf(m, "Up threshold: %d%%\n", |
| 1164 | rps->power.up_threshold); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1165 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1166 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1167 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1168 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1169 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1170 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1171 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 1172 | seq_printf(m, "Down threshold: %d%%\n", |
| 1173 | rps->power.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1174 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1175 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1176 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1177 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1178 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1179 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1180 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1181 | |
| 1182 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1183 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1184 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1185 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1186 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1187 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 1188 | max_freq = (IS_GEN9_LP(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1189 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1190 | max_freq *= (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1191 | INTEL_GEN(dev_priv) >= 10 ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1192 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1193 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1194 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1195 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1196 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1197 | seq_printf(m, "Current freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1198 | intel_gpu_freq(dev_priv, rps->cur_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1199 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1200 | seq_printf(m, "Idle freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1201 | intel_gpu_freq(dev_priv, rps->idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1202 | seq_printf(m, "Min freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1203 | intel_gpu_freq(dev_priv, rps->min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1204 | seq_printf(m, "Boost freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1205 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1206 | seq_printf(m, "Max freq: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1207 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1208 | seq_printf(m, |
| 1209 | "efficient (RPe) frequency: %d MHz\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1210 | intel_gpu_freq(dev_priv, rps->efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1211 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1212 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1213 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1214 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 1215 | 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] | 1216 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1217 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1218 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1219 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1220 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1221 | } |
| 1222 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1223 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1224 | struct seq_file *m, |
| 1225 | struct intel_instdone *instdone) |
| 1226 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1227 | int slice; |
| 1228 | int subslice; |
| 1229 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1230 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1231 | instdone->instdone); |
| 1232 | |
| 1233 | if (INTEL_GEN(dev_priv) <= 3) |
| 1234 | return; |
| 1235 | |
| 1236 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1237 | instdone->slice_common); |
| 1238 | |
| 1239 | if (INTEL_GEN(dev_priv) <= 6) |
| 1240 | return; |
| 1241 | |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 1242 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1243 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1244 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1245 | |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 1246 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1247 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1248 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1249 | } |
| 1250 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1251 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1252 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1253 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1254 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1255 | u64 acthd[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1256 | struct intel_instdone instdone; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1257 | intel_wakeref_t wakeref; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1258 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1259 | |
Chris Wilson | 2caffbf | 2019-02-08 15:37:03 +0000 | [diff] [blame] | 1260 | seq_printf(m, "Reset flags: %lx\n", dev_priv->gpu_error.flags); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1261 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
Chris Wilson | 2caffbf | 2019-02-08 15:37:03 +0000 | [diff] [blame] | 1262 | seq_puts(m, "\tWedged\n"); |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1263 | if (test_bit(I915_RESET_BACKOFF, &dev_priv->gpu_error.flags)) |
Chris Wilson | 2caffbf | 2019-02-08 15:37:03 +0000 | [diff] [blame] | 1264 | seq_puts(m, "\tDevice (global) reset in progress\n"); |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1265 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1266 | if (!i915_modparams.enable_hangcheck) { |
Chris Wilson | 8c185ec | 2017-03-16 17:13:02 +0000 | [diff] [blame] | 1267 | seq_puts(m, "Hangcheck disabled\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1268 | return 0; |
| 1269 | } |
| 1270 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1271 | with_intel_runtime_pm(dev_priv, wakeref) { |
Chris Wilson | 519a019 | 2019-05-08 09:06:25 +0100 | [diff] [blame] | 1272 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1273 | acthd[id] = intel_engine_get_active_head(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1274 | |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1275 | intel_engine_get_instdone(dev_priv->engine[RCS0], &instdone); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1276 | } |
| 1277 | |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1278 | if (timer_pending(&dev_priv->gpu_error.hangcheck_work.timer)) |
| 1279 | seq_printf(m, "Hangcheck active, timer fires in %dms\n", |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1280 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1281 | jiffies)); |
Chris Wilson | 8352aea | 2017-03-03 09:00:56 +0000 | [diff] [blame] | 1282 | else if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) |
| 1283 | seq_puts(m, "Hangcheck active, work pending\n"); |
| 1284 | else |
| 1285 | seq_puts(m, "Hangcheck inactive\n"); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1286 | |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 1287 | seq_printf(m, "GT active? %s\n", yesno(dev_priv->gt.awake)); |
| 1288 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1289 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 519a019 | 2019-05-08 09:06:25 +0100 | [diff] [blame] | 1290 | seq_printf(m, "%s: %d ms ago\n", |
| 1291 | engine->name, |
Chris Wilson | eb8d0f5 | 2019-01-25 13:22:28 +0000 | [diff] [blame] | 1292 | jiffies_to_msecs(jiffies - |
| 1293 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame] | 1294 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1295 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1296 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1297 | (long long)acthd[id]); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1298 | |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 1299 | if (engine->id == RCS0) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1300 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1301 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1302 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1303 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1304 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1305 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1306 | i915_instdone_info(dev_priv, m, |
| 1307 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1308 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | return 0; |
| 1312 | } |
| 1313 | |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 1314 | static int i915_reset_info(struct seq_file *m, void *unused) |
| 1315 | { |
| 1316 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1317 | struct i915_gpu_error *error = &dev_priv->gpu_error; |
| 1318 | struct intel_engine_cs *engine; |
| 1319 | enum intel_engine_id id; |
| 1320 | |
| 1321 | seq_printf(m, "full gpu reset = %u\n", i915_reset_count(error)); |
| 1322 | |
| 1323 | for_each_engine(engine, dev_priv, id) { |
| 1324 | seq_printf(m, "%s = %u\n", engine->name, |
| 1325 | i915_reset_engine_count(error, engine)); |
| 1326 | } |
| 1327 | |
| 1328 | return 0; |
| 1329 | } |
| 1330 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1331 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1332 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1333 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1334 | u32 rgvmodectl, rstdbyctl; |
| 1335 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1336 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1337 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1338 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1339 | crstandvid = I915_READ16(CRSTANDVID); |
| 1340 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1341 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1342 | seq_printf(m, "Boost freq: %d\n", |
| 1343 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1344 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1345 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1346 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1347 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1348 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1349 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1350 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1351 | seq_printf(m, "Starting frequency: P%d\n", |
| 1352 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1353 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1354 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1355 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1356 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1357 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1358 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1359 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1360 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1361 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1362 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1363 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1364 | break; |
| 1365 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1366 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1367 | break; |
| 1368 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1369 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1370 | break; |
| 1371 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1372 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1373 | break; |
| 1374 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1375 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1376 | break; |
| 1377 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1378 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1379 | break; |
| 1380 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1381 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1382 | break; |
| 1383 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1384 | |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1388 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1389 | { |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1390 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1391 | struct intel_uncore *uncore = &i915->uncore; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1392 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | d2dc94b | 2017-03-23 10:19:41 +0000 | [diff] [blame] | 1393 | unsigned int tmp; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1394 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1395 | seq_printf(m, "user.bypass_count = %u\n", |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1396 | uncore->user_forcewake.count); |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 1397 | |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1398 | for_each_fw_domain(fw_domain, uncore, tmp) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1399 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1400 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | 233ebf5 | 2017-03-23 10:19:44 +0000 | [diff] [blame] | 1401 | READ_ONCE(fw_domain->wake_count)); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1402 | |
| 1403 | return 0; |
| 1404 | } |
| 1405 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1406 | static void print_rc6_res(struct seq_file *m, |
| 1407 | const char *title, |
| 1408 | const i915_reg_t reg) |
| 1409 | { |
| 1410 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1411 | |
| 1412 | seq_printf(m, "%s %u (%llu us)\n", |
| 1413 | title, I915_READ(reg), |
| 1414 | intel_rc6_residency_us(dev_priv, reg)); |
| 1415 | } |
| 1416 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1417 | static int vlv_drpc_info(struct seq_file *m) |
| 1418 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1419 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 0d6fc92 | 2017-10-10 22:30:02 +0100 | [diff] [blame] | 1420 | u32 rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1421 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1422 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1423 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1424 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1425 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1426 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1427 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1428 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1429 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1430 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1431 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1432 | |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1433 | print_rc6_res(m, "Render RC6 residency since boot:", VLV_GT_RENDER_RC6); |
| 1434 | 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] | 1435 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1436 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1437 | } |
| 1438 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1439 | static int gen6_drpc_info(struct seq_file *m) |
| 1440 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1441 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 960e546 | 2017-10-10 22:29:59 +0100 | [diff] [blame] | 1442 | u32 gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1443 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1444 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1445 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1446 | 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] | 1447 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1448 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1449 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1450 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1451 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1452 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1453 | |
Chris Wilson | ebb5eb7 | 2019-04-26 09:17:21 +0100 | [diff] [blame] | 1454 | if (INTEL_GEN(dev_priv) <= 7) |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1455 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, |
Ville Syrjälä | d284d51 | 2019-05-21 19:40:24 +0300 | [diff] [blame] | 1456 | &rc6vids, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1457 | |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1458 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1459 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1460 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1461 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1462 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1463 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1464 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1465 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1466 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1467 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1468 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1469 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1470 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1471 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1472 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1473 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1474 | case GEN6_RC0: |
| 1475 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1476 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1477 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1478 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1479 | break; |
| 1480 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1481 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1482 | break; |
| 1483 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1484 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1485 | break; |
| 1486 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1487 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1488 | break; |
| 1489 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1490 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1491 | break; |
| 1492 | } |
| 1493 | |
| 1494 | seq_printf(m, "Core Power Down: %s\n", |
| 1495 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1496 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1497 | seq_printf(m, "Render Power Well: %s\n", |
| 1498 | (gen9_powergate_status & |
| 1499 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1500 | seq_printf(m, "Media Power Well: %s\n", |
| 1501 | (gen9_powergate_status & |
| 1502 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1503 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1504 | |
| 1505 | /* Not exactly sure what this is */ |
Mika Kuoppala | 1362877 | 2017-03-15 17:43:02 +0200 | [diff] [blame] | 1506 | print_rc6_res(m, "RC6 \"Locked to RPn\" residency since boot:", |
| 1507 | GEN6_GT_GFX_RC6_LOCKED); |
| 1508 | print_rc6_res(m, "RC6 residency since boot:", GEN6_GT_GFX_RC6); |
| 1509 | print_rc6_res(m, "RC6+ residency since boot:", GEN6_GT_GFX_RC6p); |
| 1510 | print_rc6_res(m, "RC6++ residency since boot:", GEN6_GT_GFX_RC6pp); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1511 | |
Imre Deak | 51cc9ad | 2018-02-08 19:41:02 +0200 | [diff] [blame] | 1512 | if (INTEL_GEN(dev_priv) <= 7) { |
| 1513 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1514 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1515 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1516 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1517 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1518 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
| 1519 | } |
| 1520 | |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1521 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1525 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1526 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1527 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1528 | int err = -ENODEV; |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1529 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1530 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 1531 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 1532 | err = vlv_drpc_info(m); |
| 1533 | else if (INTEL_GEN(dev_priv) >= 6) |
| 1534 | err = gen6_drpc_info(m); |
| 1535 | else |
| 1536 | err = ironlake_drpc_info(m); |
| 1537 | } |
Chris Wilson | cf632bd | 2017-03-13 09:56:17 +0000 | [diff] [blame] | 1538 | |
| 1539 | return err; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1540 | } |
| 1541 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1542 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1543 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1544 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1545 | |
| 1546 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1547 | dev_priv->fb_tracking.busy_bits); |
| 1548 | |
| 1549 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1550 | dev_priv->fb_tracking.flip_bits); |
| 1551 | |
| 1552 | return 0; |
| 1553 | } |
| 1554 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1555 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1556 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1557 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1558 | struct intel_fbc *fbc = &dev_priv->fbc; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1559 | intel_wakeref_t wakeref; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1560 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1561 | if (!HAS_FBC(dev_priv)) |
| 1562 | return -ENODEV; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1563 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1564 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1565 | mutex_lock(&fbc->lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1566 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1567 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1568 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1569 | else |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1570 | seq_printf(m, "FBC disabled: %s\n", fbc->no_fbc_reason); |
| 1571 | |
Ville Syrjälä | 3fd5d1e | 2017-06-06 15:43:18 +0300 | [diff] [blame] | 1572 | if (intel_fbc_is_active(dev_priv)) { |
| 1573 | u32 mask; |
| 1574 | |
| 1575 | if (INTEL_GEN(dev_priv) >= 8) |
| 1576 | mask = I915_READ(IVB_FBC_STATUS2) & BDW_FBC_COMP_SEG_MASK; |
| 1577 | else if (INTEL_GEN(dev_priv) >= 7) |
| 1578 | mask = I915_READ(IVB_FBC_STATUS2) & IVB_FBC_COMP_SEG_MASK; |
| 1579 | else if (INTEL_GEN(dev_priv) >= 5) |
| 1580 | mask = I915_READ(ILK_DPFC_STATUS) & ILK_DPFC_COMP_SEG_MASK; |
| 1581 | else if (IS_G4X(dev_priv)) |
| 1582 | mask = I915_READ(DPFC_STATUS) & DPFC_COMP_SEG_MASK; |
| 1583 | else |
| 1584 | mask = I915_READ(FBC_STATUS) & (FBC_STAT_COMPRESSING | |
| 1585 | FBC_STAT_COMPRESSED); |
| 1586 | |
| 1587 | seq_printf(m, "Compressing: %s\n", yesno(mask)); |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1588 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1589 | |
Chris Wilson | 3138872 | 2017-12-20 20:58:48 +0000 | [diff] [blame] | 1590 | mutex_unlock(&fbc->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1591 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1592 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1593 | return 0; |
| 1594 | } |
| 1595 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1596 | static int i915_fbc_false_color_get(void *data, u64 *val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1597 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1598 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1599 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1600 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1601 | return -ENODEV; |
| 1602 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1603 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1604 | |
| 1605 | return 0; |
| 1606 | } |
| 1607 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1608 | static int i915_fbc_false_color_set(void *data, u64 val) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1609 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1610 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1611 | u32 reg; |
| 1612 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1613 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1614 | return -ENODEV; |
| 1615 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1616 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1617 | |
| 1618 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1619 | dev_priv->fbc.false_color = val; |
| 1620 | |
| 1621 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1622 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1623 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1624 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1625 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1626 | return 0; |
| 1627 | } |
| 1628 | |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 1629 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_false_color_fops, |
| 1630 | i915_fbc_false_color_get, i915_fbc_false_color_set, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1631 | "%llu\n"); |
| 1632 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1633 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1634 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1635 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1636 | intel_wakeref_t wakeref; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1637 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1638 | if (!HAS_IPS(dev_priv)) |
| 1639 | return -ENODEV; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1640 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1641 | wakeref = intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1642 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1643 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 1644 | yesno(i915_modparams.enable_ips)); |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1645 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1646 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1647 | seq_puts(m, "Currently: unknown\n"); |
| 1648 | } else { |
| 1649 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1650 | seq_puts(m, "Currently: enabled\n"); |
| 1651 | else |
| 1652 | seq_puts(m, "Currently: disabled\n"); |
| 1653 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1654 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1655 | intel_runtime_pm_put(dev_priv, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1656 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1657 | return 0; |
| 1658 | } |
| 1659 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1660 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1661 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1662 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1663 | intel_wakeref_t wakeref; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1664 | bool sr_enabled = false; |
| 1665 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1666 | wakeref = intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1667 | |
Chris Wilson | 7342a72 | 2017-03-09 14:20:49 +0000 | [diff] [blame] | 1668 | if (INTEL_GEN(dev_priv) >= 9) |
| 1669 | /* no global SR status; inspect per-plane WM */; |
| 1670 | else if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1671 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 1672 | else if (IS_I965GM(dev_priv) || IS_G4X(dev_priv) || |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1673 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1674 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1675 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1676 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1677 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1678 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1679 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1680 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1681 | |
Chris Wilson | 0e6e0be | 2019-01-14 14:21:24 +0000 | [diff] [blame] | 1682 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, wakeref); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1683 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1684 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1685 | |
| 1686 | return 0; |
| 1687 | } |
| 1688 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1689 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1690 | { |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1691 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1692 | intel_wakeref_t wakeref; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1693 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1694 | if (!IS_GEN(i915, 5)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1695 | return -ENODEV; |
| 1696 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1697 | with_intel_runtime_pm(i915, wakeref) { |
| 1698 | unsigned long temp, chipset, gfx; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1699 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1700 | temp = i915_mch_val(i915); |
| 1701 | chipset = i915_chipset_val(i915); |
| 1702 | gfx = i915_gfx_val(i915); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1703 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1704 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1705 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1706 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1707 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1708 | } |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1709 | |
| 1710 | return 0; |
| 1711 | } |
| 1712 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1713 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1714 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1715 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1716 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1717 | unsigned int max_gpu_freq, min_gpu_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1718 | intel_wakeref_t wakeref; |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1719 | int gpu_freq, ia_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1720 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 1721 | if (!HAS_LLC(dev_priv)) |
| 1722 | return -ENODEV; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1723 | |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1724 | min_gpu_freq = rps->min_freq; |
| 1725 | max_gpu_freq = rps->max_freq; |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1726 | if (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1727 | /* Convert GT frequency to 50 HZ units */ |
Chris Wilson | d586b5f | 2018-03-08 14:26:48 +0000 | [diff] [blame] | 1728 | min_gpu_freq /= GEN9_FREQ_SCALER; |
| 1729 | max_gpu_freq /= GEN9_FREQ_SCALER; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1730 | } |
| 1731 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1732 | 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] | 1733 | |
Chris Wilson | ebb5eb7 | 2019-04-26 09:17:21 +0100 | [diff] [blame] | 1734 | wakeref = intel_runtime_pm_get(dev_priv); |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1735 | 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] | 1736 | ia_freq = gpu_freq; |
| 1737 | sandybridge_pcode_read(dev_priv, |
| 1738 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
Ville Syrjälä | d284d51 | 2019-05-21 19:40:24 +0300 | [diff] [blame] | 1739 | &ia_freq, NULL); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1740 | 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] | 1741 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | 35ceabf | 2017-07-06 13:41:13 -0700 | [diff] [blame] | 1742 | (IS_GEN9_BC(dev_priv) || |
Oscar Mateo | 2b2874e | 2018-04-05 17:00:52 +0300 | [diff] [blame] | 1743 | INTEL_GEN(dev_priv) >= 10 ? |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 1744 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1745 | ((ia_freq >> 0) & 0xff) * 100, |
| 1746 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1747 | } |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1748 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | ebb5eb7 | 2019-04-26 09:17:21 +0100 | [diff] [blame] | 1749 | |
| 1750 | return 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1751 | } |
| 1752 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1753 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1754 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1755 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1756 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1757 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1758 | int ret; |
| 1759 | |
| 1760 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1761 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1762 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1763 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1764 | if (opregion->header) |
| 1765 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1766 | |
| 1767 | mutex_unlock(&dev->struct_mutex); |
| 1768 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1769 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1770 | return 0; |
| 1771 | } |
| 1772 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1773 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1774 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1775 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1776 | |
| 1777 | if (opregion->vbt) |
| 1778 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1779 | |
| 1780 | return 0; |
| 1781 | } |
| 1782 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1783 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1784 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1785 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1786 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1787 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1788 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1789 | int ret; |
| 1790 | |
| 1791 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1792 | if (ret) |
| 1793 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1794 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1795 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Daniel Vetter | 346fb4e | 2017-07-06 15:00:20 +0200 | [diff] [blame] | 1796 | if (dev_priv->fbdev && dev_priv->fbdev->helper.fb) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1797 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1798 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1799 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1800 | fbdev_fb->base.width, |
| 1801 | fbdev_fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1802 | fbdev_fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1803 | fbdev_fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1804 | fbdev_fb->base.modifier, |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1805 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1806 | describe_obj(m, intel_fb_obj(&fbdev_fb->base)); |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1807 | seq_putc(m, '\n'); |
| 1808 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1809 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1810 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1811 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1812 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1813 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1814 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1815 | continue; |
| 1816 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1817 | 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] | 1818 | fb->base.width, |
| 1819 | fb->base.height, |
Ville Syrjälä | b00c600 | 2016-12-14 23:31:35 +0200 | [diff] [blame] | 1820 | fb->base.format->depth, |
Ville Syrjälä | 272725c | 2016-12-14 23:32:20 +0200 | [diff] [blame] | 1821 | fb->base.format->cpp[0] * 8, |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 1822 | fb->base.modifier, |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1823 | drm_framebuffer_read_refcount(&fb->base)); |
Daniel Stone | a5ff7a4 | 2018-05-18 15:30:07 +0100 | [diff] [blame] | 1824 | describe_obj(m, intel_fb_obj(&fb->base)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1825 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1826 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1827 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1828 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1829 | |
| 1830 | return 0; |
| 1831 | } |
| 1832 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1833 | 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] | 1834 | { |
Chris Wilson | ef5032a | 2018-03-07 13:42:24 +0000 | [diff] [blame] | 1835 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, emit: %u)", |
| 1836 | ring->space, ring->head, ring->tail, ring->emit); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1837 | } |
| 1838 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1839 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1840 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1841 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1842 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1843 | struct i915_gem_context *ctx; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1844 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1845 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1846 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1847 | if (ret) |
| 1848 | return ret; |
| 1849 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1850 | list_for_each_entry(ctx, &dev_priv->contexts.list, link) { |
Chris Wilson | 0268444 | 2019-04-26 17:33:35 +0100 | [diff] [blame] | 1851 | struct i915_gem_engines_iter it; |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 1852 | struct intel_context *ce; |
| 1853 | |
Chris Wilson | 288f1ce | 2018-09-04 16:31:17 +0100 | [diff] [blame] | 1854 | seq_puts(m, "HW context "); |
| 1855 | if (!list_empty(&ctx->hw_id_link)) |
| 1856 | seq_printf(m, "%x [pin %u]", ctx->hw_id, |
| 1857 | atomic_read(&ctx->hw_id_pin_count)); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1858 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1859 | struct task_struct *task; |
| 1860 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1861 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1862 | if (task) { |
| 1863 | seq_printf(m, "(%s [%d]) ", |
| 1864 | task->comm, task->pid); |
| 1865 | put_task_struct(task); |
| 1866 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1867 | } else if (IS_ERR(ctx->file_priv)) { |
| 1868 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1869 | } else { |
| 1870 | seq_puts(m, "(kernel) "); |
| 1871 | } |
| 1872 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1873 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1874 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1875 | |
Chris Wilson | 0268444 | 2019-04-26 17:33:35 +0100 | [diff] [blame] | 1876 | for_each_gem_engine(ce, |
| 1877 | i915_gem_context_lock_engines(ctx), it) { |
Chris Wilson | 7e3d9a5 | 2019-03-08 13:25:16 +0000 | [diff] [blame] | 1878 | seq_printf(m, "%s: ", ce->engine->name); |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1879 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1880 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1881 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1882 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1883 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1884 | } |
Chris Wilson | 0268444 | 2019-04-26 17:33:35 +0100 | [diff] [blame] | 1885 | i915_gem_context_unlock_engines(ctx); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1886 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1887 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1888 | } |
| 1889 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1890 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1891 | |
| 1892 | return 0; |
| 1893 | } |
| 1894 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1895 | static const char *swizzle_string(unsigned swizzle) |
| 1896 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1897 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1898 | case I915_BIT_6_SWIZZLE_NONE: |
| 1899 | return "none"; |
| 1900 | case I915_BIT_6_SWIZZLE_9: |
| 1901 | return "bit9"; |
| 1902 | case I915_BIT_6_SWIZZLE_9_10: |
| 1903 | return "bit9/bit10"; |
| 1904 | case I915_BIT_6_SWIZZLE_9_11: |
| 1905 | return "bit9/bit11"; |
| 1906 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1907 | return "bit9/bit10/bit11"; |
| 1908 | case I915_BIT_6_SWIZZLE_9_17: |
| 1909 | return "bit9/bit17"; |
| 1910 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1911 | return "bit9/bit10/bit17"; |
| 1912 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1913 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1914 | } |
| 1915 | |
| 1916 | return "bug"; |
| 1917 | } |
| 1918 | |
| 1919 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1920 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1921 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1922 | intel_wakeref_t wakeref; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1923 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1924 | wakeref = intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1925 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1926 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1927 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1928 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1929 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1930 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 1931 | if (IS_GEN_RANGE(dev_priv, 3, 4)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1932 | seq_printf(m, "DDC = 0x%08x\n", |
| 1933 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1934 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 1935 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1936 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1937 | I915_READ16(C0DRB3)); |
| 1938 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1939 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1940 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1941 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1942 | I915_READ(MAD_DIMM_C0)); |
| 1943 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1944 | I915_READ(MAD_DIMM_C1)); |
| 1945 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1946 | I915_READ(MAD_DIMM_C2)); |
| 1947 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1948 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1949 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 1950 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 1951 | I915_READ(GAMTARBMODE)); |
| 1952 | else |
| 1953 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 1954 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1955 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 1956 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1957 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 1958 | |
| 1959 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 1960 | seq_puts(m, "L-shaped memory detected\n"); |
| 1961 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1962 | intel_runtime_pm_put(dev_priv, wakeref); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1963 | |
| 1964 | return 0; |
| 1965 | } |
| 1966 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 1967 | static const char *rps_power_to_str(unsigned int power) |
| 1968 | { |
| 1969 | static const char * const strings[] = { |
| 1970 | [LOW_POWER] = "low power", |
| 1971 | [BETWEEN] = "mixed", |
| 1972 | [HIGH_POWER] = "high power", |
| 1973 | }; |
| 1974 | |
| 1975 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 1976 | return "unknown"; |
| 1977 | |
| 1978 | return strings[power]; |
| 1979 | } |
| 1980 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 1981 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 1982 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1983 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 1984 | struct intel_rps *rps = &dev_priv->gt_pm.rps; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 1985 | u32 act_freq = rps->cur_freq; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 1986 | intel_wakeref_t wakeref; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 1987 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 1988 | with_intel_runtime_pm_if_in_use(dev_priv, wakeref) { |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 1989 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Chris Wilson | 337fa6e | 2019-04-26 09:17:20 +0100 | [diff] [blame] | 1990 | vlv_punit_get(dev_priv); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 1991 | act_freq = vlv_punit_read(dev_priv, |
| 1992 | PUNIT_REG_GPU_FREQ_STS); |
Chris Wilson | 337fa6e | 2019-04-26 09:17:20 +0100 | [diff] [blame] | 1993 | vlv_punit_put(dev_priv); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 1994 | act_freq = (act_freq >> 8) & 0xff; |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 1995 | } else { |
| 1996 | act_freq = intel_get_cagf(dev_priv, |
| 1997 | I915_READ(GEN6_RPSTAT1)); |
| 1998 | } |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 1999 | } |
| 2000 | |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2001 | seq_printf(m, "RPS enabled? %d\n", rps->enabled); |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame] | 2002 | seq_printf(m, "GPU busy? %s\n", yesno(dev_priv->gt.awake)); |
Chris Wilson | 7b92c1b | 2017-06-28 13:35:48 +0100 | [diff] [blame] | 2003 | seq_printf(m, "Boosts outstanding? %d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2004 | atomic_read(&rps->num_waiters)); |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2005 | seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); |
Chris Wilson | c0a6aa7 | 2018-10-02 12:32:21 +0100 | [diff] [blame] | 2006 | seq_printf(m, "Frequency requested %d, actual %d\n", |
| 2007 | intel_gpu_freq(dev_priv, rps->cur_freq), |
| 2008 | intel_gpu_freq(dev_priv, act_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2009 | 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] | 2010 | intel_gpu_freq(dev_priv, rps->min_freq), |
| 2011 | intel_gpu_freq(dev_priv, rps->min_freq_softlimit), |
| 2012 | intel_gpu_freq(dev_priv, rps->max_freq_softlimit), |
| 2013 | intel_gpu_freq(dev_priv, rps->max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2014 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
Sagar Arun Kamble | 562d9ba | 2017-10-10 22:30:06 +0100 | [diff] [blame] | 2015 | intel_gpu_freq(dev_priv, rps->idle_freq), |
| 2016 | intel_gpu_freq(dev_priv, rps->efficient_freq), |
| 2017 | intel_gpu_freq(dev_priv, rps->boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2018 | |
Chris Wilson | 62eb3c2 | 2019-02-13 09:25:04 +0000 | [diff] [blame] | 2019 | seq_printf(m, "Wait boosts: %d\n", atomic_read(&rps->boosts)); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2020 | |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame] | 2021 | if (INTEL_GEN(dev_priv) >= 6 && rps->enabled && dev_priv->gt.awake) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2022 | u32 rpup, rpupei; |
| 2023 | u32 rpdown, rpdownei; |
| 2024 | |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 2025 | intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2026 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2027 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2028 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2029 | 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] | 2030 | intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2031 | |
| 2032 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2033 | rps_power_to_str(rps->power.mode)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2034 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2035 | rpup && rpupei ? 100 * rpup / rpupei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2036 | rps->power.up_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2037 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
Chris Wilson | 23f4a28 | 2017-02-18 11:27:08 +0000 | [diff] [blame] | 2038 | rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, |
Chris Wilson | 60548c5 | 2018-07-31 14:26:29 +0100 | [diff] [blame] | 2039 | rps->power.down_threshold); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2040 | } else { |
| 2041 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2042 | } |
| 2043 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2044 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2045 | } |
| 2046 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2047 | static int i915_llc(struct seq_file *m, void *data) |
| 2048 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2049 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2050 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2051 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2052 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Daniele Ceraolo Spurio | f6ac993 | 2019-03-28 10:45:32 -0700 | [diff] [blame] | 2053 | seq_printf(m, "%s: %uMB\n", edram ? "eDRAM" : "eLLC", |
| 2054 | dev_priv->edram_size_mb); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2055 | |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2059 | static int i915_huc_load_status_info(struct seq_file *m, void *data) |
| 2060 | { |
| 2061 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2062 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2063 | struct drm_printer p; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2064 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2065 | if (!HAS_HUC(dev_priv)) |
| 2066 | return -ENODEV; |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2067 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2068 | p = drm_seq_file_printer(m); |
| 2069 | intel_uc_fw_dump(&dev_priv->huc.fw, &p); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2070 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2071 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2072 | seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2)); |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 2073 | |
| 2074 | return 0; |
| 2075 | } |
| 2076 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2077 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2078 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2079 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2080 | intel_wakeref_t wakeref; |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2081 | struct drm_printer p; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2082 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2083 | if (!HAS_GUC(dev_priv)) |
| 2084 | return -ENODEV; |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2085 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 2086 | p = drm_seq_file_printer(m); |
| 2087 | intel_uc_fw_dump(&dev_priv->guc.fw, &p); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2088 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2089 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 2090 | u32 tmp = I915_READ(GUC_STATUS); |
| 2091 | u32 i; |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2092 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2093 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2094 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2095 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2096 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2097 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2098 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2099 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2100 | seq_puts(m, "\nScratch registers:\n"); |
| 2101 | for (i = 0; i < 16; i++) { |
| 2102 | seq_printf(m, "\t%2d: \t0x%x\n", |
| 2103 | i, I915_READ(SOFT_SCRATCH(i))); |
| 2104 | } |
| 2105 | } |
sagar.a.kamble@intel.com | 3582ad1 | 2017-02-03 13:58:33 +0530 | [diff] [blame] | 2106 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2107 | return 0; |
| 2108 | } |
| 2109 | |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2110 | static const char * |
| 2111 | stringify_guc_log_type(enum guc_log_buffer_type type) |
| 2112 | { |
| 2113 | switch (type) { |
| 2114 | case GUC_ISR_LOG_BUFFER: |
| 2115 | return "ISR"; |
| 2116 | case GUC_DPC_LOG_BUFFER: |
| 2117 | return "DPC"; |
| 2118 | case GUC_CRASH_DUMP_LOG_BUFFER: |
| 2119 | return "CRASH"; |
| 2120 | default: |
| 2121 | MISSING_CASE(type); |
| 2122 | } |
| 2123 | |
| 2124 | return ""; |
| 2125 | } |
| 2126 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2127 | static void i915_guc_log_info(struct seq_file *m, |
| 2128 | struct drm_i915_private *dev_priv) |
| 2129 | { |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2130 | struct intel_guc_log *log = &dev_priv->guc.log; |
| 2131 | enum guc_log_buffer_type type; |
| 2132 | |
| 2133 | if (!intel_guc_log_relay_enabled(log)) { |
| 2134 | seq_puts(m, "GuC log relay disabled\n"); |
| 2135 | return; |
| 2136 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2137 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2138 | seq_puts(m, "GuC logging stats:\n"); |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2139 | |
Michał Winiarski | 6a96be2 | 2018-03-19 10:53:42 +0100 | [diff] [blame] | 2140 | seq_printf(m, "\tRelay full count: %u\n", |
Michał Winiarski | 5e24e4a | 2018-03-19 10:53:44 +0100 | [diff] [blame] | 2141 | log->relay.full_count); |
| 2142 | |
| 2143 | for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) { |
| 2144 | seq_printf(m, "\t%s:\tflush count %10u, overflow count %10u\n", |
| 2145 | stringify_guc_log_type(type), |
| 2146 | log->stats[type].flush, |
| 2147 | log->stats[type].sampled_overflow); |
| 2148 | } |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2149 | } |
| 2150 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2151 | static void i915_guc_client_info(struct seq_file *m, |
| 2152 | struct drm_i915_private *dev_priv, |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2153 | struct intel_guc_client *client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2154 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2155 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2156 | enum intel_engine_id id; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 2157 | u64 tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2158 | |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 2159 | seq_printf(m, "\tPriority %d, GuC stage index: %u, PD offset 0x%x\n", |
| 2160 | client->priority, client->stage_id, client->proc_desc_offset); |
Michał Winiarski | 59db36c | 2017-09-14 12:51:23 +0200 | [diff] [blame] | 2161 | seq_printf(m, "\tDoorbell id %d, offset: 0x%lx\n", |
| 2162 | client->doorbell_id, client->doorbell_offset); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2163 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2164 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2165 | u64 submissions = client->submissions[id]; |
| 2166 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2167 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2168 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2169 | } |
| 2170 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2171 | } |
| 2172 | |
| 2173 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2174 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2175 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2176 | const struct intel_guc *guc = &dev_priv->guc; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2177 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2178 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2179 | return -ENODEV; |
| 2180 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2181 | i915_guc_log_info(m, dev_priv); |
| 2182 | |
| 2183 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2184 | return 0; |
| 2185 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2186 | GEM_BUG_ON(!guc->execbuf_client); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2187 | |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2188 | seq_printf(m, "\nDoorbell map:\n"); |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 2189 | seq_printf(m, "\t%*pb\n", GUC_NUM_DOORBELLS, guc->doorbell_bitmap); |
Michał Winiarski | db55799 | 2018-03-19 10:53:43 +0100 | [diff] [blame] | 2190 | seq_printf(m, "Doorbell next cacheline: 0x%x\n", guc->db_cacheline); |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2191 | |
Chris Wilson | 334636c | 2016-11-29 12:10:20 +0000 | [diff] [blame] | 2192 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); |
| 2193 | i915_guc_client_info(m, dev_priv, guc->execbuf_client); |
Chris Wilson | e78c917 | 2018-02-07 21:05:42 +0000 | [diff] [blame] | 2194 | if (guc->preempt_client) { |
| 2195 | seq_printf(m, "\nGuC preempt client @ %p:\n", |
| 2196 | guc->preempt_client); |
| 2197 | i915_guc_client_info(m, dev_priv, guc->preempt_client); |
| 2198 | } |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2199 | |
| 2200 | /* Add more as required ... */ |
| 2201 | |
| 2202 | return 0; |
| 2203 | } |
| 2204 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2205 | static int i915_guc_stage_pool(struct seq_file *m, void *data) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2206 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2207 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2208 | const struct intel_guc *guc = &dev_priv->guc; |
| 2209 | struct guc_stage_desc *desc = guc->stage_desc_pool_vaddr; |
Sagar Arun Kamble | 5afc8b4 | 2017-11-16 19:02:40 +0530 | [diff] [blame] | 2210 | struct intel_guc_client *client = guc->execbuf_client; |
Chris Wilson | 3a891a6 | 2019-04-01 17:26:39 +0100 | [diff] [blame] | 2211 | intel_engine_mask_t tmp; |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2212 | int index; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2213 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2214 | if (!USES_GUC_SUBMISSION(dev_priv)) |
| 2215 | return -ENODEV; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2216 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2217 | for (index = 0; index < GUC_MAX_STAGE_DESCRIPTORS; index++, desc++) { |
| 2218 | struct intel_engine_cs *engine; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2219 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2220 | if (!(desc->attribute & GUC_STAGE_DESC_ATTR_ACTIVE)) |
| 2221 | continue; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2222 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2223 | seq_printf(m, "GuC stage descriptor %u:\n", index); |
| 2224 | seq_printf(m, "\tIndex: %u\n", desc->stage_id); |
| 2225 | seq_printf(m, "\tAttribute: 0x%x\n", desc->attribute); |
| 2226 | seq_printf(m, "\tPriority: %d\n", desc->priority); |
| 2227 | seq_printf(m, "\tDoorbell id: %d\n", desc->db_id); |
| 2228 | seq_printf(m, "\tEngines used: 0x%x\n", |
| 2229 | desc->engines_used); |
| 2230 | seq_printf(m, "\tDoorbell trigger phy: 0x%llx, cpu: 0x%llx, uK: 0x%x\n", |
| 2231 | desc->db_trigger_phy, |
| 2232 | desc->db_trigger_cpu, |
| 2233 | desc->db_trigger_uk); |
| 2234 | seq_printf(m, "\tProcess descriptor: 0x%x\n", |
| 2235 | desc->process_desc); |
Colin Ian King | 9a09485 | 2017-05-16 10:22:35 +0100 | [diff] [blame] | 2236 | seq_printf(m, "\tWorkqueue address: 0x%x, size: 0x%x\n", |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2237 | desc->wq_addr, desc->wq_size); |
| 2238 | seq_putc(m, '\n'); |
| 2239 | |
| 2240 | for_each_engine_masked(engine, dev_priv, client->engines, tmp) { |
| 2241 | u32 guc_engine_id = engine->guc_id; |
| 2242 | struct guc_execlist_context *lrc = |
| 2243 | &desc->lrc[guc_engine_id]; |
| 2244 | |
| 2245 | seq_printf(m, "\t%s LRC:\n", engine->name); |
| 2246 | seq_printf(m, "\t\tContext desc: 0x%x\n", |
| 2247 | lrc->context_desc); |
| 2248 | seq_printf(m, "\t\tContext id: 0x%x\n", lrc->context_id); |
| 2249 | seq_printf(m, "\t\tLRCA: 0x%x\n", lrc->ring_lrca); |
| 2250 | seq_printf(m, "\t\tRing begin: 0x%x\n", lrc->ring_begin); |
| 2251 | seq_printf(m, "\t\tRing end: 0x%x\n", lrc->ring_end); |
| 2252 | seq_putc(m, '\n'); |
| 2253 | } |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2254 | } |
| 2255 | |
Oscar Mateo | a8b9370 | 2017-05-10 15:04:51 +0000 | [diff] [blame] | 2256 | return 0; |
| 2257 | } |
| 2258 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2259 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2260 | { |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2261 | struct drm_info_node *node = m->private; |
| 2262 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 2263 | bool dump_load_err = !!node->info_ent->data; |
| 2264 | struct drm_i915_gem_object *obj = NULL; |
| 2265 | u32 *log; |
| 2266 | int i = 0; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2267 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2268 | if (!HAS_GUC(dev_priv)) |
| 2269 | return -ENODEV; |
| 2270 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2271 | if (dump_load_err) |
| 2272 | obj = dev_priv->guc.load_err_log; |
| 2273 | else if (dev_priv->guc.log.vma) |
| 2274 | obj = dev_priv->guc.log.vma->obj; |
| 2275 | |
| 2276 | if (!obj) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2277 | return 0; |
| 2278 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2279 | log = i915_gem_object_pin_map(obj, I915_MAP_WC); |
| 2280 | if (IS_ERR(log)) { |
| 2281 | DRM_DEBUG("Failed to pin object\n"); |
| 2282 | seq_puts(m, "(log data unaccessible)\n"); |
| 2283 | return PTR_ERR(log); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2284 | } |
| 2285 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2286 | for (i = 0; i < obj->base.size / sizeof(u32); i += 4) |
| 2287 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2288 | *(log + i), *(log + i + 1), |
| 2289 | *(log + i + 2), *(log + i + 3)); |
| 2290 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2291 | seq_putc(m, '\n'); |
| 2292 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 2293 | i915_gem_object_unpin_map(obj); |
| 2294 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2295 | return 0; |
| 2296 | } |
| 2297 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2298 | static int i915_guc_log_level_get(void *data, u64 *val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2299 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2300 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2301 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2302 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2303 | return -ENODEV; |
| 2304 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2305 | *val = intel_guc_log_get_level(&dev_priv->guc.log); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2306 | |
| 2307 | return 0; |
| 2308 | } |
| 2309 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2310 | static int i915_guc_log_level_set(void *data, u64 val) |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2311 | { |
Chris Wilson | bcc36d8 | 2017-04-07 20:42:20 +0100 | [diff] [blame] | 2312 | struct drm_i915_private *dev_priv = data; |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2313 | |
Michał Winiarski | 86aa824 | 2018-03-08 16:46:53 +0100 | [diff] [blame] | 2314 | if (!USES_GUC(dev_priv)) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2315 | return -ENODEV; |
| 2316 | |
Piotr Piórkowski | 50935ac | 2018-06-04 16:19:41 +0200 | [diff] [blame] | 2317 | return intel_guc_log_set_level(&dev_priv->guc.log, val); |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2318 | } |
| 2319 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2320 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_level_fops, |
| 2321 | i915_guc_log_level_get, i915_guc_log_level_set, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2322 | "%lld\n"); |
| 2323 | |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 2324 | static int i915_guc_log_relay_open(struct inode *inode, struct file *file) |
| 2325 | { |
| 2326 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2327 | |
| 2328 | if (!USES_GUC(dev_priv)) |
| 2329 | return -ENODEV; |
| 2330 | |
| 2331 | file->private_data = &dev_priv->guc.log; |
| 2332 | |
| 2333 | return intel_guc_log_relay_open(&dev_priv->guc.log); |
| 2334 | } |
| 2335 | |
| 2336 | static ssize_t |
| 2337 | i915_guc_log_relay_write(struct file *filp, |
| 2338 | const char __user *ubuf, |
| 2339 | size_t cnt, |
| 2340 | loff_t *ppos) |
| 2341 | { |
| 2342 | struct intel_guc_log *log = filp->private_data; |
| 2343 | |
| 2344 | intel_guc_log_relay_flush(log); |
| 2345 | |
| 2346 | return cnt; |
| 2347 | } |
| 2348 | |
| 2349 | static int i915_guc_log_relay_release(struct inode *inode, struct file *file) |
| 2350 | { |
| 2351 | struct drm_i915_private *dev_priv = inode->i_private; |
| 2352 | |
| 2353 | intel_guc_log_relay_close(&dev_priv->guc.log); |
| 2354 | |
| 2355 | return 0; |
| 2356 | } |
| 2357 | |
| 2358 | static const struct file_operations i915_guc_log_relay_fops = { |
| 2359 | .owner = THIS_MODULE, |
| 2360 | .open = i915_guc_log_relay_open, |
| 2361 | .write = i915_guc_log_relay_write, |
| 2362 | .release = i915_guc_log_relay_release, |
| 2363 | }; |
| 2364 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2365 | static int i915_psr_sink_status_show(struct seq_file *m, void *data) |
| 2366 | { |
| 2367 | u8 val; |
| 2368 | static const char * const sink_status[] = { |
| 2369 | "inactive", |
| 2370 | "transition to active, capture and display", |
| 2371 | "active, display from RFB", |
| 2372 | "active, capture and display on sink device timings", |
| 2373 | "transition to inactive, capture and display, timing re-sync", |
| 2374 | "reserved", |
| 2375 | "reserved", |
| 2376 | "sink internal error", |
| 2377 | }; |
| 2378 | struct drm_connector *connector = m->private; |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2379 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2380 | struct intel_dp *intel_dp = |
| 2381 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2382 | int ret; |
| 2383 | |
| 2384 | if (!CAN_PSR(dev_priv)) { |
| 2385 | seq_puts(m, "PSR Unsupported\n"); |
| 2386 | return -ENODEV; |
| 2387 | } |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2388 | |
| 2389 | if (connector->status != connector_status_connected) |
| 2390 | return -ENODEV; |
| 2391 | |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2392 | ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val); |
| 2393 | |
| 2394 | if (ret == 1) { |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2395 | const char *str = "unknown"; |
| 2396 | |
| 2397 | val &= DP_PSR_SINK_STATE_MASK; |
| 2398 | if (val < ARRAY_SIZE(sink_status)) |
| 2399 | str = sink_status[val]; |
| 2400 | seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str); |
| 2401 | } else { |
Rodrigo Vivi | 7a72c78 | 2018-07-19 17:31:55 -0700 | [diff] [blame] | 2402 | return ret; |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 2403 | } |
| 2404 | |
| 2405 | return 0; |
| 2406 | } |
| 2407 | DEFINE_SHOW_ATTRIBUTE(i915_psr_sink_status); |
| 2408 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2409 | static void |
| 2410 | 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] | 2411 | { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2412 | u32 val, status_val; |
| 2413 | const char *status = "unknown"; |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2414 | |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2415 | if (dev_priv->psr.psr2_enabled) { |
| 2416 | static const char * const live_status[] = { |
| 2417 | "IDLE", |
| 2418 | "CAPTURE", |
| 2419 | "CAPTURE_FS", |
| 2420 | "SLEEP", |
| 2421 | "BUFON_FW", |
| 2422 | "ML_UP", |
| 2423 | "SU_STANDBY", |
| 2424 | "FAST_SLEEP", |
| 2425 | "DEEP_SLEEP", |
| 2426 | "BUF_ON", |
| 2427 | "TG_ON" |
| 2428 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2429 | val = I915_READ(EDP_PSR2_STATUS); |
| 2430 | status_val = (val & EDP_PSR2_STATUS_STATE_MASK) >> |
| 2431 | EDP_PSR2_STATUS_STATE_SHIFT; |
| 2432 | if (status_val < ARRAY_SIZE(live_status)) |
| 2433 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2434 | } else { |
| 2435 | static const char * const live_status[] = { |
| 2436 | "IDLE", |
| 2437 | "SRDONACK", |
| 2438 | "SRDENT", |
| 2439 | "BUFOFF", |
| 2440 | "BUFON", |
| 2441 | "AUXACK", |
| 2442 | "SRDOFFACK", |
| 2443 | "SRDENT_ON", |
| 2444 | }; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2445 | val = I915_READ(EDP_PSR_STATUS); |
| 2446 | status_val = (val & EDP_PSR_STATUS_STATE_MASK) >> |
| 2447 | EDP_PSR_STATUS_STATE_SHIFT; |
| 2448 | if (status_val < ARRAY_SIZE(live_status)) |
| 2449 | status = live_status[status_val]; |
Vathsala Nagaraju | 00b0629 | 2018-06-27 13:38:30 +0530 | [diff] [blame] | 2450 | } |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2451 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2452 | seq_printf(m, "Source PSR status: %s [0x%08x]\n", status, val); |
Chris Wilson | b86bef20 | 2017-01-16 13:06:21 +0000 | [diff] [blame] | 2453 | } |
| 2454 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2455 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2456 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2457 | 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] | 2458 | struct i915_psr *psr = &dev_priv->psr; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2459 | intel_wakeref_t wakeref; |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2460 | const char *status; |
| 2461 | bool enabled; |
| 2462 | u32 val; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2463 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2464 | if (!HAS_PSR(dev_priv)) |
| 2465 | return -ENODEV; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2466 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2467 | seq_printf(m, "Sink support: %s", yesno(psr->sink_support)); |
| 2468 | if (psr->dp) |
| 2469 | seq_printf(m, " [0x%02x]", psr->dp->psr_dpcd[0]); |
| 2470 | seq_puts(m, "\n"); |
| 2471 | |
| 2472 | if (!psr->sink_support) |
Dhinakaran Pandiyan | c9ef291 | 2018-01-03 13:38:24 -0800 | [diff] [blame] | 2473 | return 0; |
| 2474 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2475 | wakeref = intel_runtime_pm_get(dev_priv); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2476 | mutex_lock(&psr->lock); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2477 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2478 | if (psr->enabled) |
| 2479 | status = psr->psr2_enabled ? "PSR2 enabled" : "PSR1 enabled"; |
Dhinakaran Pandiyan | ce3508f | 2018-05-11 16:00:59 -0700 | [diff] [blame] | 2480 | else |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2481 | status = "disabled"; |
| 2482 | seq_printf(m, "PSR mode: %s\n", status); |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2483 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2484 | if (!psr->enabled) |
| 2485 | goto unlock; |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2486 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2487 | if (psr->psr2_enabled) { |
| 2488 | val = I915_READ(EDP_PSR2_CTL); |
| 2489 | enabled = val & EDP_PSR2_ENABLE; |
| 2490 | } else { |
| 2491 | val = I915_READ(EDP_PSR_CTL); |
| 2492 | enabled = val & EDP_PSR_ENABLE; |
| 2493 | } |
| 2494 | seq_printf(m, "Source PSR ctl: %s [0x%08x]\n", |
| 2495 | enableddisabled(enabled), val); |
| 2496 | psr_source_status(dev_priv, m); |
| 2497 | seq_printf(m, "Busy frontbuffer bits: 0x%08x\n", |
| 2498 | psr->busy_frontbuffer_bits); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2499 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2500 | /* |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2501 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2502 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2503 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2504 | val = I915_READ(EDP_PSR_PERF_CNT) & EDP_PSR_PERF_CNT_MASK; |
| 2505 | seq_printf(m, "Performance counter: %u\n", val); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2506 | } |
Nagaraju, Vathsala | 6ba1f9e | 2017-01-06 22:02:32 +0530 | [diff] [blame] | 2507 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2508 | if (psr->debug & I915_PSR_DEBUG_IRQ) { |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2509 | seq_printf(m, "Last attempted entry at: %lld\n", |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2510 | psr->last_entry_attempt); |
| 2511 | seq_printf(m, "Last exit at: %lld\n", psr->last_exit); |
Dhinakaran Pandiyan | 3f983e54 | 2018-04-03 14:24:20 -0700 | [diff] [blame] | 2512 | } |
| 2513 | |
José Roberto de Souza | a81f781 | 2019-01-17 12:55:48 -0800 | [diff] [blame] | 2514 | if (psr->psr2_enabled) { |
| 2515 | u32 su_frames_val[3]; |
| 2516 | int frame; |
| 2517 | |
| 2518 | /* |
| 2519 | * Reading all 3 registers before hand to minimize crossing a |
| 2520 | * frame boundary between register reads |
| 2521 | */ |
| 2522 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame += 3) |
| 2523 | su_frames_val[frame / 3] = I915_READ(PSR2_SU_STATUS(frame)); |
| 2524 | |
| 2525 | seq_puts(m, "Frame:\tPSR2 SU blocks:\n"); |
| 2526 | |
| 2527 | for (frame = 0; frame < PSR2_SU_STATUS_FRAMES; frame++) { |
| 2528 | u32 su_blocks; |
| 2529 | |
| 2530 | su_blocks = su_frames_val[frame / 3] & |
| 2531 | PSR2_SU_STATUS_MASK(frame); |
| 2532 | su_blocks = su_blocks >> PSR2_SU_STATUS_SHIFT(frame); |
| 2533 | seq_printf(m, "%d\t%d\n", frame, su_blocks); |
| 2534 | } |
| 2535 | } |
| 2536 | |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2537 | unlock: |
| 2538 | mutex_unlock(&psr->lock); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2539 | intel_runtime_pm_put(dev_priv, wakeref); |
José Roberto de Souza | 47c6cd5 | 2019-01-17 12:55:46 -0800 | [diff] [blame] | 2540 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2541 | return 0; |
| 2542 | } |
| 2543 | |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2544 | static int |
| 2545 | i915_edp_psr_debug_set(void *data, u64 val) |
| 2546 | { |
| 2547 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2548 | intel_wakeref_t wakeref; |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2549 | int ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2550 | |
| 2551 | if (!CAN_PSR(dev_priv)) |
| 2552 | return -ENODEV; |
| 2553 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2554 | DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2555 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2556 | wakeref = intel_runtime_pm_get(dev_priv); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2557 | |
José Roberto de Souza | 23ec9f5 | 2019-02-06 13:18:45 -0800 | [diff] [blame] | 2558 | ret = intel_psr_debug_set(dev_priv, val); |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2559 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2560 | intel_runtime_pm_put(dev_priv, wakeref); |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2561 | |
Maarten Lankhorst | c44301f | 2018-08-09 16:21:01 +0200 | [diff] [blame] | 2562 | return ret; |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 2563 | } |
| 2564 | |
| 2565 | static int |
| 2566 | i915_edp_psr_debug_get(void *data, u64 *val) |
| 2567 | { |
| 2568 | struct drm_i915_private *dev_priv = data; |
| 2569 | |
| 2570 | if (!CAN_PSR(dev_priv)) |
| 2571 | return -ENODEV; |
| 2572 | |
| 2573 | *val = READ_ONCE(dev_priv->psr.debug); |
| 2574 | return 0; |
| 2575 | } |
| 2576 | |
| 2577 | DEFINE_SIMPLE_ATTRIBUTE(i915_edp_psr_debug_fops, |
| 2578 | i915_edp_psr_debug_get, i915_edp_psr_debug_set, |
| 2579 | "%llu\n"); |
| 2580 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2581 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2582 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2583 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2584 | unsigned long long power; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2585 | intel_wakeref_t wakeref; |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2586 | u32 units; |
| 2587 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2588 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2589 | return -ENODEV; |
| 2590 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2591 | if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2592 | return -ENODEV; |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2593 | |
| 2594 | units = (power & 0x1f00) >> 8; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 2595 | with_intel_runtime_pm(dev_priv, wakeref) |
| 2596 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2597 | |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2598 | power = (1000000 * power) >> units; /* convert to uJ */ |
Gabriel Krisman Bertazi | d38014e | 2017-07-26 02:30:16 -0300 | [diff] [blame] | 2599 | seq_printf(m, "%llu", power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2600 | |
| 2601 | return 0; |
| 2602 | } |
| 2603 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2604 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2605 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2606 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2607 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2608 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2609 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2610 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2611 | |
Chris Wilson | 25c896bd | 2019-01-14 14:21:25 +0000 | [diff] [blame] | 2612 | seq_printf(m, "Runtime power status: %s\n", |
| 2613 | enableddisabled(!dev_priv->power_domains.wakeref)); |
| 2614 | |
Chris Wilson | d9948a1 | 2019-02-28 10:20:35 +0000 | [diff] [blame] | 2615 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2616 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2617 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2618 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2619 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2620 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2621 | #else |
| 2622 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2623 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2624 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2625 | pci_power_name(pdev->current_state), |
| 2626 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2627 | |
Chris Wilson | bd780f3 | 2019-01-14 14:21:09 +0000 | [diff] [blame] | 2628 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) { |
| 2629 | struct drm_printer p = drm_seq_file_printer(m); |
| 2630 | |
| 2631 | print_intel_runtime_pm_wakeref(dev_priv, &p); |
| 2632 | } |
| 2633 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2634 | return 0; |
| 2635 | } |
| 2636 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2637 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2638 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2639 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2640 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2641 | int i; |
| 2642 | |
| 2643 | mutex_lock(&power_domains->lock); |
| 2644 | |
| 2645 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2646 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2647 | struct i915_power_well *power_well; |
| 2648 | enum intel_display_power_domain power_domain; |
| 2649 | |
| 2650 | power_well = &power_domains->power_wells[i]; |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2651 | seq_printf(m, "%-25s %d\n", power_well->desc->name, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2652 | power_well->count); |
| 2653 | |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 2654 | for_each_power_domain(power_domain, power_well->desc->domains) |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2655 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2656 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2657 | power_domains->domain_use_count[power_domain]); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2658 | } |
| 2659 | |
| 2660 | mutex_unlock(&power_domains->lock); |
| 2661 | |
| 2662 | return 0; |
| 2663 | } |
| 2664 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2665 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2666 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2667 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2668 | intel_wakeref_t wakeref; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2669 | struct intel_csr *csr; |
| 2670 | |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 2671 | if (!HAS_CSR(dev_priv)) |
| 2672 | return -ENODEV; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2673 | |
| 2674 | csr = &dev_priv->csr; |
| 2675 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2676 | wakeref = intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2677 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2678 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2679 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2680 | |
| 2681 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2682 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2683 | |
| 2684 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2685 | CSR_VERSION_MINOR(csr->version)); |
| 2686 | |
Imre Deak | 34b2f8d | 2018-10-31 22:02:20 +0200 | [diff] [blame] | 2687 | if (WARN_ON(INTEL_GEN(dev_priv) > 11)) |
| 2688 | goto out; |
| 2689 | |
| 2690 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2691 | I915_READ(IS_BROXTON(dev_priv) ? BXT_CSR_DC3_DC5_COUNT : |
| 2692 | SKL_CSR_DC3_DC5_COUNT)); |
| 2693 | if (!IS_GEN9_LP(dev_priv)) |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2694 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2695 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2696 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2697 | out: |
| 2698 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2699 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2700 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2701 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2702 | intel_runtime_pm_put(dev_priv, wakeref); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2703 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2704 | return 0; |
| 2705 | } |
| 2706 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2707 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2708 | struct drm_display_mode *mode) |
| 2709 | { |
| 2710 | int i; |
| 2711 | |
| 2712 | for (i = 0; i < tabs; i++) |
| 2713 | seq_putc(m, '\t'); |
| 2714 | |
Shayenne Moura | 4fb6bb8 | 2018-12-20 10:27:57 -0200 | [diff] [blame] | 2715 | seq_printf(m, DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2716 | } |
| 2717 | |
| 2718 | static void intel_encoder_info(struct seq_file *m, |
| 2719 | struct intel_crtc *intel_crtc, |
| 2720 | struct intel_encoder *intel_encoder) |
| 2721 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2722 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2723 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2724 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2725 | struct intel_connector *intel_connector; |
| 2726 | struct drm_encoder *encoder; |
| 2727 | |
| 2728 | encoder = &intel_encoder->base; |
| 2729 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2730 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2731 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2732 | struct drm_connector *connector = &intel_connector->base; |
| 2733 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2734 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2735 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2736 | drm_get_connector_status_name(connector->status)); |
| 2737 | if (connector->status == connector_status_connected) { |
| 2738 | struct drm_display_mode *mode = &crtc->mode; |
| 2739 | seq_printf(m, ", mode:\n"); |
| 2740 | intel_seq_print_mode(m, 2, mode); |
| 2741 | } else { |
| 2742 | seq_putc(m, '\n'); |
| 2743 | } |
| 2744 | } |
| 2745 | } |
| 2746 | |
| 2747 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2748 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2749 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2750 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2751 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2752 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2753 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2754 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2755 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2756 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2757 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2758 | fb->base.id, plane_state->src_x >> 16, |
| 2759 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2760 | else |
| 2761 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2762 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2763 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2764 | } |
| 2765 | |
| 2766 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2767 | { |
| 2768 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2769 | |
| 2770 | seq_printf(m, "\tfixed mode:\n"); |
| 2771 | intel_seq_print_mode(m, 2, mode); |
| 2772 | } |
| 2773 | |
| 2774 | static void intel_dp_info(struct seq_file *m, |
| 2775 | struct intel_connector *intel_connector) |
| 2776 | { |
| 2777 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2778 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2779 | |
| 2780 | 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] | 2781 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2782 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2783 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2784 | |
| 2785 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2786 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2787 | } |
| 2788 | |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2789 | static void intel_dp_mst_info(struct seq_file *m, |
| 2790 | struct intel_connector *intel_connector) |
| 2791 | { |
| 2792 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2793 | struct intel_dp_mst_encoder *intel_mst = |
| 2794 | enc_to_mst(&intel_encoder->base); |
| 2795 | struct intel_digital_port *intel_dig_port = intel_mst->primary; |
| 2796 | struct intel_dp *intel_dp = &intel_dig_port->dp; |
| 2797 | bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, |
| 2798 | intel_connector->port); |
| 2799 | |
| 2800 | seq_printf(m, "\taudio support: %s\n", yesno(has_audio)); |
| 2801 | } |
| 2802 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2803 | static void intel_hdmi_info(struct seq_file *m, |
| 2804 | struct intel_connector *intel_connector) |
| 2805 | { |
| 2806 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2807 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2808 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2809 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2810 | } |
| 2811 | |
| 2812 | static void intel_lvds_info(struct seq_file *m, |
| 2813 | struct intel_connector *intel_connector) |
| 2814 | { |
| 2815 | intel_panel_info(m, &intel_connector->panel); |
| 2816 | } |
| 2817 | |
| 2818 | static void intel_connector_info(struct seq_file *m, |
| 2819 | struct drm_connector *connector) |
| 2820 | { |
| 2821 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2822 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2823 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2824 | |
| 2825 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2826 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2827 | drm_get_connector_status_name(connector->status)); |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame] | 2828 | |
| 2829 | if (connector->status == connector_status_disconnected) |
| 2830 | return; |
| 2831 | |
José Roberto de Souza | 3e037f9 | 2018-10-30 14:57:46 -0700 | [diff] [blame] | 2832 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2833 | connector->display_info.width_mm, |
| 2834 | connector->display_info.height_mm); |
| 2835 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2836 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2837 | seq_printf(m, "\tCEA rev: %d\n", connector->display_info.cea_rev); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2838 | |
Maarten Lankhorst | 77d1f61 | 2017-06-26 10:33:49 +0200 | [diff] [blame] | 2839 | if (!intel_encoder) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2840 | return; |
| 2841 | |
| 2842 | switch (connector->connector_type) { |
| 2843 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2844 | case DRM_MODE_CONNECTOR_eDP: |
Libin Yang | 9a148a9 | 2016-11-28 20:07:05 +0800 | [diff] [blame] | 2845 | if (intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2846 | intel_dp_mst_info(m, intel_connector); |
| 2847 | else |
| 2848 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2849 | break; |
| 2850 | case DRM_MODE_CONNECTOR_LVDS: |
| 2851 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2852 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2853 | break; |
| 2854 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2855 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
Ville Syrjälä | 7e732ca | 2017-10-27 22:31:24 +0300 | [diff] [blame] | 2856 | intel_encoder->type == INTEL_OUTPUT_DDI) |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2857 | intel_hdmi_info(m, intel_connector); |
| 2858 | break; |
| 2859 | default: |
| 2860 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2861 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2862 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2863 | seq_printf(m, "\tmodes:\n"); |
| 2864 | list_for_each_entry(mode, &connector->modes, head) |
| 2865 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2866 | } |
| 2867 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2868 | static const char *plane_type(enum drm_plane_type type) |
| 2869 | { |
| 2870 | switch (type) { |
| 2871 | case DRM_PLANE_TYPE_OVERLAY: |
| 2872 | return "OVL"; |
| 2873 | case DRM_PLANE_TYPE_PRIMARY: |
| 2874 | return "PRI"; |
| 2875 | case DRM_PLANE_TYPE_CURSOR: |
| 2876 | return "CUR"; |
| 2877 | /* |
| 2878 | * Deliberately omitting default: to generate compiler warnings |
| 2879 | * when a new drm_plane_type gets added. |
| 2880 | */ |
| 2881 | } |
| 2882 | |
| 2883 | return "unknown"; |
| 2884 | } |
| 2885 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2886 | static void plane_rotation(char *buf, size_t bufsize, unsigned int rotation) |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2887 | { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2888 | /* |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2889 | * According to doc only one DRM_MODE_ROTATE_ is allowed but this |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2890 | * will print them all to visualize if the values are misused |
| 2891 | */ |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2892 | snprintf(buf, bufsize, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2893 | "%s%s%s%s%s%s(0x%08x)", |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 2894 | (rotation & DRM_MODE_ROTATE_0) ? "0 " : "", |
| 2895 | (rotation & DRM_MODE_ROTATE_90) ? "90 " : "", |
| 2896 | (rotation & DRM_MODE_ROTATE_180) ? "180 " : "", |
| 2897 | (rotation & DRM_MODE_ROTATE_270) ? "270 " : "", |
| 2898 | (rotation & DRM_MODE_REFLECT_X) ? "FLIPX " : "", |
| 2899 | (rotation & DRM_MODE_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2900 | rotation); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2901 | } |
| 2902 | |
| 2903 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2904 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2905 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2906 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2907 | struct intel_plane *intel_plane; |
| 2908 | |
| 2909 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 2910 | struct drm_plane_state *state; |
| 2911 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2912 | struct drm_format_name_buf format_name; |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2913 | char rot_str[48]; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2914 | |
| 2915 | if (!plane->state) { |
| 2916 | seq_puts(m, "plane->state is NULL!\n"); |
| 2917 | continue; |
| 2918 | } |
| 2919 | |
| 2920 | state = plane->state; |
| 2921 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2922 | if (state->fb) { |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 2923 | drm_get_format_name(state->fb->format->format, |
| 2924 | &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2925 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2926 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 2927 | } |
| 2928 | |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2929 | plane_rotation(rot_str, sizeof(rot_str), state->rotation); |
| 2930 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2931 | 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", |
| 2932 | plane->base.id, |
| 2933 | plane_type(intel_plane->base.type), |
| 2934 | state->crtc_x, state->crtc_y, |
| 2935 | state->crtc_w, state->crtc_h, |
| 2936 | (state->src_x >> 16), |
| 2937 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 2938 | (state->src_y >> 16), |
| 2939 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 2940 | (state->src_w >> 16), |
| 2941 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 2942 | (state->src_h >> 16), |
| 2943 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 2944 | format_name.str, |
Jani Nikula | 5852a15 | 2019-01-07 16:51:49 +0200 | [diff] [blame] | 2945 | rot_str); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2946 | } |
| 2947 | } |
| 2948 | |
| 2949 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2950 | { |
| 2951 | struct intel_crtc_state *pipe_config; |
| 2952 | int num_scalers = intel_crtc->num_scalers; |
| 2953 | int i; |
| 2954 | |
| 2955 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 2956 | |
| 2957 | /* Not all platformas have a scaler */ |
| 2958 | if (num_scalers) { |
| 2959 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 2960 | num_scalers, |
| 2961 | pipe_config->scaler_state.scaler_users, |
| 2962 | pipe_config->scaler_state.scaler_id); |
| 2963 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 2964 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2965 | struct intel_scaler *sc = |
| 2966 | &pipe_config->scaler_state.scalers[i]; |
| 2967 | |
| 2968 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 2969 | i, yesno(sc->in_use), sc->mode); |
| 2970 | } |
| 2971 | seq_puts(m, "\n"); |
| 2972 | } else { |
| 2973 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 2974 | } |
| 2975 | } |
| 2976 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2977 | static int i915_display_info(struct seq_file *m, void *unused) |
| 2978 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2979 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2980 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2981 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2982 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2983 | struct drm_connector_list_iter conn_iter; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2984 | intel_wakeref_t wakeref; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2985 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 2986 | wakeref = intel_runtime_pm_get(dev_priv); |
| 2987 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2988 | seq_printf(m, "CRTC info\n"); |
| 2989 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 2990 | for_each_intel_crtc(dev, crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 2991 | struct intel_crtc_state *pipe_config; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2992 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 2993 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 2994 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 2995 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2996 | 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] | 2997 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 2998 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2999 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3000 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3001 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3002 | if (pipe_config->base.active) { |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3003 | struct intel_plane *cursor = |
| 3004 | to_intel_plane(crtc->base.cursor); |
| 3005 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3006 | intel_crtc_info(m, crtc); |
| 3007 | |
Ville Syrjälä | cd5dcbf | 2017-03-27 21:55:35 +0300 | [diff] [blame] | 3008 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x\n", |
| 3009 | yesno(cursor->base.state->visible), |
| 3010 | cursor->base.state->crtc_x, |
| 3011 | cursor->base.state->crtc_y, |
| 3012 | cursor->base.state->crtc_w, |
| 3013 | cursor->base.state->crtc_h, |
| 3014 | cursor->cursor.base); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3015 | intel_scaler_info(m, crtc); |
| 3016 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3017 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3018 | |
| 3019 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3020 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3021 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3022 | drm_modeset_unlock(&crtc->base.mutex); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3023 | } |
| 3024 | |
| 3025 | seq_printf(m, "\n"); |
| 3026 | seq_printf(m, "Connector info\n"); |
| 3027 | seq_printf(m, "--------------\n"); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3028 | mutex_lock(&dev->mode_config.mutex); |
| 3029 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3030 | drm_for_each_connector_iter(connector, &conn_iter) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3031 | intel_connector_info(m, connector); |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3032 | drm_connector_list_iter_end(&conn_iter); |
| 3033 | mutex_unlock(&dev->mode_config.mutex); |
| 3034 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3035 | intel_runtime_pm_put(dev_priv, wakeref); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3036 | |
| 3037 | return 0; |
| 3038 | } |
| 3039 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3040 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3041 | { |
| 3042 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3043 | struct intel_engine_cs *engine; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3044 | intel_wakeref_t wakeref; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3045 | enum intel_engine_id id; |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3046 | struct drm_printer p; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3047 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3048 | wakeref = intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3049 | |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame] | 3050 | seq_printf(m, "GT awake? %s [%d]\n", |
| 3051 | yesno(dev_priv->gt.awake), |
| 3052 | atomic_read(&dev_priv->gt.wakeref.count)); |
Lionel Landwerlin | f577a03 | 2017-11-13 23:34:53 +0000 | [diff] [blame] | 3053 | seq_printf(m, "CS timestamp frequency: %u kHz\n", |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3054 | RUNTIME_INFO(dev_priv)->cs_timestamp_frequency_khz); |
Chris Wilson | f73b567 | 2017-03-02 15:03:56 +0000 | [diff] [blame] | 3055 | |
Chris Wilson | f636edb | 2017-10-09 12:02:57 +0100 | [diff] [blame] | 3056 | p = drm_seq_file_printer(m); |
| 3057 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 0db18b1 | 2017-12-08 01:23:00 +0000 | [diff] [blame] | 3058 | intel_engine_dump(engine, &p, "%s\n", engine->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3059 | |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3060 | intel_runtime_pm_put(dev_priv, wakeref); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3061 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3062 | return 0; |
| 3063 | } |
| 3064 | |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3065 | static int i915_rcs_topology(struct seq_file *m, void *unused) |
| 3066 | { |
| 3067 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3068 | struct drm_printer p = drm_seq_file_printer(m); |
| 3069 | |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 3070 | intel_device_info_dump_topology(&RUNTIME_INFO(dev_priv)->sseu, &p); |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 3071 | |
| 3072 | return 0; |
| 3073 | } |
| 3074 | |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 3075 | static int i915_shrinker_info(struct seq_file *m, void *unused) |
| 3076 | { |
| 3077 | struct drm_i915_private *i915 = node_to_i915(m->private); |
| 3078 | |
| 3079 | seq_printf(m, "seeks = %d\n", i915->mm.shrinker.seeks); |
| 3080 | seq_printf(m, "batch = %lu\n", i915->mm.shrinker.batch); |
| 3081 | |
| 3082 | return 0; |
| 3083 | } |
| 3084 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3085 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3086 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3087 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3088 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3089 | int i; |
| 3090 | |
| 3091 | drm_modeset_lock_all(dev); |
| 3092 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3093 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3094 | |
Lucas De Marchi | 72f775f | 2018-03-20 15:06:34 -0700 | [diff] [blame] | 3095 | 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] | 3096 | pll->info->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3097 | 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] | 3098 | pll->state.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3099 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3100 | 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] | 3101 | seq_printf(m, " dpll_md: 0x%08x\n", |
Ander Conselvan de Oliveira | 2c42e53 | 2016-12-29 17:22:09 +0200 | [diff] [blame] | 3102 | pll->state.hw_state.dpll_md); |
| 3103 | seq_printf(m, " fp0: 0x%08x\n", pll->state.hw_state.fp0); |
| 3104 | seq_printf(m, " fp1: 0x%08x\n", pll->state.hw_state.fp1); |
| 3105 | seq_printf(m, " wrpll: 0x%08x\n", pll->state.hw_state.wrpll); |
Paulo Zanoni | c27e917 | 2018-04-27 16:14:36 -0700 | [diff] [blame] | 3106 | seq_printf(m, " cfgcr0: 0x%08x\n", pll->state.hw_state.cfgcr0); |
| 3107 | seq_printf(m, " cfgcr1: 0x%08x\n", pll->state.hw_state.cfgcr1); |
| 3108 | seq_printf(m, " mg_refclkin_ctl: 0x%08x\n", |
| 3109 | pll->state.hw_state.mg_refclkin_ctl); |
| 3110 | seq_printf(m, " mg_clktop2_coreclkctl1: 0x%08x\n", |
| 3111 | pll->state.hw_state.mg_clktop2_coreclkctl1); |
| 3112 | seq_printf(m, " mg_clktop2_hsclkctl: 0x%08x\n", |
| 3113 | pll->state.hw_state.mg_clktop2_hsclkctl); |
| 3114 | seq_printf(m, " mg_pll_div0: 0x%08x\n", |
| 3115 | pll->state.hw_state.mg_pll_div0); |
| 3116 | seq_printf(m, " mg_pll_div1: 0x%08x\n", |
| 3117 | pll->state.hw_state.mg_pll_div1); |
| 3118 | seq_printf(m, " mg_pll_lf: 0x%08x\n", |
| 3119 | pll->state.hw_state.mg_pll_lf); |
| 3120 | seq_printf(m, " mg_pll_frac_lock: 0x%08x\n", |
| 3121 | pll->state.hw_state.mg_pll_frac_lock); |
| 3122 | seq_printf(m, " mg_pll_ssc: 0x%08x\n", |
| 3123 | pll->state.hw_state.mg_pll_ssc); |
| 3124 | seq_printf(m, " mg_pll_bias: 0x%08x\n", |
| 3125 | pll->state.hw_state.mg_pll_bias); |
| 3126 | seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", |
| 3127 | pll->state.hw_state.mg_pll_tdc_coldst_bias); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3128 | } |
| 3129 | drm_modeset_unlock_all(dev); |
| 3130 | |
| 3131 | return 0; |
| 3132 | } |
| 3133 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3134 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3135 | { |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3136 | struct drm_i915_private *i915 = node_to_i915(m->private); |
Chris Wilson | 8a68d46 | 2019-03-05 18:03:30 +0000 | [diff] [blame] | 3137 | const struct i915_wa_list *wal = &i915->engine[RCS0]->ctx_wa_list; |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3138 | struct i915_wa *wa; |
| 3139 | unsigned int i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3140 | |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3141 | seq_printf(m, "Workarounds applied: %u\n", wal->count); |
| 3142 | for (i = 0, wa = wal->list; i < wal->count; i++, wa++) |
Chris Wilson | 548764b | 2018-06-15 13:02:07 +0100 | [diff] [blame] | 3143 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n", |
Tvrtko Ursulin | 452420d | 2018-12-03 13:33:57 +0000 | [diff] [blame] | 3144 | i915_mmio_reg_offset(wa->reg), wa->val, wa->mask); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3145 | |
| 3146 | return 0; |
| 3147 | } |
| 3148 | |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3149 | static int i915_ipc_status_show(struct seq_file *m, void *data) |
| 3150 | { |
| 3151 | struct drm_i915_private *dev_priv = m->private; |
| 3152 | |
| 3153 | seq_printf(m, "Isochronous Priority Control: %s\n", |
| 3154 | yesno(dev_priv->ipc_enabled)); |
| 3155 | return 0; |
| 3156 | } |
| 3157 | |
| 3158 | static int i915_ipc_status_open(struct inode *inode, struct file *file) |
| 3159 | { |
| 3160 | struct drm_i915_private *dev_priv = inode->i_private; |
| 3161 | |
| 3162 | if (!HAS_IPC(dev_priv)) |
| 3163 | return -ENODEV; |
| 3164 | |
| 3165 | return single_open(file, i915_ipc_status_show, dev_priv); |
| 3166 | } |
| 3167 | |
| 3168 | static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf, |
| 3169 | size_t len, loff_t *offp) |
| 3170 | { |
| 3171 | struct seq_file *m = file->private_data; |
| 3172 | struct drm_i915_private *dev_priv = m->private; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3173 | intel_wakeref_t wakeref; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3174 | bool enable; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3175 | int ret; |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3176 | |
| 3177 | ret = kstrtobool_from_user(ubuf, len, &enable); |
| 3178 | if (ret < 0) |
| 3179 | return ret; |
| 3180 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3181 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3182 | if (!dev_priv->ipc_enabled && enable) |
| 3183 | DRM_INFO("Enabling IPC: WM will be proper only after next commit\n"); |
| 3184 | dev_priv->wm.distrust_bios_wm = true; |
| 3185 | dev_priv->ipc_enabled = enable; |
| 3186 | intel_enable_ipc(dev_priv); |
| 3187 | } |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 3188 | |
| 3189 | return len; |
| 3190 | } |
| 3191 | |
| 3192 | static const struct file_operations i915_ipc_status_fops = { |
| 3193 | .owner = THIS_MODULE, |
| 3194 | .open = i915_ipc_status_open, |
| 3195 | .read = seq_read, |
| 3196 | .llseek = seq_lseek, |
| 3197 | .release = single_release, |
| 3198 | .write = i915_ipc_status_write |
| 3199 | }; |
| 3200 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3201 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3202 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3203 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3204 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3205 | struct skl_ddb_entry *entry; |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3206 | struct intel_crtc *crtc; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3207 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3208 | if (INTEL_GEN(dev_priv) < 9) |
Michal Wajdeczko | ab309a6 | 2017-12-15 14:36:35 +0000 | [diff] [blame] | 3209 | return -ENODEV; |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3210 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3211 | drm_modeset_lock_all(dev); |
| 3212 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3213 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3214 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3215 | for_each_intel_crtc(&dev_priv->drm, crtc) { |
| 3216 | struct intel_crtc_state *crtc_state = |
| 3217 | to_intel_crtc_state(crtc->base.state); |
| 3218 | enum pipe pipe = crtc->pipe; |
| 3219 | enum plane_id plane_id; |
| 3220 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3221 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3222 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3223 | for_each_plane_id_on_crtc(crtc, plane_id) { |
| 3224 | entry = &crtc_state->wm.skl.plane_ddb_y[plane_id]; |
| 3225 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane_id + 1, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3226 | entry->start, entry->end, |
| 3227 | skl_ddb_entry_size(entry)); |
| 3228 | } |
| 3229 | |
Ville Syrjälä | ff43bc3 | 2018-11-27 18:59:00 +0200 | [diff] [blame] | 3230 | entry = &crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3231 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3232 | entry->end, skl_ddb_entry_size(entry)); |
| 3233 | } |
| 3234 | |
| 3235 | drm_modeset_unlock_all(dev); |
| 3236 | |
| 3237 | return 0; |
| 3238 | } |
| 3239 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3240 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3241 | struct drm_device *dev, |
| 3242 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3243 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3244 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3245 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3246 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3247 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3248 | struct drm_connector_list_iter conn_iter; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3249 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3250 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3251 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3252 | if (connector->state->crtc != &intel_crtc->base) |
| 3253 | continue; |
| 3254 | |
| 3255 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3256 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3257 | drm_connector_list_iter_end(&conn_iter); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3258 | |
| 3259 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3260 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3261 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3262 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3263 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3264 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3265 | else |
| 3266 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3267 | |
| 3268 | seq_puts(m, "\n\n"); |
| 3269 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3270 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3271 | struct intel_panel *panel; |
| 3272 | |
| 3273 | mutex_lock(&drrs->mutex); |
| 3274 | /* DRRS Supported */ |
| 3275 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3276 | |
| 3277 | /* disable_drrs() will make drrs->dp NULL */ |
| 3278 | if (!drrs->dp) { |
C, Ramalingam | ce6e213 | 2017-11-20 09:53:47 +0530 | [diff] [blame] | 3279 | seq_puts(m, "Idleness DRRS: Disabled\n"); |
| 3280 | if (dev_priv->psr.enabled) |
| 3281 | seq_puts(m, |
| 3282 | "\tAs PSR is enabled, DRRS is not enabled\n"); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3283 | mutex_unlock(&drrs->mutex); |
| 3284 | return; |
| 3285 | } |
| 3286 | |
| 3287 | panel = &drrs->dp->attached_connector->panel; |
| 3288 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3289 | drrs->busy_frontbuffer_bits); |
| 3290 | |
| 3291 | seq_puts(m, "\n\t\t"); |
| 3292 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3293 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3294 | vrefresh = panel->fixed_mode->vrefresh; |
| 3295 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3296 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3297 | vrefresh = panel->downclock_mode->vrefresh; |
| 3298 | } else { |
| 3299 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3300 | drrs->refresh_rate_type); |
| 3301 | mutex_unlock(&drrs->mutex); |
| 3302 | return; |
| 3303 | } |
| 3304 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3305 | |
| 3306 | seq_puts(m, "\n\t\t"); |
| 3307 | mutex_unlock(&drrs->mutex); |
| 3308 | } else { |
| 3309 | /* DRRS not supported. Print the VBT parameter*/ |
| 3310 | seq_puts(m, "\tDRRS Supported : No"); |
| 3311 | } |
| 3312 | seq_puts(m, "\n"); |
| 3313 | } |
| 3314 | |
| 3315 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3316 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3317 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3318 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3319 | struct intel_crtc *intel_crtc; |
| 3320 | int active_crtc_cnt = 0; |
| 3321 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3322 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3323 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3324 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3325 | active_crtc_cnt++; |
| 3326 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3327 | |
| 3328 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3329 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3330 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3331 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3332 | |
| 3333 | if (!active_crtc_cnt) |
| 3334 | seq_puts(m, "No active crtc found\n"); |
| 3335 | |
| 3336 | return 0; |
| 3337 | } |
| 3338 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3339 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3340 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3341 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3342 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3343 | struct intel_encoder *intel_encoder; |
| 3344 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3345 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3346 | struct drm_connector_list_iter conn_iter; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3347 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3348 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3349 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3350 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3351 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3352 | |
| 3353 | intel_encoder = intel_attached_encoder(connector); |
| 3354 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3355 | continue; |
| 3356 | |
| 3357 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3358 | if (!intel_dig_port->dp.can_mst) |
| 3359 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3360 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3361 | seq_printf(m, "MST Source Port %c\n", |
Ville Syrjälä | 8f4f279 | 2017-11-09 17:24:34 +0200 | [diff] [blame] | 3362 | port_name(intel_dig_port->base.port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3363 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3364 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3365 | drm_connector_list_iter_end(&conn_iter); |
| 3366 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3367 | return 0; |
| 3368 | } |
| 3369 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3370 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3371 | const char __user *ubuf, |
| 3372 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3373 | { |
| 3374 | char *input_buffer; |
| 3375 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3376 | struct drm_device *dev; |
| 3377 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3378 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3379 | struct intel_dp *intel_dp; |
| 3380 | int val = 0; |
| 3381 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 3382 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3383 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3384 | if (len == 0) |
| 3385 | return 0; |
| 3386 | |
Geliang Tang | 261aeba | 2017-05-06 23:40:17 +0800 | [diff] [blame] | 3387 | input_buffer = memdup_user_nul(ubuf, len); |
| 3388 | if (IS_ERR(input_buffer)) |
| 3389 | return PTR_ERR(input_buffer); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3390 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3391 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 3392 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3393 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3394 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3395 | struct intel_encoder *encoder; |
| 3396 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3397 | if (connector->connector_type != |
| 3398 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3399 | continue; |
| 3400 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3401 | encoder = to_intel_encoder(connector->encoder); |
| 3402 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3403 | continue; |
| 3404 | |
| 3405 | if (encoder && connector->status == connector_status_connected) { |
| 3406 | intel_dp = enc_to_intel_dp(&encoder->base); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3407 | status = kstrtoint(input_buffer, 10, &val); |
| 3408 | if (status < 0) |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3409 | break; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3410 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 3411 | /* To prevent erroneous activation of the compliance |
| 3412 | * testing code, only accept an actual value of 1 here |
| 3413 | */ |
| 3414 | if (val == 1) |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3415 | intel_dp->compliance.test_active = 1; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3416 | else |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3417 | intel_dp->compliance.test_active = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3418 | } |
| 3419 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3420 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3421 | kfree(input_buffer); |
| 3422 | if (status < 0) |
| 3423 | return status; |
| 3424 | |
| 3425 | *offp += len; |
| 3426 | return len; |
| 3427 | } |
| 3428 | |
| 3429 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 3430 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3431 | struct drm_i915_private *dev_priv = m->private; |
| 3432 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3433 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3434 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3435 | struct intel_dp *intel_dp; |
| 3436 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3437 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3438 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3439 | struct intel_encoder *encoder; |
| 3440 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3441 | if (connector->connector_type != |
| 3442 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3443 | continue; |
| 3444 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3445 | encoder = to_intel_encoder(connector->encoder); |
| 3446 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3447 | continue; |
| 3448 | |
| 3449 | if (encoder && connector->status == connector_status_connected) { |
| 3450 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3451 | if (intel_dp->compliance.test_active) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3452 | seq_puts(m, "1"); |
| 3453 | else |
| 3454 | seq_puts(m, "0"); |
| 3455 | } else |
| 3456 | seq_puts(m, "0"); |
| 3457 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3458 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3459 | |
| 3460 | return 0; |
| 3461 | } |
| 3462 | |
| 3463 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3464 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3465 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3466 | return single_open(file, i915_displayport_test_active_show, |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3467 | inode->i_private); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3468 | } |
| 3469 | |
| 3470 | static const struct file_operations i915_displayport_test_active_fops = { |
| 3471 | .owner = THIS_MODULE, |
| 3472 | .open = i915_displayport_test_active_open, |
| 3473 | .read = seq_read, |
| 3474 | .llseek = seq_lseek, |
| 3475 | .release = single_release, |
| 3476 | .write = i915_displayport_test_active_write |
| 3477 | }; |
| 3478 | |
| 3479 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 3480 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3481 | struct drm_i915_private *dev_priv = m->private; |
| 3482 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3483 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3484 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3485 | struct intel_dp *intel_dp; |
| 3486 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3487 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3488 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3489 | struct intel_encoder *encoder; |
| 3490 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3491 | if (connector->connector_type != |
| 3492 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3493 | continue; |
| 3494 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3495 | encoder = to_intel_encoder(connector->encoder); |
| 3496 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3497 | continue; |
| 3498 | |
| 3499 | if (encoder && connector->status == connector_status_connected) { |
| 3500 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | b48a5ba | 2017-01-20 19:09:28 -0800 | [diff] [blame] | 3501 | if (intel_dp->compliance.test_type == |
| 3502 | DP_TEST_LINK_EDID_READ) |
| 3503 | seq_printf(m, "%lx", |
| 3504 | intel_dp->compliance.test_data.edid); |
Manasi Navare | 611032b | 2017-01-24 08:21:49 -0800 | [diff] [blame] | 3505 | else if (intel_dp->compliance.test_type == |
| 3506 | DP_TEST_LINK_VIDEO_PATTERN) { |
| 3507 | seq_printf(m, "hdisplay: %d\n", |
| 3508 | intel_dp->compliance.test_data.hdisplay); |
| 3509 | seq_printf(m, "vdisplay: %d\n", |
| 3510 | intel_dp->compliance.test_data.vdisplay); |
| 3511 | seq_printf(m, "bpc: %u\n", |
| 3512 | intel_dp->compliance.test_data.bpc); |
| 3513 | } |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3514 | } else |
| 3515 | seq_puts(m, "0"); |
| 3516 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3517 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3518 | |
| 3519 | return 0; |
| 3520 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3521 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3522 | |
| 3523 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 3524 | { |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3525 | struct drm_i915_private *dev_priv = m->private; |
| 3526 | struct drm_device *dev = &dev_priv->drm; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3527 | struct drm_connector *connector; |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3528 | struct drm_connector_list_iter conn_iter; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3529 | struct intel_dp *intel_dp; |
| 3530 | |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3531 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 3532 | drm_for_each_connector_iter(connector, &conn_iter) { |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3533 | struct intel_encoder *encoder; |
| 3534 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3535 | if (connector->connector_type != |
| 3536 | DRM_MODE_CONNECTOR_DisplayPort) |
| 3537 | continue; |
| 3538 | |
Maarten Lankhorst | a874b6a | 2017-06-26 10:18:35 +0200 | [diff] [blame] | 3539 | encoder = to_intel_encoder(connector->encoder); |
| 3540 | if (encoder && encoder->type == INTEL_OUTPUT_DP_MST) |
| 3541 | continue; |
| 3542 | |
| 3543 | if (encoder && connector->status == connector_status_connected) { |
| 3544 | intel_dp = enc_to_intel_dp(&encoder->base); |
Manasi Navare | c1617ab | 2016-12-09 16:22:50 -0800 | [diff] [blame] | 3545 | seq_printf(m, "%02lx", intel_dp->compliance.test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3546 | } else |
| 3547 | seq_puts(m, "0"); |
| 3548 | } |
Daniel Vetter | 3f6a5e1 | 2017-03-01 10:52:21 +0100 | [diff] [blame] | 3549 | drm_connector_list_iter_end(&conn_iter); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3550 | |
| 3551 | return 0; |
| 3552 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 3553 | DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3554 | |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3555 | 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] | 3556 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3557 | struct drm_i915_private *dev_priv = m->private; |
| 3558 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3559 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3560 | int num_levels; |
| 3561 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3562 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3563 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3564 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3565 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3566 | else if (IS_G4X(dev_priv)) |
| 3567 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3568 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3569 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3570 | |
| 3571 | drm_modeset_lock_all(dev); |
| 3572 | |
| 3573 | for (level = 0; level < num_levels; level++) { |
| 3574 | unsigned int latency = wm[level]; |
| 3575 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3576 | /* |
| 3577 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3578 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3579 | */ |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3580 | if (INTEL_GEN(dev_priv) >= 9 || |
| 3581 | IS_VALLEYVIEW(dev_priv) || |
| 3582 | IS_CHERRYVIEW(dev_priv) || |
| 3583 | IS_G4X(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3584 | latency *= 10; |
| 3585 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3586 | latency *= 5; |
| 3587 | |
| 3588 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3589 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3590 | } |
| 3591 | |
| 3592 | drm_modeset_unlock_all(dev); |
| 3593 | } |
| 3594 | |
| 3595 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3596 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3597 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3598 | const u16 *latencies; |
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 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3601 | latencies = dev_priv->wm.skl_latency; |
| 3602 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3603 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3604 | |
| 3605 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3606 | |
| 3607 | return 0; |
| 3608 | } |
| 3609 | |
| 3610 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3611 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3612 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3613 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3614 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3615 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3616 | latencies = dev_priv->wm.skl_latency; |
| 3617 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3618 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3619 | |
| 3620 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3621 | |
| 3622 | return 0; |
| 3623 | } |
| 3624 | |
| 3625 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3626 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3627 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3628 | const u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3629 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3630 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3631 | latencies = dev_priv->wm.skl_latency; |
| 3632 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3633 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3634 | |
| 3635 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3636 | |
| 3637 | return 0; |
| 3638 | } |
| 3639 | |
| 3640 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3641 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3642 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3643 | |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3644 | if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3645 | return -ENODEV; |
| 3646 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3647 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3651 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3652 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3653 | |
Rodrigo Vivi | b2ae318 | 2019-02-04 14:25:38 -0800 | [diff] [blame] | 3654 | if (HAS_GMCH(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3655 | return -ENODEV; |
| 3656 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3657 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3658 | } |
| 3659 | |
| 3660 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3661 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3662 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3663 | |
Rodrigo Vivi | b2ae318 | 2019-02-04 14:25:38 -0800 | [diff] [blame] | 3664 | if (HAS_GMCH(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3665 | return -ENODEV; |
| 3666 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3667 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3668 | } |
| 3669 | |
| 3670 | 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] | 3671 | size_t len, loff_t *offp, u16 wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3672 | { |
| 3673 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3674 | struct drm_i915_private *dev_priv = m->private; |
| 3675 | struct drm_device *dev = &dev_priv->drm; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3676 | u16 new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3677 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3678 | int level; |
| 3679 | int ret; |
| 3680 | char tmp[32]; |
| 3681 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3682 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3683 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3684 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3685 | num_levels = 1; |
Ville Syrjälä | 04548cb | 2017-04-21 21:14:29 +0300 | [diff] [blame] | 3686 | else if (IS_G4X(dev_priv)) |
| 3687 | num_levels = 3; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3688 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 3689 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 3690 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3691 | if (len >= sizeof(tmp)) |
| 3692 | return -EINVAL; |
| 3693 | |
| 3694 | if (copy_from_user(tmp, ubuf, len)) |
| 3695 | return -EFAULT; |
| 3696 | |
| 3697 | tmp[len] = '\0'; |
| 3698 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3699 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 3700 | &new[0], &new[1], &new[2], &new[3], |
| 3701 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3702 | if (ret != num_levels) |
| 3703 | return -EINVAL; |
| 3704 | |
| 3705 | drm_modeset_lock_all(dev); |
| 3706 | |
| 3707 | for (level = 0; level < num_levels; level++) |
| 3708 | wm[level] = new[level]; |
| 3709 | |
| 3710 | drm_modeset_unlock_all(dev); |
| 3711 | |
| 3712 | return len; |
| 3713 | } |
| 3714 | |
| 3715 | |
| 3716 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3717 | size_t len, loff_t *offp) |
| 3718 | { |
| 3719 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3720 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3721 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3722 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3723 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3724 | latencies = dev_priv->wm.skl_latency; |
| 3725 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3726 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3727 | |
| 3728 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3729 | } |
| 3730 | |
| 3731 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3732 | size_t len, loff_t *offp) |
| 3733 | { |
| 3734 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3735 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3736 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3737 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3738 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3739 | latencies = dev_priv->wm.skl_latency; |
| 3740 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3741 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3742 | |
| 3743 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3744 | } |
| 3745 | |
| 3746 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3747 | size_t len, loff_t *offp) |
| 3748 | { |
| 3749 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3750 | struct drm_i915_private *dev_priv = m->private; |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 3751 | u16 *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3752 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3753 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3754 | latencies = dev_priv->wm.skl_latency; |
| 3755 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3756 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 3757 | |
| 3758 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3759 | } |
| 3760 | |
| 3761 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3762 | .owner = THIS_MODULE, |
| 3763 | .open = pri_wm_latency_open, |
| 3764 | .read = seq_read, |
| 3765 | .llseek = seq_lseek, |
| 3766 | .release = single_release, |
| 3767 | .write = pri_wm_latency_write |
| 3768 | }; |
| 3769 | |
| 3770 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3771 | .owner = THIS_MODULE, |
| 3772 | .open = spr_wm_latency_open, |
| 3773 | .read = seq_read, |
| 3774 | .llseek = seq_lseek, |
| 3775 | .release = single_release, |
| 3776 | .write = spr_wm_latency_write |
| 3777 | }; |
| 3778 | |
| 3779 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3780 | .owner = THIS_MODULE, |
| 3781 | .open = cur_wm_latency_open, |
| 3782 | .read = seq_read, |
| 3783 | .llseek = seq_lseek, |
| 3784 | .release = single_release, |
| 3785 | .write = cur_wm_latency_write |
| 3786 | }; |
| 3787 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3788 | static int |
| 3789 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3790 | { |
Chris Wilson | c41166f | 2019-02-20 14:56:37 +0000 | [diff] [blame] | 3791 | int ret = i915_terminally_wedged(data); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3792 | |
Chris Wilson | c41166f | 2019-02-20 14:56:37 +0000 | [diff] [blame] | 3793 | switch (ret) { |
| 3794 | case -EIO: |
| 3795 | *val = 1; |
| 3796 | return 0; |
| 3797 | case 0: |
| 3798 | *val = 0; |
| 3799 | return 0; |
| 3800 | default: |
| 3801 | return ret; |
| 3802 | } |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3803 | } |
| 3804 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3805 | static int |
| 3806 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3807 | { |
Chris Wilson | 598b6b5 | 2017-03-25 13:47:35 +0000 | [diff] [blame] | 3808 | struct drm_i915_private *i915 = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3809 | |
Chris Wilson | 15cbf00 | 2019-02-08 15:37:06 +0000 | [diff] [blame] | 3810 | /* Flush any previous reset before applying for a new one */ |
| 3811 | wait_event(i915->gpu_error.reset_queue, |
| 3812 | !test_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags)); |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 3813 | |
Chris Wilson | ce80075 | 2018-03-20 10:04:49 +0000 | [diff] [blame] | 3814 | i915_handle_error(i915, val, I915_ERROR_CAPTURE, |
| 3815 | "Manually set wedged engine mask = %llx", val); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3816 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3817 | } |
| 3818 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3819 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3820 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3821 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3822 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3823 | #define DROP_UNBOUND BIT(0) |
| 3824 | #define DROP_BOUND BIT(1) |
| 3825 | #define DROP_RETIRE BIT(2) |
| 3826 | #define DROP_ACTIVE BIT(3) |
| 3827 | #define DROP_FREED BIT(4) |
| 3828 | #define DROP_SHRINK_ALL BIT(5) |
| 3829 | #define DROP_IDLE BIT(6) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3830 | #define DROP_RESET_ACTIVE BIT(7) |
| 3831 | #define DROP_RESET_SEQNO BIT(8) |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 3832 | #define DROP_ALL (DROP_UNBOUND | \ |
| 3833 | DROP_BOUND | \ |
| 3834 | DROP_RETIRE | \ |
| 3835 | DROP_ACTIVE | \ |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3836 | DROP_FREED | \ |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3837 | DROP_SHRINK_ALL |\ |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3838 | DROP_IDLE | \ |
| 3839 | DROP_RESET_ACTIVE | \ |
| 3840 | DROP_RESET_SEQNO) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3841 | static int |
| 3842 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3843 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3844 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3845 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3846 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3847 | } |
| 3848 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3849 | static int |
| 3850 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3851 | { |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3852 | struct drm_i915_private *i915 = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3853 | |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3854 | DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n", |
| 3855 | val, val & DROP_ALL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3856 | |
Chris Wilson | ad4062d | 2019-01-28 01:02:18 +0000 | [diff] [blame] | 3857 | if (val & DROP_RESET_ACTIVE && |
| 3858 | wait_for(intel_engines_are_idle(i915), I915_IDLE_ENGINES_TIMEOUT)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3859 | i915_gem_set_wedged(i915); |
| 3860 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3861 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 3862 | * on ioctls on -EAGAIN. */ |
Chris Wilson | ba00016 | 2019-05-07 13:11:05 +0100 | [diff] [blame] | 3863 | if (val & (DROP_ACTIVE | DROP_IDLE | DROP_RETIRE | DROP_RESET_SEQNO)) { |
Chris Wilson | 6cffeb8 | 2019-03-18 09:51:49 +0000 | [diff] [blame] | 3864 | int ret; |
| 3865 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3866 | ret = mutex_lock_interruptible(&i915->drm.struct_mutex); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3867 | if (ret) |
Chris Wilson | 6cffeb8 | 2019-03-18 09:51:49 +0000 | [diff] [blame] | 3868 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3869 | |
Chris Wilson | ba00016 | 2019-05-07 13:11:05 +0100 | [diff] [blame] | 3870 | /* |
| 3871 | * To finish the flush of the idle_worker, we must complete |
| 3872 | * the switch-to-kernel-context, which requires a double |
| 3873 | * pass through wait_for_idle: first queues the switch, |
| 3874 | * second waits for the switch. |
| 3875 | */ |
| 3876 | if (ret == 0 && val & (DROP_IDLE | DROP_ACTIVE)) |
| 3877 | ret = i915_gem_wait_for_idle(i915, |
| 3878 | I915_WAIT_INTERRUPTIBLE | |
| 3879 | I915_WAIT_LOCKED, |
| 3880 | MAX_SCHEDULE_TIMEOUT); |
| 3881 | |
| 3882 | if (ret == 0 && val & DROP_IDLE) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3883 | ret = i915_gem_wait_for_idle(i915, |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3884 | I915_WAIT_INTERRUPTIBLE | |
Chris Wilson | ec625fb | 2018-07-09 13:20:42 +0100 | [diff] [blame] | 3885 | I915_WAIT_LOCKED, |
| 3886 | MAX_SCHEDULE_TIMEOUT); |
Chris Wilson | 00c26cf | 2017-05-24 17:26:53 +0100 | [diff] [blame] | 3887 | |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3888 | if (val & DROP_RETIRE) |
| 3889 | i915_retire_requests(i915); |
| 3890 | |
| 3891 | mutex_unlock(&i915->drm.struct_mutex); |
| 3892 | } |
| 3893 | |
Chris Wilson | c41166f | 2019-02-20 14:56:37 +0000 | [diff] [blame] | 3894 | if (val & DROP_RESET_ACTIVE && i915_terminally_wedged(i915)) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3895 | i915_handle_error(i915, ALL_ENGINES, 0, NULL); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3896 | |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 3897 | fs_reclaim_acquire(GFP_KERNEL); |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3898 | if (val & DROP_BOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3899 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 3900 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 3901 | if (val & DROP_UNBOUND) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3902 | i915_gem_shrink(i915, LONG_MAX, NULL, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3903 | |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3904 | if (val & DROP_SHRINK_ALL) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3905 | i915_gem_shrink_all(i915); |
Peter Zijlstra | d92a8cf | 2017-03-03 10:13:38 +0100 | [diff] [blame] | 3906 | fs_reclaim_release(GFP_KERNEL); |
Chris Wilson | 8eadc19 | 2017-03-08 14:46:22 +0000 | [diff] [blame] | 3907 | |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 3908 | if (val & DROP_IDLE) { |
Chris Wilson | 3970564 | 2019-05-07 13:11:08 +0100 | [diff] [blame] | 3909 | flush_delayed_work(&i915->gem.retire_work); |
Chris Wilson | ae23063 | 2019-05-07 13:11:06 +0100 | [diff] [blame] | 3910 | flush_work(&i915->gem.idle_work); |
Chris Wilson | 4dfacb0 | 2018-05-31 09:22:43 +0100 | [diff] [blame] | 3911 | } |
Chris Wilson | b4a0b32 | 2017-10-18 13:16:21 +0100 | [diff] [blame] | 3912 | |
Chris Wilson | c9c70471 | 2018-02-19 22:06:31 +0000 | [diff] [blame] | 3913 | if (val & DROP_FREED) |
Chris Wilson | 6b04870 | 2018-09-03 09:33:37 +0100 | [diff] [blame] | 3914 | i915_gem_drain_freed_objects(i915); |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 3915 | |
Chris Wilson | 6cffeb8 | 2019-03-18 09:51:49 +0000 | [diff] [blame] | 3916 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3917 | } |
| 3918 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3919 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 3920 | i915_drop_caches_get, i915_drop_caches_set, |
| 3921 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3922 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3923 | static int |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3924 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3925 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3926 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3927 | intel_wakeref_t wakeref; |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3928 | u32 snpcr = 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3929 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 3930 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3931 | return -ENODEV; |
| 3932 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3933 | with_intel_runtime_pm(dev_priv, wakeref) |
| 3934 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3935 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3936 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3937 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3938 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3939 | } |
| 3940 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3941 | static int |
| 3942 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3943 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3944 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 3945 | intel_wakeref_t wakeref; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3946 | |
Lucas De Marchi | f3ce44a | 2018-12-12 10:10:44 -0800 | [diff] [blame] | 3947 | if (!(IS_GEN_RANGE(dev_priv, 6, 7))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3948 | return -ENODEV; |
| 3949 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3950 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3951 | return -EINVAL; |
| 3952 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3953 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3954 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 3955 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3956 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 3957 | /* Update the cache sharing policy here as well */ |
| 3958 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 3959 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 3960 | snpcr |= val << GEN6_MBC_SNPCR_SHIFT; |
| 3961 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 3962 | } |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3963 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3964 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3965 | } |
| 3966 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3967 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 3968 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 3969 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3970 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3971 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 3972 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 3973 | { |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 3974 | #define SS_MAX 2 |
| 3975 | const int ss_max = SS_MAX; |
| 3976 | u32 sig1[SS_MAX], sig2[SS_MAX]; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 3977 | int ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 3978 | |
| 3979 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 3980 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 3981 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 3982 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 3983 | |
| 3984 | for (ss = 0; ss < ss_max; ss++) { |
| 3985 | unsigned int eu_cnt; |
| 3986 | |
| 3987 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 3988 | /* skip disabled subslice */ |
| 3989 | continue; |
| 3990 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 3991 | sseu->slice_mask = BIT(0); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 3992 | sseu->subslice_mask[0] |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 3993 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 3994 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 3995 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 3996 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 3997 | sseu->eu_total += eu_cnt; |
| 3998 | sseu->eu_per_subslice = max_t(unsigned int, |
| 3999 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4000 | } |
Chris Wilson | 7aa0b14 | 2018-03-13 00:40:54 +0000 | [diff] [blame] | 4001 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4002 | } |
| 4003 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4004 | static void gen10_sseu_device_status(struct drm_i915_private *dev_priv, |
| 4005 | struct sseu_dev_info *sseu) |
| 4006 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4007 | #define SS_MAX 6 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4008 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4009 | 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] | 4010 | int s, ss; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4011 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4012 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4013 | /* |
| 4014 | * FIXME: Valid SS Mask respects the spec and read |
Alexandre Belloni | 3c64ea8 | 2018-11-20 16:14:15 +0100 | [diff] [blame] | 4015 | * only valid bits for those registers, excluding reserved |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4016 | * although this seems wrong because it would leave many |
| 4017 | * subslices without ACK. |
| 4018 | */ |
| 4019 | s_reg[s] = I915_READ(GEN10_SLICE_PGCTL_ACK(s)) & |
| 4020 | GEN10_PGCTL_VALID_SS_MASK(s); |
| 4021 | eu_reg[2 * s] = I915_READ(GEN10_SS01_EU_PGCTL_ACK(s)); |
| 4022 | eu_reg[2 * s + 1] = I915_READ(GEN10_SS23_EU_PGCTL_ACK(s)); |
| 4023 | } |
| 4024 | |
| 4025 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4026 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4027 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4028 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4029 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4030 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4031 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4032 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4033 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4034 | for (s = 0; s < info->sseu.max_slices; s++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4035 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4036 | /* skip disabled slice */ |
| 4037 | continue; |
| 4038 | |
| 4039 | sseu->slice_mask |= BIT(s); |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4040 | sseu->subslice_mask[s] = info->sseu.subslice_mask[s]; |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4041 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4042 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4043 | unsigned int eu_cnt; |
| 4044 | |
| 4045 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4046 | /* skip disabled subslice */ |
| 4047 | continue; |
| 4048 | |
| 4049 | eu_cnt = 2 * hweight32(eu_reg[2 * s + ss / 2] & |
| 4050 | eu_mask[ss % 2]); |
| 4051 | sseu->eu_total += eu_cnt; |
| 4052 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4053 | sseu->eu_per_subslice, |
| 4054 | eu_cnt); |
| 4055 | } |
| 4056 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4057 | #undef SS_MAX |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4058 | } |
| 4059 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4060 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4061 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4062 | { |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4063 | #define SS_MAX 3 |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 4064 | const struct intel_runtime_info *info = RUNTIME_INFO(dev_priv); |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4065 | 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] | 4066 | int s, ss; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4067 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4068 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4069 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4070 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4071 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4072 | } |
| 4073 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4074 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4075 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4076 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4077 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4078 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4079 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4080 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4081 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4082 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4083 | for (s = 0; s < info->sseu.max_slices; s++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4084 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4085 | /* skip disabled slice */ |
| 4086 | continue; |
| 4087 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4088 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4089 | |
Rodrigo Vivi | f8c3dcf | 2017-10-25 17:15:46 -0700 | [diff] [blame] | 4090 | if (IS_GEN9_BC(dev_priv)) |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4091 | sseu->subslice_mask[s] = |
| 4092 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4093 | |
Lionel Landwerlin | b3e7f86 | 2018-03-06 12:28:53 +0000 | [diff] [blame] | 4094 | for (ss = 0; ss < info->sseu.max_subslices; ss++) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4095 | unsigned int eu_cnt; |
| 4096 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 4097 | if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4098 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4099 | /* skip disabled subslice */ |
| 4100 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4101 | |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4102 | sseu->subslice_mask[s] |= BIT(ss); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4103 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4104 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4105 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4106 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4107 | sseu->eu_total += eu_cnt; |
| 4108 | sseu->eu_per_subslice = max_t(unsigned int, |
| 4109 | sseu->eu_per_subslice, |
| 4110 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4111 | } |
| 4112 | } |
Chris Wilson | c7fb3c6 | 2018-03-13 11:31:49 +0000 | [diff] [blame] | 4113 | #undef SS_MAX |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4114 | } |
| 4115 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4116 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4117 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4118 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4119 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4120 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4121 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4122 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4123 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4124 | if (sseu->slice_mask) { |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4125 | sseu->eu_per_subslice = |
| 4126 | RUNTIME_INFO(dev_priv)->sseu.eu_per_subslice; |
| 4127 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4128 | sseu->subslice_mask[s] = |
| 4129 | RUNTIME_INFO(dev_priv)->sseu.subslice_mask[s]; |
| 4130 | } |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 4131 | sseu->eu_total = sseu->eu_per_subslice * |
Stuart Summers | 0040fd1 | 2019-05-24 08:40:21 -0700 | [diff] [blame] | 4132 | intel_sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4133 | |
| 4134 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 4135 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4136 | u8 subslice_7eu = |
| 4137 | RUNTIME_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4138 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4139 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 4140 | } |
| 4141 | } |
| 4142 | } |
| 4143 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4144 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 4145 | const struct sseu_dev_info *sseu) |
| 4146 | { |
| 4147 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 4148 | const char *type = is_available_info ? "Available" : "Enabled"; |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4149 | int s; |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4150 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 4151 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 4152 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4153 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 4154 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4155 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Stuart Summers | 0040fd1 | 2019-05-24 08:40:21 -0700 | [diff] [blame] | 4156 | intel_sseu_subslice_total(sseu)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4157 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
| 4158 | seq_printf(m, " %s Slice%i subslices: %u\n", type, |
Stuart Summers | b5ab1ab | 2019-05-24 08:40:20 -0700 | [diff] [blame] | 4159 | s, intel_sseu_subslices_per_slice(sseu, s)); |
Lionel Landwerlin | 8cc7669 | 2018-03-06 12:28:52 +0000 | [diff] [blame] | 4160 | } |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4161 | seq_printf(m, " %s EU Total: %u\n", type, |
| 4162 | sseu->eu_total); |
| 4163 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 4164 | sseu->eu_per_subslice); |
| 4165 | |
| 4166 | if (!is_available_info) |
| 4167 | return; |
| 4168 | |
| 4169 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 4170 | if (HAS_POOLED_EU(dev_priv)) |
| 4171 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 4172 | |
| 4173 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4174 | yesno(sseu->has_slice_pg)); |
| 4175 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4176 | yesno(sseu->has_subslice_pg)); |
| 4177 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4178 | yesno(sseu->has_eu_pg)); |
| 4179 | } |
| 4180 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4181 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4182 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4183 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4184 | struct sseu_dev_info sseu; |
Chris Wilson | a037121 | 2019-01-14 14:21:14 +0000 | [diff] [blame] | 4185 | intel_wakeref_t wakeref; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4186 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4187 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4188 | return -ENODEV; |
| 4189 | |
| 4190 | seq_puts(m, "SSEU Device Info\n"); |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4191 | i915_print_sseu_info(m, true, &RUNTIME_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4192 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4193 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 4194 | memset(&sseu, 0, sizeof(sseu)); |
Jani Nikula | a10f361 | 2019-05-29 11:21:50 +0300 | [diff] [blame] | 4195 | sseu.max_slices = RUNTIME_INFO(dev_priv)->sseu.max_slices; |
| 4196 | sseu.max_subslices = RUNTIME_INFO(dev_priv)->sseu.max_subslices; |
| 4197 | sseu.max_eus_per_subslice = |
| 4198 | RUNTIME_INFO(dev_priv)->sseu.max_eus_per_subslice; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4199 | |
Chris Wilson | d4225a5 | 2019-01-14 14:21:23 +0000 | [diff] [blame] | 4200 | with_intel_runtime_pm(dev_priv, wakeref) { |
| 4201 | if (IS_CHERRYVIEW(dev_priv)) |
| 4202 | cherryview_sseu_device_status(dev_priv, &sseu); |
| 4203 | else if (IS_BROADWELL(dev_priv)) |
| 4204 | broadwell_sseu_device_status(dev_priv, &sseu); |
| 4205 | else if (IS_GEN(dev_priv, 9)) |
| 4206 | gen9_sseu_device_status(dev_priv, &sseu); |
| 4207 | else if (INTEL_GEN(dev_priv) >= 10) |
| 4208 | gen10_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4209 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 4210 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 4211 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4212 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4213 | return 0; |
| 4214 | } |
| 4215 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4216 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4217 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4218 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4219 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4220 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4221 | return 0; |
| 4222 | |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4223 | file->private_data = (void *)(uintptr_t)intel_runtime_pm_get(i915); |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 4224 | intel_uncore_forcewake_user_get(&i915->uncore); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4225 | |
| 4226 | return 0; |
| 4227 | } |
| 4228 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4229 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4230 | { |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4231 | struct drm_i915_private *i915 = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4232 | |
Chris Wilson | d7a133d | 2017-09-07 14:44:41 +0100 | [diff] [blame] | 4233 | if (INTEL_GEN(i915) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4234 | return 0; |
| 4235 | |
Daniele Ceraolo Spurio | 3ceea6a | 2019-03-19 11:35:36 -0700 | [diff] [blame] | 4236 | intel_uncore_forcewake_user_put(&i915->uncore); |
Tvrtko Ursulin | 6ddbb12e | 2019-01-17 14:48:31 +0000 | [diff] [blame] | 4237 | intel_runtime_pm_put(i915, |
| 4238 | (intel_wakeref_t)(uintptr_t)file->private_data); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4239 | |
| 4240 | return 0; |
| 4241 | } |
| 4242 | |
| 4243 | static const struct file_operations i915_forcewake_fops = { |
| 4244 | .owner = THIS_MODULE, |
| 4245 | .open = i915_forcewake_open, |
| 4246 | .release = i915_forcewake_release, |
| 4247 | }; |
| 4248 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4249 | static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) |
| 4250 | { |
| 4251 | struct drm_i915_private *dev_priv = m->private; |
| 4252 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4253 | |
Lyude Paul | 6fc5d78 | 2018-11-20 19:37:17 -0500 | [diff] [blame] | 4254 | /* Synchronize with everything first in case there's been an HPD |
| 4255 | * storm, but we haven't finished handling it in the kernel yet |
| 4256 | */ |
| 4257 | synchronize_irq(dev_priv->drm.irq); |
| 4258 | flush_work(&dev_priv->hotplug.dig_port_work); |
| 4259 | flush_work(&dev_priv->hotplug.hotplug_work); |
| 4260 | |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 4261 | seq_printf(m, "Threshold: %d\n", hotplug->hpd_storm_threshold); |
| 4262 | seq_printf(m, "Detected: %s\n", |
| 4263 | yesno(delayed_work_pending(&hotplug->reenable_work))); |
| 4264 | |
| 4265 | return 0; |
| 4266 | } |
| 4267 | |
| 4268 | static ssize_t i915_hpd_storm_ctl_write(struct file *file, |
| 4269 | const char __user *ubuf, size_t len, |
| 4270 | loff_t *offp) |
| 4271 | { |
| 4272 | struct seq_file *m = file->private_data; |
| 4273 | struct drm_i915_private *dev_priv = m->private; |
| 4274 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4275 | unsigned int new_threshold; |
| 4276 | int i; |
| 4277 | char *newline; |
| 4278 | char tmp[16]; |
| 4279 | |
| 4280 | if (len >= sizeof(tmp)) |
| 4281 | return -EINVAL; |
| 4282 | |
| 4283 | if (copy_from_user(tmp, ubuf, len)) |
| 4284 | return -EFAULT; |
| 4285 | |
| 4286 | tmp[len] = '\0'; |
| 4287 | |
| 4288 | /* Strip newline, if any */ |
| 4289 | newline = strchr(tmp, '\n'); |
| 4290 | if (newline) |
| 4291 | *newline = '\0'; |
| 4292 | |
| 4293 | if (strcmp(tmp, "reset") == 0) |
| 4294 | new_threshold = HPD_STORM_DEFAULT_THRESHOLD; |
| 4295 | else if (kstrtouint(tmp, 10, &new_threshold) != 0) |
| 4296 | return -EINVAL; |
| 4297 | |
| 4298 | if (new_threshold > 0) |
| 4299 | DRM_DEBUG_KMS("Setting HPD storm detection threshold to %d\n", |
| 4300 | new_threshold); |
| 4301 | else |
| 4302 | DRM_DEBUG_KMS("Disabling HPD storm detection\n"); |
| 4303 | |
| 4304 | spin_lock_irq(&dev_priv->irq_lock); |
| 4305 | hotplug->hpd_storm_threshold = new_threshold; |
| 4306 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4307 | for_each_hpd_pin(i) |
| 4308 | hotplug->stats[i].count = 0; |
| 4309 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4310 | |
| 4311 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4312 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4313 | |
| 4314 | return len; |
| 4315 | } |
| 4316 | |
| 4317 | static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) |
| 4318 | { |
| 4319 | return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); |
| 4320 | } |
| 4321 | |
| 4322 | static const struct file_operations i915_hpd_storm_ctl_fops = { |
| 4323 | .owner = THIS_MODULE, |
| 4324 | .open = i915_hpd_storm_ctl_open, |
| 4325 | .read = seq_read, |
| 4326 | .llseek = seq_lseek, |
| 4327 | .release = single_release, |
| 4328 | .write = i915_hpd_storm_ctl_write |
| 4329 | }; |
| 4330 | |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4331 | static int i915_hpd_short_storm_ctl_show(struct seq_file *m, void *data) |
| 4332 | { |
| 4333 | struct drm_i915_private *dev_priv = m->private; |
| 4334 | |
| 4335 | seq_printf(m, "Enabled: %s\n", |
| 4336 | yesno(dev_priv->hotplug.hpd_short_storm_enabled)); |
| 4337 | |
| 4338 | return 0; |
| 4339 | } |
| 4340 | |
| 4341 | static int |
| 4342 | i915_hpd_short_storm_ctl_open(struct inode *inode, struct file *file) |
| 4343 | { |
| 4344 | return single_open(file, i915_hpd_short_storm_ctl_show, |
| 4345 | inode->i_private); |
| 4346 | } |
| 4347 | |
| 4348 | static ssize_t i915_hpd_short_storm_ctl_write(struct file *file, |
| 4349 | const char __user *ubuf, |
| 4350 | size_t len, loff_t *offp) |
| 4351 | { |
| 4352 | struct seq_file *m = file->private_data; |
| 4353 | struct drm_i915_private *dev_priv = m->private; |
| 4354 | struct i915_hotplug *hotplug = &dev_priv->hotplug; |
| 4355 | char *newline; |
| 4356 | char tmp[16]; |
| 4357 | int i; |
| 4358 | bool new_state; |
| 4359 | |
| 4360 | if (len >= sizeof(tmp)) |
| 4361 | return -EINVAL; |
| 4362 | |
| 4363 | if (copy_from_user(tmp, ubuf, len)) |
| 4364 | return -EFAULT; |
| 4365 | |
| 4366 | tmp[len] = '\0'; |
| 4367 | |
| 4368 | /* Strip newline, if any */ |
| 4369 | newline = strchr(tmp, '\n'); |
| 4370 | if (newline) |
| 4371 | *newline = '\0'; |
| 4372 | |
| 4373 | /* Reset to the "default" state for this system */ |
| 4374 | if (strcmp(tmp, "reset") == 0) |
| 4375 | new_state = !HAS_DP_MST(dev_priv); |
| 4376 | else if (kstrtobool(tmp, &new_state) != 0) |
| 4377 | return -EINVAL; |
| 4378 | |
| 4379 | DRM_DEBUG_KMS("%sabling HPD short storm detection\n", |
| 4380 | new_state ? "En" : "Dis"); |
| 4381 | |
| 4382 | spin_lock_irq(&dev_priv->irq_lock); |
| 4383 | hotplug->hpd_short_storm_enabled = new_state; |
| 4384 | /* Reset the HPD storm stats so we don't accidentally trigger a storm */ |
| 4385 | for_each_hpd_pin(i) |
| 4386 | hotplug->stats[i].count = 0; |
| 4387 | spin_unlock_irq(&dev_priv->irq_lock); |
| 4388 | |
| 4389 | /* Re-enable hpd immediately if we were in an irq storm */ |
| 4390 | flush_delayed_work(&dev_priv->hotplug.reenable_work); |
| 4391 | |
| 4392 | return len; |
| 4393 | } |
| 4394 | |
| 4395 | static const struct file_operations i915_hpd_short_storm_ctl_fops = { |
| 4396 | .owner = THIS_MODULE, |
| 4397 | .open = i915_hpd_short_storm_ctl_open, |
| 4398 | .read = seq_read, |
| 4399 | .llseek = seq_lseek, |
| 4400 | .release = single_release, |
| 4401 | .write = i915_hpd_short_storm_ctl_write, |
| 4402 | }; |
| 4403 | |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4404 | static int i915_drrs_ctl_set(void *data, u64 val) |
| 4405 | { |
| 4406 | struct drm_i915_private *dev_priv = data; |
| 4407 | struct drm_device *dev = &dev_priv->drm; |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4408 | struct intel_crtc *crtc; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4409 | |
| 4410 | if (INTEL_GEN(dev_priv) < 7) |
| 4411 | return -ENODEV; |
| 4412 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4413 | for_each_intel_crtc(dev, crtc) { |
| 4414 | struct drm_connector_list_iter conn_iter; |
| 4415 | struct intel_crtc_state *crtc_state; |
| 4416 | struct drm_connector *connector; |
| 4417 | struct drm_crtc_commit *commit; |
| 4418 | int ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4419 | |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4420 | ret = drm_modeset_lock_single_interruptible(&crtc->base.mutex); |
| 4421 | if (ret) |
| 4422 | return ret; |
| 4423 | |
| 4424 | crtc_state = to_intel_crtc_state(crtc->base.state); |
| 4425 | |
| 4426 | if (!crtc_state->base.active || |
| 4427 | !crtc_state->has_drrs) |
| 4428 | goto out; |
| 4429 | |
| 4430 | commit = crtc_state->base.commit; |
| 4431 | if (commit) { |
| 4432 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4433 | if (ret) |
| 4434 | goto out; |
| 4435 | } |
| 4436 | |
| 4437 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 4438 | drm_for_each_connector_iter(connector, &conn_iter) { |
| 4439 | struct intel_encoder *encoder; |
| 4440 | struct intel_dp *intel_dp; |
| 4441 | |
| 4442 | if (!(crtc_state->base.connector_mask & |
| 4443 | drm_connector_mask(connector))) |
| 4444 | continue; |
| 4445 | |
| 4446 | encoder = intel_attached_encoder(connector); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4447 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 4448 | continue; |
| 4449 | |
| 4450 | DRM_DEBUG_DRIVER("Manually %sabling DRRS. %llu\n", |
| 4451 | val ? "en" : "dis", val); |
| 4452 | |
| 4453 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 4454 | if (val) |
| 4455 | intel_edp_drrs_enable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4456 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4457 | else |
| 4458 | intel_edp_drrs_disable(intel_dp, |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4459 | crtc_state); |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4460 | } |
Maarten Lankhorst | 138bdac | 2018-10-11 12:04:48 +0200 | [diff] [blame] | 4461 | drm_connector_list_iter_end(&conn_iter); |
| 4462 | |
| 4463 | out: |
| 4464 | drm_modeset_unlock(&crtc->base.mutex); |
| 4465 | if (ret) |
| 4466 | return ret; |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4467 | } |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4468 | |
| 4469 | return 0; |
| 4470 | } |
| 4471 | |
| 4472 | DEFINE_SIMPLE_ATTRIBUTE(i915_drrs_ctl_fops, NULL, i915_drrs_ctl_set, "%llu\n"); |
| 4473 | |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4474 | static ssize_t |
| 4475 | i915_fifo_underrun_reset_write(struct file *filp, |
| 4476 | const char __user *ubuf, |
| 4477 | size_t cnt, loff_t *ppos) |
| 4478 | { |
| 4479 | struct drm_i915_private *dev_priv = filp->private_data; |
| 4480 | struct intel_crtc *intel_crtc; |
| 4481 | struct drm_device *dev = &dev_priv->drm; |
| 4482 | int ret; |
| 4483 | bool reset; |
| 4484 | |
| 4485 | ret = kstrtobool_from_user(ubuf, cnt, &reset); |
| 4486 | if (ret) |
| 4487 | return ret; |
| 4488 | |
| 4489 | if (!reset) |
| 4490 | return cnt; |
| 4491 | |
| 4492 | for_each_intel_crtc(dev, intel_crtc) { |
| 4493 | struct drm_crtc_commit *commit; |
| 4494 | struct intel_crtc_state *crtc_state; |
| 4495 | |
| 4496 | ret = drm_modeset_lock_single_interruptible(&intel_crtc->base.mutex); |
| 4497 | if (ret) |
| 4498 | return ret; |
| 4499 | |
| 4500 | crtc_state = to_intel_crtc_state(intel_crtc->base.state); |
| 4501 | commit = crtc_state->base.commit; |
| 4502 | if (commit) { |
| 4503 | ret = wait_for_completion_interruptible(&commit->hw_done); |
| 4504 | if (!ret) |
| 4505 | ret = wait_for_completion_interruptible(&commit->flip_done); |
| 4506 | } |
| 4507 | |
| 4508 | if (!ret && crtc_state->base.active) { |
| 4509 | DRM_DEBUG_KMS("Re-arming FIFO underruns on pipe %c\n", |
| 4510 | pipe_name(intel_crtc->pipe)); |
| 4511 | |
| 4512 | intel_crtc_arm_fifo_underrun(intel_crtc, crtc_state); |
| 4513 | } |
| 4514 | |
| 4515 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 4516 | |
| 4517 | if (ret) |
| 4518 | return ret; |
| 4519 | } |
| 4520 | |
| 4521 | ret = intel_fbc_reset_underrun(dev_priv); |
| 4522 | if (ret) |
| 4523 | return ret; |
| 4524 | |
| 4525 | return cnt; |
| 4526 | } |
| 4527 | |
| 4528 | static const struct file_operations i915_fifo_underrun_reset_ops = { |
| 4529 | .owner = THIS_MODULE, |
| 4530 | .open = simple_open, |
| 4531 | .write = i915_fifo_underrun_reset_write, |
| 4532 | .llseek = default_llseek, |
| 4533 | }; |
| 4534 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4535 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4536 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4537 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4538 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4539 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4540 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 4541 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 4542 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 4543 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 4544 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 4545 | {"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] | 4546 | {"i915_guc_stage_pool", i915_guc_stage_pool, 0}, |
Anusha Srivatsa | 0509ead | 2017-01-18 08:05:56 -0800 | [diff] [blame] | 4547 | {"i915_huc_load_status", i915_huc_load_status_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4548 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 4549 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Michel Thierry | 061d06a | 2017-06-20 10:57:49 +0100 | [diff] [blame] | 4550 | {"i915_reset_info", i915_reset_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4551 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4552 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4553 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 4554 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4555 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4556 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4557 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4558 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 4559 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4560 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4561 | {"i915_context_status", i915_context_status, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 4562 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4563 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4564 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4565 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4566 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 4567 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4568 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 4569 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4570 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 4571 | {"i915_engine_info", i915_engine_info, 0}, |
Lionel Landwerlin | 79e9cd5 | 2018-03-06 12:28:54 +0000 | [diff] [blame] | 4572 | {"i915_rcs_topology", i915_rcs_topology, 0}, |
Chris Wilson | c5418a8 | 2017-10-13 21:26:19 +0100 | [diff] [blame] | 4573 | {"i915_shrinker_info", i915_shrinker_info, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4574 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4575 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 4576 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 4577 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4578 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 4579 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 4580 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4581 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4582 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4583 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4584 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4585 | const char *name; |
| 4586 | const struct file_operations *fops; |
| 4587 | } i915_debugfs_files[] = { |
| 4588 | {"i915_wedged", &i915_wedged_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4589 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4590 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4591 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4592 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 5a4c6f1 | 2017-02-14 16:46:11 +0000 | [diff] [blame] | 4593 | {"i915_gpu_info", &i915_gpu_info_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 4594 | #endif |
Maarten Lankhorst | d52ad9c | 2018-03-28 12:05:26 +0200 | [diff] [blame] | 4595 | {"i915_fifo_underrun_reset", &i915_fifo_underrun_reset_ops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4596 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4597 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4598 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Ville Syrjälä | 4127dc4 | 2017-06-06 15:44:12 +0300 | [diff] [blame] | 4599 | {"i915_fbc_false_color", &i915_fbc_false_color_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4600 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 4601 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 4602 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
Michał Winiarski | 4977a28 | 2018-03-19 10:53:40 +0100 | [diff] [blame] | 4603 | {"i915_guc_log_level", &i915_guc_log_level_fops}, |
| 4604 | {"i915_guc_log_relay", &i915_guc_log_relay_fops}, |
Kumar, Mahesh | d2d4f39 | 2017-08-17 19:15:29 +0530 | [diff] [blame] | 4605 | {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops}, |
Lyude Paul | 9a64c65 | 2018-11-06 16:30:16 -0500 | [diff] [blame] | 4606 | {"i915_hpd_short_storm_ctl", &i915_hpd_short_storm_ctl_fops}, |
C, Ramalingam | 35954e8 | 2017-11-08 00:08:23 +0530 | [diff] [blame] | 4607 | {"i915_ipc_status", &i915_ipc_status_fops}, |
Dhinakaran Pandiyan | 54fd314 | 2018-04-04 18:37:17 -0700 | [diff] [blame] | 4608 | {"i915_drrs_ctl", &i915_drrs_ctl_fops}, |
| 4609 | {"i915_edp_psr_debug", &i915_edp_psr_debug_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4610 | }; |
| 4611 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 4612 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4613 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 4614 | struct drm_minor *minor = dev_priv->drm.primary; |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4615 | struct dentry *ent; |
Maarten Lankhorst | 6cc4215 | 2018-06-28 09:23:02 +0200 | [diff] [blame] | 4616 | int i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4617 | |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4618 | ent = debugfs_create_file("i915_forcewake_user", S_IRUSR, |
| 4619 | minor->debugfs_root, to_i915(minor->dev), |
| 4620 | &i915_forcewake_fops); |
| 4621 | if (!ent) |
| 4622 | return -ENOMEM; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4623 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4624 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4625 | ent = debugfs_create_file(i915_debugfs_files[i].name, |
| 4626 | S_IRUGO | S_IWUSR, |
| 4627 | minor->debugfs_root, |
| 4628 | to_i915(minor->dev), |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4629 | i915_debugfs_files[i].fops); |
Noralf Trønnes | b05eeb0 | 2017-01-26 23:56:21 +0100 | [diff] [blame] | 4630 | if (!ent) |
| 4631 | return -ENOMEM; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4632 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4633 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4634 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4635 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4636 | minor->debugfs_root, minor); |
| 4637 | } |
| 4638 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4639 | struct dpcd_block { |
| 4640 | /* DPCD dump start address. */ |
| 4641 | unsigned int offset; |
| 4642 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 4643 | unsigned int end; |
| 4644 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 4645 | size_t size; |
| 4646 | /* Only valid for eDP. */ |
| 4647 | bool edp; |
| 4648 | }; |
| 4649 | |
| 4650 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 4651 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 4652 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 4653 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 4654 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 4655 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 4656 | { .offset = DP_SET_POWER }, |
| 4657 | { .offset = DP_EDP_DPCD_REV }, |
| 4658 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 4659 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 4660 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 4661 | }; |
| 4662 | |
| 4663 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 4664 | { |
| 4665 | struct drm_connector *connector = m->private; |
| 4666 | struct intel_dp *intel_dp = |
| 4667 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
Jani Nikula | e531521 | 2019-01-16 11:15:23 +0200 | [diff] [blame] | 4668 | u8 buf[16]; |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4669 | ssize_t err; |
| 4670 | int i; |
| 4671 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 4672 | if (connector->status != connector_status_connected) |
| 4673 | return -ENODEV; |
| 4674 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4675 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 4676 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 4677 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 4678 | |
| 4679 | if (b->edp && |
| 4680 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 4681 | continue; |
| 4682 | |
| 4683 | /* low tech for now */ |
| 4684 | if (WARN_ON(size > sizeof(buf))) |
| 4685 | continue; |
| 4686 | |
| 4687 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
Chris Wilson | 65404c8 | 2018-10-10 09:17:06 +0100 | [diff] [blame] | 4688 | if (err < 0) |
| 4689 | seq_printf(m, "%04x: ERROR %d\n", b->offset, (int)err); |
| 4690 | else |
| 4691 | seq_printf(m, "%04x: %*ph\n", b->offset, (int)err, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 4692 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4693 | |
| 4694 | return 0; |
| 4695 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4696 | DEFINE_SHOW_ATTRIBUTE(i915_dpcd); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4697 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4698 | static int i915_panel_show(struct seq_file *m, void *data) |
| 4699 | { |
| 4700 | struct drm_connector *connector = m->private; |
| 4701 | struct intel_dp *intel_dp = |
| 4702 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4703 | |
| 4704 | if (connector->status != connector_status_connected) |
| 4705 | return -ENODEV; |
| 4706 | |
| 4707 | seq_printf(m, "Panel power up delay: %d\n", |
| 4708 | intel_dp->panel_power_up_delay); |
| 4709 | seq_printf(m, "Panel power down delay: %d\n", |
| 4710 | intel_dp->panel_power_down_delay); |
| 4711 | seq_printf(m, "Backlight on delay: %d\n", |
| 4712 | intel_dp->backlight_on_delay); |
| 4713 | seq_printf(m, "Backlight off delay: %d\n", |
| 4714 | intel_dp->backlight_off_delay); |
| 4715 | |
| 4716 | return 0; |
| 4717 | } |
Andy Shevchenko | e400671 | 2018-03-16 16:12:13 +0200 | [diff] [blame] | 4718 | DEFINE_SHOW_ATTRIBUTE(i915_panel); |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4719 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4720 | static int i915_hdcp_sink_capability_show(struct seq_file *m, void *data) |
| 4721 | { |
| 4722 | struct drm_connector *connector = m->private; |
| 4723 | struct intel_connector *intel_connector = to_intel_connector(connector); |
Ramalingam C | 43318c0 | 2019-05-07 21:57:36 +0530 | [diff] [blame] | 4724 | bool hdcp_cap, hdcp2_cap; |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4725 | |
| 4726 | if (connector->status != connector_status_connected) |
| 4727 | return -ENODEV; |
| 4728 | |
| 4729 | /* HDCP is supported by connector */ |
Ramalingam C | d3dacc7 | 2018-10-29 15:15:46 +0530 | [diff] [blame] | 4730 | if (!intel_connector->hdcp.shim) |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4731 | return -EINVAL; |
| 4732 | |
| 4733 | seq_printf(m, "%s:%d HDCP version: ", connector->name, |
| 4734 | connector->base.id); |
Ramalingam C | 43318c0 | 2019-05-07 21:57:36 +0530 | [diff] [blame] | 4735 | hdcp_cap = intel_hdcp_capable(intel_connector); |
| 4736 | hdcp2_cap = intel_hdcp2_capable(intel_connector); |
| 4737 | |
| 4738 | if (hdcp_cap) |
| 4739 | seq_puts(m, "HDCP1.4 "); |
| 4740 | if (hdcp2_cap) |
| 4741 | seq_puts(m, "HDCP2.2 "); |
| 4742 | |
| 4743 | if (!hdcp_cap && !hdcp2_cap) |
| 4744 | seq_puts(m, "None"); |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4745 | seq_puts(m, "\n"); |
| 4746 | |
| 4747 | return 0; |
| 4748 | } |
| 4749 | DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability); |
| 4750 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4751 | static int i915_dsc_fec_support_show(struct seq_file *m, void *data) |
| 4752 | { |
| 4753 | struct drm_connector *connector = m->private; |
| 4754 | struct drm_device *dev = connector->dev; |
| 4755 | struct drm_crtc *crtc; |
| 4756 | struct intel_dp *intel_dp; |
| 4757 | struct drm_modeset_acquire_ctx ctx; |
| 4758 | struct intel_crtc_state *crtc_state = NULL; |
| 4759 | int ret = 0; |
| 4760 | bool try_again = false; |
| 4761 | |
| 4762 | drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); |
| 4763 | |
| 4764 | do { |
Manasi Navare | 6afe892 | 2018-12-19 15:51:20 -0800 | [diff] [blame] | 4765 | try_again = false; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4766 | ret = drm_modeset_lock(&dev->mode_config.connection_mutex, |
| 4767 | &ctx); |
| 4768 | if (ret) { |
Chris Wilson | ee6df56 | 2019-03-29 16:51:52 +0000 | [diff] [blame] | 4769 | if (ret == -EDEADLK && !drm_modeset_backoff(&ctx)) { |
| 4770 | try_again = true; |
| 4771 | continue; |
| 4772 | } |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4773 | break; |
| 4774 | } |
| 4775 | crtc = connector->state->crtc; |
| 4776 | if (connector->status != connector_status_connected || !crtc) { |
| 4777 | ret = -ENODEV; |
| 4778 | break; |
| 4779 | } |
| 4780 | ret = drm_modeset_lock(&crtc->mutex, &ctx); |
| 4781 | if (ret == -EDEADLK) { |
| 4782 | ret = drm_modeset_backoff(&ctx); |
| 4783 | if (!ret) { |
| 4784 | try_again = true; |
| 4785 | continue; |
| 4786 | } |
| 4787 | break; |
| 4788 | } else if (ret) { |
| 4789 | break; |
| 4790 | } |
| 4791 | intel_dp = enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 4792 | crtc_state = to_intel_crtc_state(crtc->state); |
| 4793 | seq_printf(m, "DSC_Enabled: %s\n", |
| 4794 | yesno(crtc_state->dsc_params.compression_enable)); |
Radhakrishna Sripada | fed8569 | 2019-01-09 13:14:14 -0800 | [diff] [blame] | 4795 | seq_printf(m, "DSC_Sink_Support: %s\n", |
| 4796 | yesno(drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd))); |
Manasi Navare | feb8846 | 2019-04-05 15:48:21 -0700 | [diff] [blame] | 4797 | seq_printf(m, "Force_DSC_Enable: %s\n", |
| 4798 | yesno(intel_dp->force_dsc_en)); |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4799 | if (!intel_dp_is_edp(intel_dp)) |
| 4800 | seq_printf(m, "FEC_Sink_Support: %s\n", |
| 4801 | yesno(drm_dp_sink_supports_fec(intel_dp->fec_capable))); |
| 4802 | } while (try_again); |
| 4803 | |
| 4804 | drm_modeset_drop_locks(&ctx); |
| 4805 | drm_modeset_acquire_fini(&ctx); |
| 4806 | |
| 4807 | return ret; |
| 4808 | } |
| 4809 | |
| 4810 | static ssize_t i915_dsc_fec_support_write(struct file *file, |
| 4811 | const char __user *ubuf, |
| 4812 | size_t len, loff_t *offp) |
| 4813 | { |
| 4814 | bool dsc_enable = false; |
| 4815 | int ret; |
| 4816 | struct drm_connector *connector = |
| 4817 | ((struct seq_file *)file->private_data)->private; |
| 4818 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
| 4819 | struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); |
| 4820 | |
| 4821 | if (len == 0) |
| 4822 | return 0; |
| 4823 | |
| 4824 | DRM_DEBUG_DRIVER("Copied %zu bytes from user to force DSC\n", |
| 4825 | len); |
| 4826 | |
| 4827 | ret = kstrtobool_from_user(ubuf, len, &dsc_enable); |
| 4828 | if (ret < 0) |
| 4829 | return ret; |
| 4830 | |
| 4831 | DRM_DEBUG_DRIVER("Got %s for DSC Enable\n", |
| 4832 | (dsc_enable) ? "true" : "false"); |
| 4833 | intel_dp->force_dsc_en = dsc_enable; |
| 4834 | |
| 4835 | *offp += len; |
| 4836 | return len; |
| 4837 | } |
| 4838 | |
| 4839 | static int i915_dsc_fec_support_open(struct inode *inode, |
| 4840 | struct file *file) |
| 4841 | { |
| 4842 | return single_open(file, i915_dsc_fec_support_show, |
| 4843 | inode->i_private); |
| 4844 | } |
| 4845 | |
| 4846 | static const struct file_operations i915_dsc_fec_support_fops = { |
| 4847 | .owner = THIS_MODULE, |
| 4848 | .open = i915_dsc_fec_support_open, |
| 4849 | .read = seq_read, |
| 4850 | .llseek = seq_lseek, |
| 4851 | .release = single_release, |
| 4852 | .write = i915_dsc_fec_support_write |
| 4853 | }; |
| 4854 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4855 | /** |
| 4856 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 4857 | * @connector: pointer to a registered drm_connector |
| 4858 | * |
| 4859 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 4860 | * drm_debugfs_connector_remove(). |
| 4861 | * |
| 4862 | * Returns 0 on success, negative error codes on error. |
| 4863 | */ |
| 4864 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 4865 | { |
| 4866 | struct dentry *root = connector->debugfs_entry; |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4867 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4868 | |
| 4869 | /* The connector must have been registered beforehands. */ |
| 4870 | if (!root) |
| 4871 | return -ENODEV; |
| 4872 | |
| 4873 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4874 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4875 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 4876 | connector, &i915_dpcd_fops); |
| 4877 | |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 4878 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 4879 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 4880 | connector, &i915_panel_fops); |
Dhinakaran Pandiyan | 5b7b308 | 2018-07-04 17:31:21 -0700 | [diff] [blame] | 4881 | debugfs_create_file("i915_psr_sink_status", S_IRUGO, root, |
| 4882 | connector, &i915_psr_sink_status_fops); |
| 4883 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4884 | |
Ramalingam C | bdc93fe | 2018-10-23 14:52:29 +0530 | [diff] [blame] | 4885 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4886 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || |
| 4887 | connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { |
| 4888 | debugfs_create_file("i915_hdcp_sink_capability", S_IRUGO, root, |
| 4889 | connector, &i915_hdcp_sink_capability_fops); |
| 4890 | } |
| 4891 | |
Manasi Navare | e845f09 | 2018-12-05 16:54:07 -0800 | [diff] [blame] | 4892 | if (INTEL_GEN(dev_priv) >= 10 && |
| 4893 | (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4894 | connector->connector_type == DRM_MODE_CONNECTOR_eDP)) |
| 4895 | debugfs_create_file("i915_dsc_fec_support", S_IRUGO, root, |
| 4896 | connector, &i915_dsc_fec_support_fops); |
| 4897 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 4898 | return 0; |
| 4899 | } |