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 | |
| 29 | #include <linux/seq_file.h> |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 30 | #include <linux/circ_buf.h> |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 31 | #include <linux/ctype.h> |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 32 | #include <linux/debugfs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 33 | #include <linux/slab.h> |
Paul Gortmaker | 2d1a8a4 | 2011-08-30 18:16:33 -0400 | [diff] [blame] | 34 | #include <linux/export.h> |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 35 | #include <linux/list_sort.h> |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 36 | #include <asm/msr-index.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 37 | #include <drm/drmP.h> |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 38 | #include "intel_drv.h" |
Chris Wilson | e5c6526 | 2010-11-01 11:35:28 +0000 | [diff] [blame] | 39 | #include "intel_ringbuffer.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 40 | #include <drm/i915_drm.h> |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 41 | #include "i915_drv.h" |
| 42 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 43 | static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) |
| 44 | { |
| 45 | return to_i915(node->minor->dev); |
| 46 | } |
| 47 | |
Damien Lespiau | 497666d | 2013-10-15 18:55:39 +0100 | [diff] [blame] | 48 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 49 | * allocated we need to hook into the minor for release. */ |
| 50 | static int |
| 51 | drm_add_fake_info_node(struct drm_minor *minor, |
| 52 | struct dentry *ent, |
| 53 | const void *key) |
| 54 | { |
| 55 | struct drm_info_node *node; |
| 56 | |
| 57 | node = kmalloc(sizeof(*node), GFP_KERNEL); |
| 58 | if (node == NULL) { |
| 59 | debugfs_remove(ent); |
| 60 | return -ENOMEM; |
| 61 | } |
| 62 | |
| 63 | node->minor = minor; |
| 64 | node->dent = ent; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 65 | node->info_ent = (void *)key; |
Damien Lespiau | 497666d | 2013-10-15 18:55:39 +0100 | [diff] [blame] | 66 | |
| 67 | mutex_lock(&minor->debugfs_lock); |
| 68 | list_add(&node->list, &minor->debugfs_list); |
| 69 | mutex_unlock(&minor->debugfs_lock); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 74 | static int i915_capabilities(struct seq_file *m, void *data) |
| 75 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 76 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 77 | const struct intel_device_info *info = INTEL_INFO(dev_priv); |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 78 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 79 | seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv)); |
| 80 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv)); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 81 | #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
Joonas Lahtinen | 604db65 | 2016-10-05 13:50:16 +0300 | [diff] [blame] | 82 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 83 | #undef PRINT_FLAG |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 84 | |
| 85 | return 0; |
| 86 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 87 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 88 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 89 | { |
Chris Wilson | 573adb3 | 2016-08-04 16:32:39 +0100 | [diff] [blame] | 90 | return i915_gem_object_is_active(obj) ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 93 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 94 | { |
| 95 | return obj->pin_display ? 'p' : ' '; |
| 96 | } |
| 97 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 98 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 99 | { |
Chris Wilson | 3e510a8 | 2016-08-05 10:14:23 +0100 | [diff] [blame] | 100 | switch (i915_gem_object_get_tiling(obj)) { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 101 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 102 | case I915_TILING_NONE: return ' '; |
| 103 | case I915_TILING_X: return 'X'; |
| 104 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 105 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 108 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 109 | { |
Chris Wilson | 275f039 | 2016-10-24 13:42:14 +0100 | [diff] [blame] | 110 | return !list_empty(&obj->userfault_link) ? 'g' : ' '; |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 111 | } |
| 112 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 113 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 114 | { |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 115 | return obj->mm.mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 118 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 119 | { |
| 120 | u64 size = 0; |
| 121 | struct i915_vma *vma; |
| 122 | |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 123 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 124 | if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 125 | size += vma->node.size; |
| 126 | } |
| 127 | |
| 128 | return size; |
| 129 | } |
| 130 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 131 | static void |
| 132 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 133 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 134 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 135 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 136 | struct i915_vma *vma; |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 137 | unsigned int frontbuffer_bits; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 138 | int pin_count = 0; |
| 139 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 140 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 141 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 142 | 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] | 143 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 144 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 145 | get_pin_flag(obj), |
| 146 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 147 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 148 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 149 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 150 | obj->base.read_domains, |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 151 | obj->base.write_domain, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 152 | i915_cache_level_str(dev_priv, obj->cache_level), |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 153 | obj->mm.dirty ? " dirty" : "", |
| 154 | obj->mm.madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 155 | if (obj->base.name) |
| 156 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 157 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 158 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 159 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 160 | } |
| 161 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 162 | if (obj->pin_display) |
| 163 | seq_printf(m, " (display)"); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 164 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 165 | if (!drm_mm_node_allocated(&vma->node)) |
| 166 | continue; |
| 167 | |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 168 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 169 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 170 | vma->node.start, vma->node.size); |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 171 | if (i915_vma_is_ggtt(vma)) |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 172 | seq_printf(m, ", type: %u", vma->ggtt_view.type); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 173 | if (vma->fence) |
| 174 | seq_printf(m, " , fence: %d%s", |
| 175 | vma->fence->id, |
| 176 | i915_gem_active_isset(&vma->last_fence) ? "*" : ""); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 177 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 178 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 179 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 180 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 181 | |
Chris Wilson | d07f0e5 | 2016-10-28 13:58:44 +0100 | [diff] [blame] | 182 | engine = i915_gem_object_last_write_engine(obj); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 183 | if (engine) |
| 184 | seq_printf(m, " (%s)", engine->name); |
| 185 | |
Chris Wilson | faf5bf0 | 2016-08-04 16:32:37 +0100 | [diff] [blame] | 186 | frontbuffer_bits = atomic_read(&obj->frontbuffer_bits); |
| 187 | if (frontbuffer_bits) |
| 188 | seq_printf(m, " (frontbuffer: 0x%03x)", frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 191 | static int obj_rank_by_stolen(void *priv, |
| 192 | struct list_head *A, struct list_head *B) |
| 193 | { |
| 194 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 195 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 196 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 197 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 198 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 199 | if (a->stolen->start < b->stolen->start) |
| 200 | return -1; |
| 201 | if (a->stolen->start > b->stolen->start) |
| 202 | return 1; |
| 203 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 207 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 208 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 209 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 210 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 211 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 212 | LIST_HEAD(stolen); |
| 213 | int count, ret; |
| 214 | |
| 215 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 216 | if (ret) |
| 217 | return ret; |
| 218 | |
| 219 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 220 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 221 | if (obj->stolen == NULL) |
| 222 | continue; |
| 223 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 224 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 225 | |
| 226 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 227 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 228 | count++; |
| 229 | } |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 230 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 231 | if (obj->stolen == NULL) |
| 232 | continue; |
| 233 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 234 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 235 | |
| 236 | total_obj_size += obj->base.size; |
| 237 | count++; |
| 238 | } |
| 239 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 240 | seq_puts(m, "Stolen:\n"); |
| 241 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 242 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 243 | seq_puts(m, " "); |
| 244 | describe_obj(m, obj); |
| 245 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 246 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 247 | } |
| 248 | mutex_unlock(&dev->struct_mutex); |
| 249 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 250 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 251 | count, total_obj_size, total_gtt_size); |
| 252 | return 0; |
| 253 | } |
| 254 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 255 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 256 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 257 | unsigned long count; |
| 258 | u64 total, unbound; |
| 259 | u64 global, shared; |
| 260 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | static int per_file_stats(int id, void *ptr, void *data) |
| 264 | { |
| 265 | struct drm_i915_gem_object *obj = ptr; |
| 266 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 267 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 268 | |
| 269 | stats->count++; |
| 270 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 271 | if (!obj->bind_count) |
| 272 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 273 | if (obj->base.name || obj->base.dma_buf) |
| 274 | stats->shared += obj->base.size; |
| 275 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 276 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 277 | if (!drm_mm_node_allocated(&vma->node)) |
| 278 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 279 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame] | 280 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 281 | stats->global += vma->node.size; |
| 282 | } else { |
| 283 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 284 | |
Chris Wilson | 2bfa996 | 2016-08-04 07:52:25 +0100 | [diff] [blame] | 285 | if (ppgtt->base.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 286 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 287 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 288 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 289 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 290 | stats->active += vma->node.size; |
| 291 | else |
| 292 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 298 | #define print_file_stats(m, name, stats) do { \ |
| 299 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 300 | seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \ |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 301 | name, \ |
| 302 | stats.count, \ |
| 303 | stats.total, \ |
| 304 | stats.active, \ |
| 305 | stats.inactive, \ |
| 306 | stats.global, \ |
| 307 | stats.shared, \ |
| 308 | stats.unbound); \ |
| 309 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 310 | |
| 311 | static void print_batch_pool_stats(struct seq_file *m, |
| 312 | struct drm_i915_private *dev_priv) |
| 313 | { |
| 314 | struct drm_i915_gem_object *obj; |
| 315 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 316 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 317 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 318 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 319 | |
| 320 | memset(&stats, 0, sizeof(stats)); |
| 321 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 322 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 323 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 324 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 325 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 326 | batch_pool_link) |
| 327 | per_file_stats(0, obj, &stats); |
| 328 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 329 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 330 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 331 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 332 | } |
| 333 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 334 | static int per_file_ctx_stats(int id, void *ptr, void *data) |
| 335 | { |
| 336 | struct i915_gem_context *ctx = ptr; |
| 337 | int n; |
| 338 | |
| 339 | for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) { |
| 340 | if (ctx->engine[n].state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 341 | per_file_stats(0, ctx->engine[n].state->obj, data); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 342 | if (ctx->engine[n].ring) |
Chris Wilson | 57e8853 | 2016-08-15 10:48:57 +0100 | [diff] [blame] | 343 | per_file_stats(0, ctx->engine[n].ring->vma->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | static void print_context_stats(struct seq_file *m, |
| 350 | struct drm_i915_private *dev_priv) |
| 351 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 352 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 353 | struct file_stats stats; |
| 354 | struct drm_file *file; |
| 355 | |
| 356 | memset(&stats, 0, sizeof(stats)); |
| 357 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 358 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 359 | if (dev_priv->kernel_context) |
| 360 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 361 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 362 | list_for_each_entry(file, &dev->filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 363 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 364 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 365 | } |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 366 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 367 | |
| 368 | print_file_stats(m, "[k]contexts", stats); |
| 369 | } |
| 370 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 371 | static int i915_gem_object_info(struct seq_file *m, void *data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 372 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 373 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 374 | struct drm_device *dev = &dev_priv->drm; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 375 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 376 | u32 count, mapped_count, purgeable_count, dpy_count; |
| 377 | u64 size, mapped_size, purgeable_size, dpy_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 378 | struct drm_i915_gem_object *obj; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 379 | struct drm_file *file; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 380 | int ret; |
| 381 | |
| 382 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 383 | if (ret) |
| 384 | return ret; |
| 385 | |
Chris Wilson | 3ef7f22 | 2016-10-18 13:02:48 +0100 | [diff] [blame] | 386 | seq_printf(m, "%u objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 387 | dev_priv->mm.object_count, |
| 388 | dev_priv->mm.object_memory); |
| 389 | |
Chris Wilson | 1544c42 | 2016-08-15 13:18:16 +0100 | [diff] [blame] | 390 | size = count = 0; |
| 391 | mapped_size = mapped_count = 0; |
| 392 | purgeable_size = purgeable_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 393 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 394 | size += obj->base.size; |
| 395 | ++count; |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 396 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 397 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 398 | purgeable_size += obj->base.size; |
| 399 | ++purgeable_count; |
| 400 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 401 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 402 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 403 | mapped_count++; |
| 404 | mapped_size += obj->base.size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 405 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 406 | } |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 407 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
| 408 | |
| 409 | size = count = dpy_size = dpy_count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 410 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 411 | size += obj->base.size; |
| 412 | ++count; |
| 413 | |
| 414 | if (obj->pin_display) { |
| 415 | dpy_size += obj->base.size; |
| 416 | ++dpy_count; |
| 417 | } |
| 418 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 419 | if (obj->mm.madv == I915_MADV_DONTNEED) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 420 | purgeable_size += obj->base.size; |
| 421 | ++purgeable_count; |
| 422 | } |
| 423 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 424 | if (obj->mm.mapping) { |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 425 | mapped_count++; |
| 426 | mapped_size += obj->base.size; |
| 427 | } |
| 428 | } |
| 429 | seq_printf(m, "%u bound objects, %llu bytes\n", |
| 430 | count, size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 431 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 432 | purgeable_count, purgeable_size); |
Chris Wilson | 2bd160a | 2016-08-15 10:48:45 +0100 | [diff] [blame] | 433 | seq_printf(m, "%u mapped objects, %llu bytes\n", |
| 434 | mapped_count, mapped_size); |
| 435 | seq_printf(m, "%u display objects (pinned), %llu bytes\n", |
| 436 | dpy_count, dpy_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 437 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 438 | seq_printf(m, "%llu [%llu] gtt total\n", |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 439 | ggtt->base.total, ggtt->mappable_end - ggtt->base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 440 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 441 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 442 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 443 | mutex_unlock(&dev->struct_mutex); |
| 444 | |
| 445 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 446 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 447 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 448 | struct file_stats stats; |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 449 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 450 | struct drm_i915_gem_request *request; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 451 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 452 | |
| 453 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 454 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 455 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 456 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 457 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 458 | /* |
| 459 | * Although we have a valid reference on file->pid, that does |
| 460 | * not guarantee that the task_struct who called get_pid() is |
| 461 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 462 | * Therefore, we need to protect this ->comm access using RCU. |
| 463 | */ |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 464 | mutex_lock(&dev->struct_mutex); |
| 465 | request = list_first_entry_or_null(&file_priv->mm.request_list, |
| 466 | struct drm_i915_gem_request, |
| 467 | client_list); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 468 | rcu_read_lock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 469 | task = pid_task(request && request->ctx->pid ? |
| 470 | request->ctx->pid : file->pid, |
| 471 | PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 472 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 473 | rcu_read_unlock(); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 474 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 475 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 476 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 477 | |
| 478 | return 0; |
| 479 | } |
| 480 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 481 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 482 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 483 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 484 | struct drm_i915_private *dev_priv = node_to_i915(node); |
| 485 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 5f4b091 | 2016-08-19 12:56:25 +0100 | [diff] [blame] | 486 | bool show_pin_display_only = !!node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 487 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 488 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 489 | int count, ret; |
| 490 | |
| 491 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 492 | if (ret) |
| 493 | return ret; |
| 494 | |
| 495 | total_obj_size = total_gtt_size = count = 0; |
Joonas Lahtinen | 56cea32 | 2016-11-02 12:16:04 +0200 | [diff] [blame] | 496 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) { |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 497 | if (show_pin_display_only && !obj->pin_display) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 498 | continue; |
| 499 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 500 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 501 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 502 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 503 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 504 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 505 | count++; |
| 506 | } |
| 507 | |
| 508 | mutex_unlock(&dev->struct_mutex); |
| 509 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 510 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 511 | count, total_obj_size, total_gtt_size); |
| 512 | |
| 513 | return 0; |
| 514 | } |
| 515 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 516 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 517 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 518 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 519 | struct drm_device *dev = &dev_priv->drm; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 520 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 521 | int ret; |
| 522 | |
| 523 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 524 | if (ret) |
| 525 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 526 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 527 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 528 | const char pipe = pipe_name(crtc->pipe); |
| 529 | const char plane = plane_name(crtc->plane); |
Maarten Lankhorst | 51cbaf0 | 2016-05-17 15:07:49 +0200 | [diff] [blame] | 530 | struct intel_flip_work *work; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 531 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 532 | spin_lock_irq(&dev->event_lock); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 533 | work = crtc->flip_work; |
| 534 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 535 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 536 | pipe, plane); |
| 537 | } else { |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 538 | u32 pending; |
| 539 | u32 addr; |
| 540 | |
| 541 | pending = atomic_read(&work->pending); |
| 542 | if (pending) { |
| 543 | seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n", |
| 544 | pipe, plane); |
| 545 | } else { |
| 546 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
| 547 | pipe, plane); |
| 548 | } |
| 549 | if (work->flip_queued_req) { |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 550 | struct intel_engine_cs *engine = work->flip_queued_req->engine; |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 551 | |
| 552 | seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n", |
| 553 | engine->name, |
Joonas Lahtinen | 24327f8 | 2016-11-08 09:11:48 +0200 | [diff] [blame] | 554 | work->flip_queued_req->global_seqno, |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 555 | atomic_read(&dev_priv->gt.global_timeline.next_seqno), |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 556 | intel_engine_get_seqno(engine), |
Chris Wilson | f69a02c | 2016-07-01 17:23:16 +0100 | [diff] [blame] | 557 | i915_gem_request_completed(work->flip_queued_req)); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 558 | } else |
| 559 | seq_printf(m, "Flip not associated with any ring\n"); |
| 560 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 561 | work->flip_queued_vblank, |
| 562 | work->flip_ready_vblank, |
| 563 | intel_crtc_get_vblank_counter(crtc)); |
| 564 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
| 565 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 566 | if (INTEL_GEN(dev_priv) >= 4) |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 567 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 568 | else |
| 569 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 570 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 571 | |
| 572 | if (work->pending_flip_obj) { |
| 573 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 574 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 575 | } |
| 576 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 577 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 578 | } |
| 579 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 580 | mutex_unlock(&dev->struct_mutex); |
| 581 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 582 | return 0; |
| 583 | } |
| 584 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 585 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 586 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 587 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 588 | struct drm_device *dev = &dev_priv->drm; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 589 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 590 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 591 | enum intel_engine_id id; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 592 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 593 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 594 | |
| 595 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 596 | if (ret) |
| 597 | return ret; |
| 598 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 599 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 600 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 601 | int count; |
| 602 | |
| 603 | count = 0; |
| 604 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 605 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 606 | batch_pool_link) |
| 607 | count++; |
| 608 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 609 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 610 | |
| 611 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 612 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 613 | batch_pool_link) { |
| 614 | seq_puts(m, " "); |
| 615 | describe_obj(m, obj); |
| 616 | seq_putc(m, '\n'); |
| 617 | } |
| 618 | |
| 619 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 620 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 621 | } |
| 622 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 623 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 624 | |
| 625 | mutex_unlock(&dev->struct_mutex); |
| 626 | |
| 627 | return 0; |
| 628 | } |
| 629 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 630 | static void print_request(struct seq_file *m, |
| 631 | struct drm_i915_gem_request *rq, |
| 632 | const char *prefix) |
| 633 | { |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 634 | seq_printf(m, "%s%x [%x:%x] prio=%d @ %dms: %s\n", prefix, |
Chris Wilson | 65e4760 | 2016-10-28 13:58:49 +0100 | [diff] [blame] | 635 | rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno, |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 636 | rq->priotree.priority, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 637 | jiffies_to_msecs(jiffies - rq->emitted_jiffies), |
Chris Wilson | 562f5d4 | 2016-10-28 13:58:54 +0100 | [diff] [blame] | 638 | rq->timeline->common->name); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 639 | } |
| 640 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 641 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 642 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 643 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 644 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 645 | struct drm_i915_gem_request *req; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 646 | struct intel_engine_cs *engine; |
| 647 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 648 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 649 | |
| 650 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 651 | if (ret) |
| 652 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 653 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 654 | any = 0; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 655 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 656 | int count; |
| 657 | |
| 658 | count = 0; |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 659 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 660 | count++; |
| 661 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 662 | continue; |
| 663 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 664 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 665 | list_for_each_entry(req, &engine->timeline->requests, link) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 666 | print_request(m, req, " "); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 667 | |
| 668 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 669 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 670 | mutex_unlock(&dev->struct_mutex); |
| 671 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 672 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 673 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 674 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 675 | return 0; |
| 676 | } |
| 677 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 678 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 679 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 680 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 681 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 682 | struct rb_node *rb; |
| 683 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 684 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 685 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 686 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 687 | spin_lock_irq(&b->lock); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 688 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 689 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 690 | |
| 691 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 692 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 693 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 694 | spin_unlock_irq(&b->lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 695 | } |
| 696 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 697 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 698 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 699 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 700 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 701 | enum intel_engine_id id; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 702 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 703 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 704 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 705 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 711 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 712 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 713 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 714 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 715 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 716 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 717 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 718 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 719 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 720 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 721 | I915_READ(GEN8_MASTER_IRQ)); |
| 722 | |
| 723 | seq_printf(m, "Display IER:\t%08x\n", |
| 724 | I915_READ(VLV_IER)); |
| 725 | seq_printf(m, "Display IIR:\t%08x\n", |
| 726 | I915_READ(VLV_IIR)); |
| 727 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 728 | I915_READ(VLV_IIR_RW)); |
| 729 | seq_printf(m, "Display IMR:\t%08x\n", |
| 730 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 731 | for_each_pipe(dev_priv, pipe) { |
| 732 | enum intel_display_power_domain power_domain; |
| 733 | |
| 734 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 735 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 736 | power_domain)) { |
| 737 | seq_printf(m, "Pipe %c power disabled\n", |
| 738 | pipe_name(pipe)); |
| 739 | continue; |
| 740 | } |
| 741 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 742 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 743 | pipe_name(pipe), |
| 744 | I915_READ(PIPESTAT(pipe))); |
| 745 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 746 | intel_display_power_put(dev_priv, power_domain); |
| 747 | } |
| 748 | |
| 749 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 750 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 751 | I915_READ(PORT_HOTPLUG_EN)); |
| 752 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 753 | I915_READ(VLV_DPFLIPSTAT)); |
| 754 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 755 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 756 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 757 | |
| 758 | for (i = 0; i < 4; i++) { |
| 759 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 760 | i, I915_READ(GEN8_GT_IMR(i))); |
| 761 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 762 | i, I915_READ(GEN8_GT_IIR(i))); |
| 763 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 764 | i, I915_READ(GEN8_GT_IER(i))); |
| 765 | } |
| 766 | |
| 767 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 768 | I915_READ(GEN8_PCU_IMR)); |
| 769 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 770 | I915_READ(GEN8_PCU_IIR)); |
| 771 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 772 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 773 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 774 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 775 | I915_READ(GEN8_MASTER_IRQ)); |
| 776 | |
| 777 | for (i = 0; i < 4; i++) { |
| 778 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 779 | i, I915_READ(GEN8_GT_IMR(i))); |
| 780 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 781 | i, I915_READ(GEN8_GT_IIR(i))); |
| 782 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 783 | i, I915_READ(GEN8_GT_IER(i))); |
| 784 | } |
| 785 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 786 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 787 | enum intel_display_power_domain power_domain; |
| 788 | |
| 789 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 790 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 791 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 792 | seq_printf(m, "Pipe %c power disabled\n", |
| 793 | pipe_name(pipe)); |
| 794 | continue; |
| 795 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 796 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 797 | pipe_name(pipe), |
| 798 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 799 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 800 | pipe_name(pipe), |
| 801 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 802 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 803 | pipe_name(pipe), |
| 804 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 805 | |
| 806 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 810 | I915_READ(GEN8_DE_PORT_IMR)); |
| 811 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 812 | I915_READ(GEN8_DE_PORT_IIR)); |
| 813 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 814 | I915_READ(GEN8_DE_PORT_IER)); |
| 815 | |
| 816 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 817 | I915_READ(GEN8_DE_MISC_IMR)); |
| 818 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 819 | I915_READ(GEN8_DE_MISC_IIR)); |
| 820 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 821 | I915_READ(GEN8_DE_MISC_IER)); |
| 822 | |
| 823 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 824 | I915_READ(GEN8_PCU_IMR)); |
| 825 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 826 | I915_READ(GEN8_PCU_IIR)); |
| 827 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 828 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 829 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 830 | seq_printf(m, "Display IER:\t%08x\n", |
| 831 | I915_READ(VLV_IER)); |
| 832 | seq_printf(m, "Display IIR:\t%08x\n", |
| 833 | I915_READ(VLV_IIR)); |
| 834 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 835 | I915_READ(VLV_IIR_RW)); |
| 836 | seq_printf(m, "Display IMR:\t%08x\n", |
| 837 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 838 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 839 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 840 | pipe_name(pipe), |
| 841 | I915_READ(PIPESTAT(pipe))); |
| 842 | |
| 843 | seq_printf(m, "Master IER:\t%08x\n", |
| 844 | I915_READ(VLV_MASTER_IER)); |
| 845 | |
| 846 | seq_printf(m, "Render IER:\t%08x\n", |
| 847 | I915_READ(GTIER)); |
| 848 | seq_printf(m, "Render IIR:\t%08x\n", |
| 849 | I915_READ(GTIIR)); |
| 850 | seq_printf(m, "Render IMR:\t%08x\n", |
| 851 | I915_READ(GTIMR)); |
| 852 | |
| 853 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 854 | I915_READ(GEN6_PMIER)); |
| 855 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 856 | I915_READ(GEN6_PMIIR)); |
| 857 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 858 | I915_READ(GEN6_PMIMR)); |
| 859 | |
| 860 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 861 | I915_READ(PORT_HOTPLUG_EN)); |
| 862 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 863 | I915_READ(VLV_DPFLIPSTAT)); |
| 864 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 865 | I915_READ(DPINVGTT)); |
| 866 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 867 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 868 | seq_printf(m, "Interrupt enable: %08x\n", |
| 869 | I915_READ(IER)); |
| 870 | seq_printf(m, "Interrupt identity: %08x\n", |
| 871 | I915_READ(IIR)); |
| 872 | seq_printf(m, "Interrupt mask: %08x\n", |
| 873 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 874 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 875 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 876 | pipe_name(pipe), |
| 877 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 878 | } else { |
| 879 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 880 | I915_READ(DEIER)); |
| 881 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 882 | I915_READ(DEIIR)); |
| 883 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 884 | I915_READ(DEIMR)); |
| 885 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 886 | I915_READ(SDEIER)); |
| 887 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 888 | I915_READ(SDEIIR)); |
| 889 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 890 | I915_READ(SDEIMR)); |
| 891 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 892 | I915_READ(GTIER)); |
| 893 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 894 | I915_READ(GTIIR)); |
| 895 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 896 | I915_READ(GTIMR)); |
| 897 | } |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 898 | for_each_engine(engine, dev_priv, id) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 899 | if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 900 | seq_printf(m, |
| 901 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 902 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 903 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 904 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 905 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 906 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 907 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 908 | return 0; |
| 909 | } |
| 910 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 911 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 912 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 913 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 914 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 915 | int i, ret; |
| 916 | |
| 917 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 918 | if (ret) |
| 919 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 920 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 921 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 922 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 923 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 924 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 925 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 926 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 927 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 928 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 929 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 930 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 931 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 932 | } |
| 933 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 934 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 935 | return 0; |
| 936 | } |
| 937 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 938 | static int i915_hws_info(struct seq_file *m, void *data) |
| 939 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 940 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 941 | struct drm_i915_private *dev_priv = node_to_i915(node); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 942 | struct intel_engine_cs *engine; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 943 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 944 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 945 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 946 | engine = dev_priv->engine[(uintptr_t)node->info_ent->data]; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 947 | hws = engine->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 948 | if (hws == NULL) |
| 949 | return 0; |
| 950 | |
| 951 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 952 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 953 | i * 4, |
| 954 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 955 | } |
| 956 | return 0; |
| 957 | } |
| 958 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 959 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
| 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 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 967 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 968 | |
| 969 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 662d19e | 2016-09-01 21:55:10 +0100 | [diff] [blame] | 970 | i915_destroy_error_state(error_priv->dev); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 971 | |
| 972 | return cnt; |
| 973 | } |
| 974 | |
| 975 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 976 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 977 | struct drm_i915_private *dev_priv = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 978 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 979 | |
| 980 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 981 | if (!error_priv) |
| 982 | return -ENOMEM; |
| 983 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 984 | error_priv->dev = &dev_priv->drm; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 985 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 986 | i915_error_state_get(&dev_priv->drm, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 987 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 988 | file->private_data = error_priv; |
| 989 | |
| 990 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 994 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 995 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 996 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 997 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 998 | kfree(error_priv); |
| 999 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1000 | return 0; |
| 1001 | } |
| 1002 | |
| 1003 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1004 | size_t count, loff_t *pos) |
| 1005 | { |
| 1006 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1007 | struct drm_i915_error_state_buf error_str; |
| 1008 | loff_t tmp_pos = 0; |
| 1009 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1010 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1011 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1012 | ret = i915_error_state_buf_init(&error_str, |
| 1013 | to_i915(error_priv->dev), count, *pos); |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1014 | if (ret) |
| 1015 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1016 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1017 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1018 | if (ret) |
| 1019 | goto out; |
| 1020 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1021 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1022 | error_str.buf, |
| 1023 | error_str.bytes); |
| 1024 | |
| 1025 | if (ret_count < 0) |
| 1026 | ret = ret_count; |
| 1027 | else |
| 1028 | *pos = error_str.start + ret_count; |
| 1029 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1030 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1031 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | static const struct file_operations i915_error_state_fops = { |
| 1035 | .owner = THIS_MODULE, |
| 1036 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1037 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1038 | .write = i915_error_state_write, |
| 1039 | .llseek = default_llseek, |
| 1040 | .release = i915_error_state_release, |
| 1041 | }; |
| 1042 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1043 | #endif |
| 1044 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1045 | static int |
| 1046 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1047 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1048 | struct drm_i915_private *dev_priv = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1049 | |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 1050 | *val = atomic_read(&dev_priv->gt.global_timeline.next_seqno); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1051 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1052 | } |
| 1053 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1054 | static int |
| 1055 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1056 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1057 | struct drm_i915_private *dev_priv = data; |
| 1058 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1059 | int ret; |
| 1060 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1061 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1062 | if (ret) |
| 1063 | return ret; |
| 1064 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 1065 | ret = i915_gem_set_global_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1066 | mutex_unlock(&dev->struct_mutex); |
| 1067 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1068 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1069 | } |
| 1070 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1071 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1072 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1073 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1074 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1075 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1076 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1077 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1078 | struct drm_device *dev = &dev_priv->drm; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1079 | int ret = 0; |
| 1080 | |
| 1081 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1082 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1083 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1084 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1085 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1086 | |
| 1087 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1088 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1089 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1090 | MEMSTAT_VID_SHIFT); |
| 1091 | seq_printf(m, "Current P-state: %d\n", |
| 1092 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1093 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1094 | u32 freq_sts; |
| 1095 | |
| 1096 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1097 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1098 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1099 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1100 | |
| 1101 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1102 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1103 | |
| 1104 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1105 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1106 | |
| 1107 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1108 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1109 | |
| 1110 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1111 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1112 | |
| 1113 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1114 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1115 | |
| 1116 | seq_printf(m, |
| 1117 | "efficient (RPe) frequency: %d MHz\n", |
| 1118 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1119 | mutex_unlock(&dev_priv->rps.hw_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1120 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1121 | u32 rp_state_limits; |
| 1122 | u32 gt_perf_status; |
| 1123 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1124 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1125 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1126 | u32 rpupei, rpcurup, rpprevup; |
| 1127 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1128 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1129 | int max_freq; |
| 1130 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1131 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1132 | if (IS_BROXTON(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1133 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1134 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1135 | } else { |
| 1136 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1137 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1138 | } |
| 1139 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1140 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1141 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1142 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1143 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1144 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1145 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1146 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1147 | reqf = I915_READ(GEN6_RPNSWREQ); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1148 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1149 | reqf >>= 23; |
| 1150 | else { |
| 1151 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1152 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1153 | reqf >>= 24; |
| 1154 | else |
| 1155 | reqf >>= 25; |
| 1156 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1157 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1158 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1159 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1160 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1161 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1162 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1163 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1164 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1165 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1166 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1167 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1168 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1169 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1170 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1171 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1172 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1173 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1174 | else |
| 1175 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1176 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1177 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1178 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1179 | mutex_unlock(&dev->struct_mutex); |
| 1180 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1181 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1182 | pm_ier = I915_READ(GEN6_PMIER); |
| 1183 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1184 | pm_isr = I915_READ(GEN6_PMISR); |
| 1185 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1186 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1187 | } else { |
| 1188 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1189 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1190 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1191 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1192 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1193 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1194 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n", |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1195 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 1196 | seq_printf(m, "pm_intr_keep: 0x%08x\n", dev_priv->rps.pm_intr_keep); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1197 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1198 | seq_printf(m, "Render p-state ratio: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1199 | (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1200 | seq_printf(m, "Render p-state VID: %d\n", |
| 1201 | gt_perf_status & 0xff); |
| 1202 | seq_printf(m, "Render p-state limit: %d\n", |
| 1203 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1204 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1205 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1206 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1207 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1208 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1209 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1210 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1211 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1212 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1213 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1214 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1215 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1216 | seq_printf(m, "Up threshold: %d%%\n", |
| 1217 | dev_priv->rps.up_threshold); |
| 1218 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1219 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1220 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1221 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1222 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1223 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1224 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1225 | seq_printf(m, "Down threshold: %d%%\n", |
| 1226 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1227 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1228 | max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1229 | rp_state_cap >> 16) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1230 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1231 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1232 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1233 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1234 | |
| 1235 | max_freq = (rp_state_cap & 0xff00) >> 8; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1236 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1237 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1238 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1239 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1240 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1241 | max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1242 | rp_state_cap >> 0) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1243 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1244 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1245 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1246 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1247 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1248 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1249 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1250 | seq_printf(m, "Current freq: %d MHz\n", |
| 1251 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1252 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1253 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1254 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1255 | seq_printf(m, "Min freq: %d MHz\n", |
| 1256 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1257 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1258 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1259 | seq_printf(m, "Max freq: %d MHz\n", |
| 1260 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1261 | seq_printf(m, |
| 1262 | "efficient (RPe) frequency: %d MHz\n", |
| 1263 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1264 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1265 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1266 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1267 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1268 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1269 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1270 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1271 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1272 | out: |
| 1273 | intel_runtime_pm_put(dev_priv); |
| 1274 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1275 | } |
| 1276 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1277 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1278 | struct seq_file *m, |
| 1279 | struct intel_instdone *instdone) |
| 1280 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1281 | int slice; |
| 1282 | int subslice; |
| 1283 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1284 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1285 | instdone->instdone); |
| 1286 | |
| 1287 | if (INTEL_GEN(dev_priv) <= 3) |
| 1288 | return; |
| 1289 | |
| 1290 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1291 | instdone->slice_common); |
| 1292 | |
| 1293 | if (INTEL_GEN(dev_priv) <= 6) |
| 1294 | return; |
| 1295 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1296 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1297 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1298 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1299 | |
| 1300 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1301 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1302 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1303 | } |
| 1304 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1305 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1306 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1307 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1308 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1309 | u64 acthd[I915_NUM_ENGINES]; |
| 1310 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1311 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1312 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1313 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1314 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
| 1315 | seq_printf(m, "Wedged\n"); |
| 1316 | if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags)) |
| 1317 | seq_printf(m, "Reset in progress\n"); |
| 1318 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
| 1319 | seq_printf(m, "Waiter holding struct mutex\n"); |
| 1320 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
| 1321 | seq_printf(m, "struct_mutex blocked for reset\n"); |
| 1322 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1323 | if (!i915.enable_hangcheck) { |
| 1324 | seq_printf(m, "Hangcheck disabled\n"); |
| 1325 | return 0; |
| 1326 | } |
| 1327 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1328 | intel_runtime_pm_get(dev_priv); |
| 1329 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1330 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1331 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1332 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1333 | } |
| 1334 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1335 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1336 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1337 | intel_runtime_pm_put(dev_priv); |
| 1338 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1339 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1340 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1341 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1342 | jiffies)); |
| 1343 | } else |
| 1344 | seq_printf(m, "Hangcheck inactive\n"); |
| 1345 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1346 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1347 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1348 | struct rb_node *rb; |
| 1349 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1350 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 14fd0d6 | 2016-04-07 07:29:10 +0100 | [diff] [blame] | 1351 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 1352 | engine->hangcheck.seqno, seqno[id], |
| 1353 | intel_engine_last_submit(engine)); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame^] | 1354 | seq_printf(m, "\twaiters? %s, fake irq active? %s, stalled? %s\n", |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1355 | yesno(intel_engine_has_waiter(engine)), |
| 1356 | yesno(test_bit(engine->id, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame^] | 1357 | &dev_priv->gpu_error.missed_irq_rings)), |
| 1358 | yesno(engine->hangcheck.stalled)); |
| 1359 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 1360 | spin_lock_irq(&b->lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1361 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 1362 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 1363 | |
| 1364 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1365 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1366 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 1367 | spin_unlock_irq(&b->lock); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1368 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1369 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1370 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1371 | (long long)acthd[id]); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame^] | 1372 | seq_printf(m, "\taction = %s(%d) %d ms ago\n", |
| 1373 | hangcheck_action_to_str(engine->hangcheck.action), |
| 1374 | engine->hangcheck.action, |
| 1375 | jiffies_to_msecs(jiffies - |
| 1376 | engine->hangcheck.action_timestamp)); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1377 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1378 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1379 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1380 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1381 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1382 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1383 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1384 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1385 | i915_instdone_info(dev_priv, m, |
| 1386 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1387 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1388 | } |
| 1389 | |
| 1390 | return 0; |
| 1391 | } |
| 1392 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1393 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1394 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1395 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1396 | u32 rgvmodectl, rstdbyctl; |
| 1397 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1398 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1399 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1400 | |
| 1401 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1402 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1403 | crstandvid = I915_READ16(CRSTANDVID); |
| 1404 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1405 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1406 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1407 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1408 | seq_printf(m, "Boost freq: %d\n", |
| 1409 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1410 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1411 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1412 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1413 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1414 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1415 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1416 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1417 | seq_printf(m, "Starting frequency: P%d\n", |
| 1418 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1419 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1420 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1421 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1422 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1423 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1424 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1425 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1426 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1427 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1428 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1429 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1430 | break; |
| 1431 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1432 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1433 | break; |
| 1434 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1435 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1436 | break; |
| 1437 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1438 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1439 | break; |
| 1440 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1441 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1442 | break; |
| 1443 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1444 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1445 | break; |
| 1446 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1447 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1448 | break; |
| 1449 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1450 | |
| 1451 | return 0; |
| 1452 | } |
| 1453 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1454 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1455 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1456 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1457 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1458 | |
| 1459 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1460 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1461 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1462 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1463 | fw_domain->wake_count); |
| 1464 | } |
| 1465 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1466 | |
| 1467 | return 0; |
| 1468 | } |
| 1469 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1470 | static int vlv_drpc_info(struct seq_file *m) |
| 1471 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1472 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1473 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1474 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1475 | intel_runtime_pm_get(dev_priv); |
| 1476 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1477 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1478 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1479 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1480 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1481 | intel_runtime_pm_put(dev_priv); |
| 1482 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1483 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1484 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1485 | seq_printf(m, "Turbo enabled: %s\n", |
| 1486 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1487 | seq_printf(m, "HW control enabled: %s\n", |
| 1488 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1489 | seq_printf(m, "SW control enabled: %s\n", |
| 1490 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1491 | GEN6_RP_MEDIA_SW_MODE)); |
| 1492 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1493 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1494 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1495 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1496 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1497 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1498 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1499 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1500 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1501 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1502 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1503 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1504 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1505 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1506 | } |
| 1507 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1508 | static int gen6_drpc_info(struct seq_file *m) |
| 1509 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1510 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1511 | struct drm_device *dev = &dev_priv->drm; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1512 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1513 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1514 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1515 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1516 | |
| 1517 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1518 | if (ret) |
| 1519 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1520 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1521 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1522 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1523 | forcewake_count = dev_priv->uncore.fw_domain[FW_DOMAIN_ID_RENDER].wake_count; |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1524 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1525 | |
| 1526 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1527 | seq_puts(m, "RC information inaccurate because somebody " |
| 1528 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1529 | } else { |
| 1530 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1531 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1532 | udelay(10); |
| 1533 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1534 | } |
| 1535 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1536 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1537 | 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] | 1538 | |
| 1539 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1540 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1541 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1542 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1543 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1544 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1545 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1546 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1547 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1548 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1549 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1550 | intel_runtime_pm_put(dev_priv); |
| 1551 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1552 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1553 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1554 | seq_printf(m, "HW control enabled: %s\n", |
| 1555 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1556 | seq_printf(m, "SW control enabled: %s\n", |
| 1557 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1558 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1559 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1560 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1561 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1562 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1563 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1564 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1565 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1566 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1567 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1568 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1569 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1570 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1571 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1572 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1573 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1574 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1575 | case GEN6_RC0: |
| 1576 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1577 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1578 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1579 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1580 | break; |
| 1581 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1582 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1583 | break; |
| 1584 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1585 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1586 | break; |
| 1587 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1588 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1589 | break; |
| 1590 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1591 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1592 | break; |
| 1593 | } |
| 1594 | |
| 1595 | seq_printf(m, "Core Power Down: %s\n", |
| 1596 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1597 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1598 | seq_printf(m, "Render Power Well: %s\n", |
| 1599 | (gen9_powergate_status & |
| 1600 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1601 | seq_printf(m, "Media Power Well: %s\n", |
| 1602 | (gen9_powergate_status & |
| 1603 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1604 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1605 | |
| 1606 | /* Not exactly sure what this is */ |
| 1607 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1608 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1609 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1610 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1611 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1612 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1613 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1614 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1615 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1616 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1617 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1618 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1619 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1620 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1621 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1622 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1623 | } |
| 1624 | |
| 1625 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1626 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1627 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1628 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1629 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1630 | return vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1631 | else if (INTEL_GEN(dev_priv) >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1632 | return gen6_drpc_info(m); |
| 1633 | else |
| 1634 | return ironlake_drpc_info(m); |
| 1635 | } |
| 1636 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1637 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1638 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1639 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1640 | |
| 1641 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1642 | dev_priv->fb_tracking.busy_bits); |
| 1643 | |
| 1644 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1645 | dev_priv->fb_tracking.flip_bits); |
| 1646 | |
| 1647 | return 0; |
| 1648 | } |
| 1649 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1650 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1651 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1652 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1653 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1654 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1655 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1656 | return 0; |
| 1657 | } |
| 1658 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1659 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1660 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1661 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1662 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1663 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1664 | else |
| 1665 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1666 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1667 | |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1668 | if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) { |
| 1669 | uint32_t mask = INTEL_GEN(dev_priv) >= 8 ? |
| 1670 | BDW_FBC_COMPRESSION_MASK : |
| 1671 | IVB_FBC_COMPRESSION_MASK; |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1672 | seq_printf(m, "Compressing: %s\n", |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1673 | yesno(I915_READ(FBC_STATUS2) & mask)); |
| 1674 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1675 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1676 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1677 | intel_runtime_pm_put(dev_priv); |
| 1678 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1679 | return 0; |
| 1680 | } |
| 1681 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1682 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1683 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1684 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1685 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1686 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1687 | return -ENODEV; |
| 1688 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1689 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1690 | |
| 1691 | return 0; |
| 1692 | } |
| 1693 | |
| 1694 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1695 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1696 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1697 | u32 reg; |
| 1698 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1699 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1700 | return -ENODEV; |
| 1701 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1702 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1703 | |
| 1704 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1705 | dev_priv->fbc.false_color = val; |
| 1706 | |
| 1707 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1708 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1709 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1710 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1711 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1712 | return 0; |
| 1713 | } |
| 1714 | |
| 1715 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1716 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1717 | "%llu\n"); |
| 1718 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1719 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1720 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1721 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1722 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1723 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1724 | seq_puts(m, "not supported\n"); |
| 1725 | return 0; |
| 1726 | } |
| 1727 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1728 | intel_runtime_pm_get(dev_priv); |
| 1729 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1730 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1731 | yesno(i915.enable_ips)); |
| 1732 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1733 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1734 | seq_puts(m, "Currently: unknown\n"); |
| 1735 | } else { |
| 1736 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1737 | seq_puts(m, "Currently: enabled\n"); |
| 1738 | else |
| 1739 | seq_puts(m, "Currently: disabled\n"); |
| 1740 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1741 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1742 | intel_runtime_pm_put(dev_priv); |
| 1743 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1744 | return 0; |
| 1745 | } |
| 1746 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1747 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1748 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1749 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1750 | bool sr_enabled = false; |
| 1751 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1752 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1753 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1754 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1755 | if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1756 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1757 | else if (IS_CRESTLINE(dev_priv) || IS_G4X(dev_priv) || |
| 1758 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1759 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1760 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1761 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1762 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1763 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1764 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1765 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1766 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1767 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1768 | intel_runtime_pm_put(dev_priv); |
| 1769 | |
Tvrtko Ursulin | 08c4d7f | 2016-11-17 12:30:14 +0000 | [diff] [blame] | 1770 | seq_printf(m, "self-refresh: %s\n", enableddisabled(sr_enabled)); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1771 | |
| 1772 | return 0; |
| 1773 | } |
| 1774 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1775 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1776 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1777 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1778 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1779 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1780 | int ret; |
| 1781 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1782 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1783 | return -ENODEV; |
| 1784 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1785 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1786 | if (ret) |
| 1787 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1788 | |
| 1789 | temp = i915_mch_val(dev_priv); |
| 1790 | chipset = i915_chipset_val(dev_priv); |
| 1791 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1792 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1793 | |
| 1794 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1795 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1796 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1797 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1798 | |
| 1799 | return 0; |
| 1800 | } |
| 1801 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1802 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1803 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1804 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1805 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1806 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1807 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1808 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1809 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1810 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1811 | return 0; |
| 1812 | } |
| 1813 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1814 | intel_runtime_pm_get(dev_priv); |
| 1815 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1816 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1817 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1818 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1819 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1820 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1821 | /* Convert GT frequency to 50 HZ units */ |
| 1822 | min_gpu_freq = |
| 1823 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1824 | max_gpu_freq = |
| 1825 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1826 | } else { |
| 1827 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1828 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1829 | } |
| 1830 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1831 | 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] | 1832 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1833 | 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] | 1834 | ia_freq = gpu_freq; |
| 1835 | sandybridge_pcode_read(dev_priv, |
| 1836 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1837 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1838 | 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] | 1839 | intel_gpu_freq(dev_priv, (gpu_freq * |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1840 | (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1841 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1842 | ((ia_freq >> 0) & 0xff) * 100, |
| 1843 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1844 | } |
| 1845 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1846 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1847 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1848 | out: |
| 1849 | intel_runtime_pm_put(dev_priv); |
| 1850 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1851 | } |
| 1852 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1853 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1854 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1855 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1856 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1857 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1858 | int ret; |
| 1859 | |
| 1860 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1861 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1862 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1863 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1864 | if (opregion->header) |
| 1865 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1866 | |
| 1867 | mutex_unlock(&dev->struct_mutex); |
| 1868 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1869 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1870 | return 0; |
| 1871 | } |
| 1872 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1873 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1874 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1875 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1876 | |
| 1877 | if (opregion->vbt) |
| 1878 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1879 | |
| 1880 | return 0; |
| 1881 | } |
| 1882 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1883 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1884 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1885 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1886 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1887 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1888 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1889 | int ret; |
| 1890 | |
| 1891 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1892 | if (ret) |
| 1893 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1894 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1895 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1896 | if (dev_priv->fbdev) { |
| 1897 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1898 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1899 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1900 | fbdev_fb->base.width, |
| 1901 | fbdev_fb->base.height, |
| 1902 | fbdev_fb->base.depth, |
| 1903 | fbdev_fb->base.bits_per_pixel, |
| 1904 | fbdev_fb->base.modifier[0], |
| 1905 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1906 | describe_obj(m, fbdev_fb->obj); |
| 1907 | seq_putc(m, '\n'); |
| 1908 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1909 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1910 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1911 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1912 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1913 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1914 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1915 | continue; |
| 1916 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1917 | 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] | 1918 | fb->base.width, |
| 1919 | fb->base.height, |
| 1920 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1921 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1922 | fb->base.modifier[0], |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1923 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1924 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1925 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1926 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1927 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1928 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1929 | |
| 1930 | return 0; |
| 1931 | } |
| 1932 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1933 | 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] | 1934 | { |
| 1935 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1936 | ring->space, ring->head, ring->tail, |
| 1937 | ring->last_retired_head); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1938 | } |
| 1939 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1940 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1941 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1942 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1943 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1944 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1945 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1946 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1947 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1948 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1949 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1950 | if (ret) |
| 1951 | return ret; |
| 1952 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1953 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1954 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1955 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1956 | struct task_struct *task; |
| 1957 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1958 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1959 | if (task) { |
| 1960 | seq_printf(m, "(%s [%d]) ", |
| 1961 | task->comm, task->pid); |
| 1962 | put_task_struct(task); |
| 1963 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1964 | } else if (IS_ERR(ctx->file_priv)) { |
| 1965 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1966 | } else { |
| 1967 | seq_puts(m, "(kernel) "); |
| 1968 | } |
| 1969 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1970 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1971 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1972 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1973 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1974 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 1975 | |
| 1976 | seq_printf(m, "%s: ", engine->name); |
| 1977 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 1978 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1979 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1980 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1981 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1982 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1983 | } |
| 1984 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1985 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1986 | } |
| 1987 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1988 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1989 | |
| 1990 | return 0; |
| 1991 | } |
| 1992 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1993 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1994 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1995 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1996 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1997 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1998 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1999 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2000 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2001 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2002 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2003 | if (!vma) { |
| 2004 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2005 | return; |
| 2006 | } |
| 2007 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2008 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 2009 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 2010 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2011 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2012 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2013 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2014 | return; |
| 2015 | } |
| 2016 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2017 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 2018 | if (page) { |
| 2019 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2020 | |
| 2021 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2022 | seq_printf(m, |
| 2023 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2024 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2025 | reg_state[j], reg_state[j + 1], |
| 2026 | reg_state[j + 2], reg_state[j + 3]); |
| 2027 | } |
| 2028 | kunmap_atomic(reg_state); |
| 2029 | } |
| 2030 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2031 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2032 | seq_putc(m, '\n'); |
| 2033 | } |
| 2034 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2035 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2036 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2037 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2038 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2039 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2040 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2041 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2042 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2043 | |
| 2044 | if (!i915.enable_execlists) { |
| 2045 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2046 | return 0; |
| 2047 | } |
| 2048 | |
| 2049 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2050 | if (ret) |
| 2051 | return ret; |
| 2052 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2053 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2054 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2055 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2056 | |
| 2057 | mutex_unlock(&dev->struct_mutex); |
| 2058 | |
| 2059 | return 0; |
| 2060 | } |
| 2061 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2062 | static const char *swizzle_string(unsigned swizzle) |
| 2063 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2064 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2065 | case I915_BIT_6_SWIZZLE_NONE: |
| 2066 | return "none"; |
| 2067 | case I915_BIT_6_SWIZZLE_9: |
| 2068 | return "bit9"; |
| 2069 | case I915_BIT_6_SWIZZLE_9_10: |
| 2070 | return "bit9/bit10"; |
| 2071 | case I915_BIT_6_SWIZZLE_9_11: |
| 2072 | return "bit9/bit11"; |
| 2073 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2074 | return "bit9/bit10/bit11"; |
| 2075 | case I915_BIT_6_SWIZZLE_9_17: |
| 2076 | return "bit9/bit17"; |
| 2077 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2078 | return "bit9/bit10/bit17"; |
| 2079 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2080 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2081 | } |
| 2082 | |
| 2083 | return "bug"; |
| 2084 | } |
| 2085 | |
| 2086 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2087 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2088 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2089 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2090 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2091 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2092 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2093 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2094 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2095 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2096 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2097 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2098 | seq_printf(m, "DDC = 0x%08x\n", |
| 2099 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2100 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2101 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2102 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2103 | I915_READ16(C0DRB3)); |
| 2104 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2105 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2106 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2107 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2108 | I915_READ(MAD_DIMM_C0)); |
| 2109 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2110 | I915_READ(MAD_DIMM_C1)); |
| 2111 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2112 | I915_READ(MAD_DIMM_C2)); |
| 2113 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2114 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2115 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2116 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2117 | I915_READ(GAMTARBMODE)); |
| 2118 | else |
| 2119 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2120 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2121 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2122 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2123 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2124 | |
| 2125 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2126 | seq_puts(m, "L-shaped memory detected\n"); |
| 2127 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2128 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2129 | |
| 2130 | return 0; |
| 2131 | } |
| 2132 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2133 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2134 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2135 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2136 | struct seq_file *m = data; |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2137 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2138 | |
| 2139 | if (!ppgtt) { |
| 2140 | seq_printf(m, " no ppgtt for context %d\n", |
| 2141 | ctx->user_handle); |
| 2142 | return 0; |
| 2143 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2144 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2145 | if (i915_gem_context_is_default(ctx)) |
| 2146 | seq_puts(m, " default context:\n"); |
| 2147 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2148 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2149 | ppgtt->debug_dump(ppgtt, m); |
| 2150 | |
| 2151 | return 0; |
| 2152 | } |
| 2153 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2154 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2155 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2156 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2157 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2158 | struct intel_engine_cs *engine; |
| 2159 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2160 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2161 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2162 | if (!ppgtt) |
| 2163 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2164 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2165 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2166 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2167 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2168 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2169 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2170 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2171 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2172 | } |
| 2173 | } |
| 2174 | } |
| 2175 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2176 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2177 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2178 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2179 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2180 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2181 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2182 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2183 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2184 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2185 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2186 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2187 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2188 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2189 | I915_READ(RING_MODE_GEN7(engine))); |
| 2190 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2191 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2192 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2193 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2194 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2195 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2196 | } |
| 2197 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2198 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2199 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2200 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2201 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd.base.ggtt_offset); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2202 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2203 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2204 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2205 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2206 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2207 | } |
| 2208 | |
| 2209 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2210 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2211 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2212 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2213 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2214 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2215 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2216 | mutex_lock(&dev->filelist_mutex); |
| 2217 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2218 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2219 | goto out_unlock; |
| 2220 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2221 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2222 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2223 | if (INTEL_GEN(dev_priv) >= 8) |
| 2224 | gen8_ppgtt_info(m, dev_priv); |
| 2225 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2226 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2227 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2228 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2229 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2230 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2231 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2232 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2233 | if (!task) { |
| 2234 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2235 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2236 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2237 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2238 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2239 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2240 | (void *)(unsigned long)m); |
| 2241 | } |
| 2242 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2243 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2244 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2245 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2246 | out_unlock: |
| 2247 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2248 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2249 | } |
| 2250 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2251 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2252 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2253 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2254 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2255 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2256 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2257 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2258 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2259 | |
| 2260 | return count; |
| 2261 | } |
| 2262 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2263 | static const char *rps_power_to_str(unsigned int power) |
| 2264 | { |
| 2265 | static const char * const strings[] = { |
| 2266 | [LOW_POWER] = "low power", |
| 2267 | [BETWEEN] = "mixed", |
| 2268 | [HIGH_POWER] = "high power", |
| 2269 | }; |
| 2270 | |
| 2271 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2272 | return "unknown"; |
| 2273 | |
| 2274 | return strings[power]; |
| 2275 | } |
| 2276 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2277 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2278 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2279 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2280 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2281 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2282 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2283 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2284 | seq_printf(m, "GPU busy? %s [%d requests]\n", |
| 2285 | yesno(dev_priv->gt.awake), dev_priv->gt.active_requests); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2286 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2287 | seq_printf(m, "Frequency requested %d\n", |
| 2288 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 2289 | seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2290 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2291 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2292 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2293 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2294 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
| 2295 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq), |
| 2296 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
| 2297 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2298 | |
| 2299 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2300 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2301 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2302 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2303 | struct task_struct *task; |
| 2304 | |
| 2305 | rcu_read_lock(); |
| 2306 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2307 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2308 | task ? task->comm : "<unknown>", |
| 2309 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2310 | file_priv->rps.boosts, |
| 2311 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2312 | rcu_read_unlock(); |
| 2313 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2314 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2315 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2316 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2317 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2318 | if (INTEL_GEN(dev_priv) >= 6 && |
| 2319 | dev_priv->rps.enabled && |
Chris Wilson | 28176ef | 2016-10-28 13:58:56 +0100 | [diff] [blame] | 2320 | dev_priv->gt.active_requests) { |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2321 | u32 rpup, rpupei; |
| 2322 | u32 rpdown, rpdownei; |
| 2323 | |
| 2324 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2325 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2326 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2327 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2328 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2329 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2330 | |
| 2331 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
| 2332 | rps_power_to_str(dev_priv->rps.power)); |
| 2333 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
| 2334 | 100 * rpup / rpupei, |
| 2335 | dev_priv->rps.up_threshold); |
| 2336 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
| 2337 | 100 * rpdown / rpdownei, |
| 2338 | dev_priv->rps.down_threshold); |
| 2339 | } else { |
| 2340 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2341 | } |
| 2342 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2343 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2344 | } |
| 2345 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2346 | static int i915_llc(struct seq_file *m, void *data) |
| 2347 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2348 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2349 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2350 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2351 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2352 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2353 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2354 | |
| 2355 | return 0; |
| 2356 | } |
| 2357 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2358 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2359 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2360 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2361 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
| 2362 | u32 tmp, i; |
| 2363 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2364 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2365 | return 0; |
| 2366 | |
| 2367 | seq_printf(m, "GuC firmware status:\n"); |
| 2368 | seq_printf(m, "\tpath: %s\n", |
| 2369 | guc_fw->guc_fw_path); |
| 2370 | seq_printf(m, "\tfetch: %s\n", |
| 2371 | intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status)); |
| 2372 | seq_printf(m, "\tload: %s\n", |
| 2373 | intel_guc_fw_status_repr(guc_fw->guc_fw_load_status)); |
| 2374 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2375 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
| 2376 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2377 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2378 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2379 | guc_fw->header_offset, guc_fw->header_size); |
| 2380 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2381 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2382 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2383 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2384 | |
| 2385 | tmp = I915_READ(GUC_STATUS); |
| 2386 | |
| 2387 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2388 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2389 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2390 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2391 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2392 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2393 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2394 | seq_puts(m, "\nScratch registers:\n"); |
| 2395 | for (i = 0; i < 16; i++) |
| 2396 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2397 | |
| 2398 | return 0; |
| 2399 | } |
| 2400 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2401 | static void i915_guc_log_info(struct seq_file *m, |
| 2402 | struct drm_i915_private *dev_priv) |
| 2403 | { |
| 2404 | struct intel_guc *guc = &dev_priv->guc; |
| 2405 | |
| 2406 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2407 | |
| 2408 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2409 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2410 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2411 | |
| 2412 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2413 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2414 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2415 | |
| 2416 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2417 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2418 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2419 | |
| 2420 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2421 | guc->log.flush_interrupt_count); |
| 2422 | |
| 2423 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2424 | guc->log.capture_miss_count); |
| 2425 | } |
| 2426 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2427 | static void i915_guc_client_info(struct seq_file *m, |
| 2428 | struct drm_i915_private *dev_priv, |
| 2429 | struct i915_guc_client *client) |
| 2430 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2431 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2432 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2433 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2434 | |
| 2435 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2436 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2437 | seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", |
| 2438 | client->doorbell_id, client->doorbell_offset, client->cookie); |
| 2439 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2440 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2441 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2442 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2443 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2444 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2445 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2446 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2447 | u64 submissions = client->submissions[id]; |
| 2448 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2449 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2450 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2451 | } |
| 2452 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2453 | } |
| 2454 | |
| 2455 | static int i915_guc_info(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); |
| 2458 | struct drm_device *dev = &dev_priv->drm; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2459 | struct intel_guc guc; |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 2460 | struct i915_guc_client client = {}; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2461 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2462 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2463 | u64 total = 0; |
| 2464 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2465 | if (!HAS_GUC_SCHED(dev_priv)) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2466 | return 0; |
| 2467 | |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2468 | if (mutex_lock_interruptible(&dev->struct_mutex)) |
| 2469 | return 0; |
| 2470 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2471 | /* Take a local copy of the GuC data, so we can dump it at leisure */ |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2472 | guc = dev_priv->guc; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2473 | if (guc.execbuf_client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2474 | client = *guc.execbuf_client; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2475 | |
| 2476 | mutex_unlock(&dev->struct_mutex); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2477 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2478 | seq_printf(m, "Doorbell map:\n"); |
| 2479 | seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc.doorbell_bitmap); |
| 2480 | seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc.db_cacheline); |
| 2481 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2482 | seq_printf(m, "GuC total action count: %llu\n", guc.action_count); |
| 2483 | seq_printf(m, "GuC action failure count: %u\n", guc.action_fail); |
| 2484 | seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd); |
| 2485 | seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status); |
| 2486 | seq_printf(m, "GuC last action error code: %d\n", guc.action_err); |
| 2487 | |
| 2488 | seq_printf(m, "\nGuC submissions:\n"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2489 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2490 | u64 submissions = guc.submissions[id]; |
| 2491 | total += submissions; |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2492 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2493 | engine->name, submissions, guc.last_seqno[id]); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2494 | } |
| 2495 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2496 | |
| 2497 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client); |
| 2498 | i915_guc_client_info(m, dev_priv, &client); |
| 2499 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2500 | i915_guc_log_info(m, dev_priv); |
| 2501 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2502 | /* Add more as required ... */ |
| 2503 | |
| 2504 | return 0; |
| 2505 | } |
| 2506 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2507 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2508 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2509 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2510 | struct drm_i915_gem_object *obj; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2511 | int i = 0, pg; |
| 2512 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2513 | if (!dev_priv->guc.log.vma) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2514 | return 0; |
| 2515 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2516 | obj = dev_priv->guc.log.vma->obj; |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2517 | for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) { |
| 2518 | u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg)); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2519 | |
| 2520 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2521 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2522 | *(log + i), *(log + i + 1), |
| 2523 | *(log + i + 2), *(log + i + 3)); |
| 2524 | |
| 2525 | kunmap_atomic(log); |
| 2526 | } |
| 2527 | |
| 2528 | seq_putc(m, '\n'); |
| 2529 | |
| 2530 | return 0; |
| 2531 | } |
| 2532 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2533 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2534 | { |
| 2535 | struct drm_device *dev = data; |
| 2536 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2537 | |
| 2538 | if (!dev_priv->guc.log.vma) |
| 2539 | return -EINVAL; |
| 2540 | |
| 2541 | *val = i915.guc_log_level; |
| 2542 | |
| 2543 | return 0; |
| 2544 | } |
| 2545 | |
| 2546 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2547 | { |
| 2548 | struct drm_device *dev = data; |
| 2549 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2550 | int ret; |
| 2551 | |
| 2552 | if (!dev_priv->guc.log.vma) |
| 2553 | return -EINVAL; |
| 2554 | |
| 2555 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2556 | if (ret) |
| 2557 | return ret; |
| 2558 | |
| 2559 | intel_runtime_pm_get(dev_priv); |
| 2560 | ret = i915_guc_log_control(dev_priv, val); |
| 2561 | intel_runtime_pm_put(dev_priv); |
| 2562 | |
| 2563 | mutex_unlock(&dev->struct_mutex); |
| 2564 | return ret; |
| 2565 | } |
| 2566 | |
| 2567 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2568 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2569 | "%lld\n"); |
| 2570 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2571 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2572 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2573 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2574 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2575 | u32 stat[3]; |
| 2576 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2577 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2578 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2579 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2580 | seq_puts(m, "PSR not supported\n"); |
| 2581 | return 0; |
| 2582 | } |
| 2583 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2584 | intel_runtime_pm_get(dev_priv); |
| 2585 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2586 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2587 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2588 | seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok)); |
Daniel Vetter | 2807cf6 | 2014-07-11 10:30:11 -0700 | [diff] [blame] | 2589 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2590 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2591 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2592 | dev_priv->psr.busy_frontbuffer_bits); |
| 2593 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2594 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2595 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2596 | if (HAS_DDI(dev_priv)) |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2597 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2598 | else { |
| 2599 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2600 | enum transcoder cpu_transcoder = |
| 2601 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2602 | enum intel_display_power_domain power_domain; |
| 2603 | |
| 2604 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2605 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2606 | power_domain)) |
| 2607 | continue; |
| 2608 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2609 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2610 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2611 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2612 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2613 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2614 | |
| 2615 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2616 | } |
| 2617 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2618 | |
| 2619 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2620 | yesno(dev_priv->psr.link_standby)); |
| 2621 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2622 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2623 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2624 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2625 | for_each_pipe(dev_priv, pipe) { |
| 2626 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2627 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2628 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2629 | } |
| 2630 | seq_puts(m, "\n"); |
| 2631 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2632 | /* |
| 2633 | * VLV/CHV PSR has no kind of performance counter |
| 2634 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2635 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2636 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2637 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2638 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2639 | |
| 2640 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2641 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2642 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2643 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2644 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2645 | return 0; |
| 2646 | } |
| 2647 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2648 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2649 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2650 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2651 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2652 | struct intel_connector *connector; |
| 2653 | struct intel_dp *intel_dp = NULL; |
| 2654 | int ret; |
| 2655 | u8 crc[6]; |
| 2656 | |
| 2657 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2658 | for_each_intel_connector(dev, connector) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2659 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2660 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2661 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2662 | continue; |
| 2663 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2664 | crtc = connector->base.state->crtc; |
| 2665 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2666 | continue; |
| 2667 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2668 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2669 | continue; |
| 2670 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2671 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2672 | |
| 2673 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2674 | if (ret) |
| 2675 | goto out; |
| 2676 | |
| 2677 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2678 | crc[0], crc[1], crc[2], |
| 2679 | crc[3], crc[4], crc[5]); |
| 2680 | goto out; |
| 2681 | } |
| 2682 | ret = -ENODEV; |
| 2683 | out: |
| 2684 | drm_modeset_unlock_all(dev); |
| 2685 | return ret; |
| 2686 | } |
| 2687 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2688 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2689 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2690 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2691 | u64 power; |
| 2692 | u32 units; |
| 2693 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2694 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2695 | return -ENODEV; |
| 2696 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2697 | intel_runtime_pm_get(dev_priv); |
| 2698 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2699 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2700 | power = (power & 0x1f00) >> 8; |
| 2701 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2702 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2703 | power *= units; |
| 2704 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2705 | intel_runtime_pm_put(dev_priv); |
| 2706 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2707 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2708 | |
| 2709 | return 0; |
| 2710 | } |
| 2711 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2712 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2713 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2714 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2715 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2716 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2717 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2718 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2719 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2720 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2721 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2722 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2723 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2724 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2725 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2726 | #else |
| 2727 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2728 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2729 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2730 | pci_power_name(pdev->current_state), |
| 2731 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2732 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2733 | return 0; |
| 2734 | } |
| 2735 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2736 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2737 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2738 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2739 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2740 | int i; |
| 2741 | |
| 2742 | mutex_lock(&power_domains->lock); |
| 2743 | |
| 2744 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2745 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2746 | struct i915_power_well *power_well; |
| 2747 | enum intel_display_power_domain power_domain; |
| 2748 | |
| 2749 | power_well = &power_domains->power_wells[i]; |
| 2750 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2751 | power_well->count); |
| 2752 | |
| 2753 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2754 | power_domain++) { |
| 2755 | if (!(BIT(power_domain) & power_well->domains)) |
| 2756 | continue; |
| 2757 | |
| 2758 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2759 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2760 | power_domains->domain_use_count[power_domain]); |
| 2761 | } |
| 2762 | } |
| 2763 | |
| 2764 | mutex_unlock(&power_domains->lock); |
| 2765 | |
| 2766 | return 0; |
| 2767 | } |
| 2768 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2769 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2770 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2771 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2772 | struct intel_csr *csr; |
| 2773 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2774 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2775 | seq_puts(m, "not supported\n"); |
| 2776 | return 0; |
| 2777 | } |
| 2778 | |
| 2779 | csr = &dev_priv->csr; |
| 2780 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2781 | intel_runtime_pm_get(dev_priv); |
| 2782 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2783 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2784 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2785 | |
| 2786 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2787 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2788 | |
| 2789 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2790 | CSR_VERSION_MINOR(csr->version)); |
| 2791 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2792 | if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2793 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2794 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2795 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2796 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2797 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2798 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2799 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2800 | } |
| 2801 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2802 | out: |
| 2803 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2804 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2805 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2806 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2807 | intel_runtime_pm_put(dev_priv); |
| 2808 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2809 | return 0; |
| 2810 | } |
| 2811 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2812 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2813 | struct drm_display_mode *mode) |
| 2814 | { |
| 2815 | int i; |
| 2816 | |
| 2817 | for (i = 0; i < tabs; i++) |
| 2818 | seq_putc(m, '\t'); |
| 2819 | |
| 2820 | seq_printf(m, "id %d:\"%s\" freq %d clock %d hdisp %d hss %d hse %d htot %d vdisp %d vss %d vse %d vtot %d type 0x%x flags 0x%x\n", |
| 2821 | mode->base.id, mode->name, |
| 2822 | mode->vrefresh, mode->clock, |
| 2823 | mode->hdisplay, mode->hsync_start, |
| 2824 | mode->hsync_end, mode->htotal, |
| 2825 | mode->vdisplay, mode->vsync_start, |
| 2826 | mode->vsync_end, mode->vtotal, |
| 2827 | mode->type, mode->flags); |
| 2828 | } |
| 2829 | |
| 2830 | static void intel_encoder_info(struct seq_file *m, |
| 2831 | struct intel_crtc *intel_crtc, |
| 2832 | struct intel_encoder *intel_encoder) |
| 2833 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2834 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2835 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2836 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2837 | struct intel_connector *intel_connector; |
| 2838 | struct drm_encoder *encoder; |
| 2839 | |
| 2840 | encoder = &intel_encoder->base; |
| 2841 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2842 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2843 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2844 | struct drm_connector *connector = &intel_connector->base; |
| 2845 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2846 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2847 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2848 | drm_get_connector_status_name(connector->status)); |
| 2849 | if (connector->status == connector_status_connected) { |
| 2850 | struct drm_display_mode *mode = &crtc->mode; |
| 2851 | seq_printf(m, ", mode:\n"); |
| 2852 | intel_seq_print_mode(m, 2, mode); |
| 2853 | } else { |
| 2854 | seq_putc(m, '\n'); |
| 2855 | } |
| 2856 | } |
| 2857 | } |
| 2858 | |
| 2859 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2860 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2861 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2862 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2863 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2864 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2865 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2866 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2867 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2868 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2869 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2870 | fb->base.id, plane_state->src_x >> 16, |
| 2871 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2872 | else |
| 2873 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2874 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2875 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2876 | } |
| 2877 | |
| 2878 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2879 | { |
| 2880 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2881 | |
| 2882 | seq_printf(m, "\tfixed mode:\n"); |
| 2883 | intel_seq_print_mode(m, 2, mode); |
| 2884 | } |
| 2885 | |
| 2886 | static void intel_dp_info(struct seq_file *m, |
| 2887 | struct intel_connector *intel_connector) |
| 2888 | { |
| 2889 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2890 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2891 | |
| 2892 | 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] | 2893 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2894 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2895 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2896 | |
| 2897 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2898 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2899 | } |
| 2900 | |
| 2901 | static void intel_hdmi_info(struct seq_file *m, |
| 2902 | struct intel_connector *intel_connector) |
| 2903 | { |
| 2904 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2905 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2906 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2907 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2908 | } |
| 2909 | |
| 2910 | static void intel_lvds_info(struct seq_file *m, |
| 2911 | struct intel_connector *intel_connector) |
| 2912 | { |
| 2913 | intel_panel_info(m, &intel_connector->panel); |
| 2914 | } |
| 2915 | |
| 2916 | static void intel_connector_info(struct seq_file *m, |
| 2917 | struct drm_connector *connector) |
| 2918 | { |
| 2919 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2920 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2921 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2922 | |
| 2923 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2924 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2925 | drm_get_connector_status_name(connector->status)); |
| 2926 | if (connector->status == connector_status_connected) { |
| 2927 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2928 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2929 | connector->display_info.width_mm, |
| 2930 | connector->display_info.height_mm); |
| 2931 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2932 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2933 | seq_printf(m, "\tCEA rev: %d\n", |
| 2934 | connector->display_info.cea_rev); |
| 2935 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2936 | |
| 2937 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2938 | return; |
| 2939 | |
| 2940 | switch (connector->connector_type) { |
| 2941 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2942 | case DRM_MODE_CONNECTOR_eDP: |
Dhinakaran Pandiyan | be754b1 | 2016-09-28 23:55:04 -0700 | [diff] [blame] | 2943 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2944 | break; |
| 2945 | case DRM_MODE_CONNECTOR_LVDS: |
| 2946 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2947 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2948 | break; |
| 2949 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2950 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 2951 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 2952 | intel_hdmi_info(m, intel_connector); |
| 2953 | break; |
| 2954 | default: |
| 2955 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2956 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2957 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2958 | seq_printf(m, "\tmodes:\n"); |
| 2959 | list_for_each_entry(mode, &connector->modes, head) |
| 2960 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2961 | } |
| 2962 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2963 | static bool cursor_active(struct drm_i915_private *dev_priv, int pipe) |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2964 | { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2965 | u32 state; |
| 2966 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2967 | if (IS_845G(dev_priv) || IS_I865G(dev_priv)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 2968 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2969 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2970 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2971 | |
| 2972 | return state; |
| 2973 | } |
| 2974 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2975 | static bool cursor_position(struct drm_i915_private *dev_priv, |
| 2976 | int pipe, int *x, int *y) |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2977 | { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2978 | u32 pos; |
| 2979 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2980 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2981 | |
| 2982 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2983 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2984 | *x = -*x; |
| 2985 | |
| 2986 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2987 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2988 | *y = -*y; |
| 2989 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2990 | return cursor_active(dev_priv, pipe); |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2991 | } |
| 2992 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2993 | static const char *plane_type(enum drm_plane_type type) |
| 2994 | { |
| 2995 | switch (type) { |
| 2996 | case DRM_PLANE_TYPE_OVERLAY: |
| 2997 | return "OVL"; |
| 2998 | case DRM_PLANE_TYPE_PRIMARY: |
| 2999 | return "PRI"; |
| 3000 | case DRM_PLANE_TYPE_CURSOR: |
| 3001 | return "CUR"; |
| 3002 | /* |
| 3003 | * Deliberately omitting default: to generate compiler warnings |
| 3004 | * when a new drm_plane_type gets added. |
| 3005 | */ |
| 3006 | } |
| 3007 | |
| 3008 | return "unknown"; |
| 3009 | } |
| 3010 | |
| 3011 | static const char *plane_rotation(unsigned int rotation) |
| 3012 | { |
| 3013 | static char buf[48]; |
| 3014 | /* |
| 3015 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3016 | * will print them all to visualize if the values are misused |
| 3017 | */ |
| 3018 | snprintf(buf, sizeof(buf), |
| 3019 | "%s%s%s%s%s%s(0x%08x)", |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 3020 | (rotation & DRM_ROTATE_0) ? "0 " : "", |
| 3021 | (rotation & DRM_ROTATE_90) ? "90 " : "", |
| 3022 | (rotation & DRM_ROTATE_180) ? "180 " : "", |
| 3023 | (rotation & DRM_ROTATE_270) ? "270 " : "", |
| 3024 | (rotation & DRM_REFLECT_X) ? "FLIPX " : "", |
| 3025 | (rotation & DRM_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3026 | rotation); |
| 3027 | |
| 3028 | return buf; |
| 3029 | } |
| 3030 | |
| 3031 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3032 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3033 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3034 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3035 | struct intel_plane *intel_plane; |
| 3036 | |
| 3037 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3038 | struct drm_plane_state *state; |
| 3039 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3040 | struct drm_format_name_buf format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3041 | |
| 3042 | if (!plane->state) { |
| 3043 | seq_puts(m, "plane->state is NULL!\n"); |
| 3044 | continue; |
| 3045 | } |
| 3046 | |
| 3047 | state = plane->state; |
| 3048 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3049 | if (state->fb) { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3050 | drm_get_format_name(state->fb->pixel_format, &format_name); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3051 | } else { |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3052 | sprintf(format_name.str, "N/A"); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3053 | } |
| 3054 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3055 | 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", |
| 3056 | plane->base.id, |
| 3057 | plane_type(intel_plane->base.type), |
| 3058 | state->crtc_x, state->crtc_y, |
| 3059 | state->crtc_w, state->crtc_h, |
| 3060 | (state->src_x >> 16), |
| 3061 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3062 | (state->src_y >> 16), |
| 3063 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3064 | (state->src_w >> 16), |
| 3065 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3066 | (state->src_h >> 16), |
| 3067 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | b3c11ac | 2016-11-12 01:12:56 +0000 | [diff] [blame] | 3068 | format_name.str, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3069 | plane_rotation(state->rotation)); |
| 3070 | } |
| 3071 | } |
| 3072 | |
| 3073 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3074 | { |
| 3075 | struct intel_crtc_state *pipe_config; |
| 3076 | int num_scalers = intel_crtc->num_scalers; |
| 3077 | int i; |
| 3078 | |
| 3079 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3080 | |
| 3081 | /* Not all platformas have a scaler */ |
| 3082 | if (num_scalers) { |
| 3083 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3084 | num_scalers, |
| 3085 | pipe_config->scaler_state.scaler_users, |
| 3086 | pipe_config->scaler_state.scaler_id); |
| 3087 | |
A.Sunil Kamath | 5841591 | 2016-11-20 23:20:26 +0530 | [diff] [blame] | 3088 | for (i = 0; i < num_scalers; i++) { |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3089 | struct intel_scaler *sc = |
| 3090 | &pipe_config->scaler_state.scalers[i]; |
| 3091 | |
| 3092 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3093 | i, yesno(sc->in_use), sc->mode); |
| 3094 | } |
| 3095 | seq_puts(m, "\n"); |
| 3096 | } else { |
| 3097 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3098 | } |
| 3099 | } |
| 3100 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3101 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3102 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3103 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3104 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3105 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3106 | struct drm_connector *connector; |
| 3107 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3108 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3109 | drm_modeset_lock_all(dev); |
| 3110 | seq_printf(m, "CRTC info\n"); |
| 3111 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3112 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3113 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3114 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3115 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3116 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3117 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3118 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3119 | seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n", |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3120 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3121 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3122 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3123 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3124 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3125 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3126 | intel_crtc_info(m, crtc); |
| 3127 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3128 | active = cursor_position(dev_priv, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3129 | seq_printf(m, "\tcursor visible? %s, position (%d, %d), size %dx%d, addr 0x%08x, active? %s\n", |
Chris Wilson | 4b0e333 | 2014-05-30 16:35:26 +0300 | [diff] [blame] | 3130 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3131 | x, y, crtc->base.cursor->state->crtc_w, |
| 3132 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3133 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3134 | intel_scaler_info(m, crtc); |
| 3135 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3136 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3137 | |
| 3138 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3139 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3140 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3141 | } |
| 3142 | |
| 3143 | seq_printf(m, "\n"); |
| 3144 | seq_printf(m, "Connector info\n"); |
| 3145 | seq_printf(m, "--------------\n"); |
| 3146 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3147 | intel_connector_info(m, connector); |
| 3148 | } |
| 3149 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3150 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3151 | |
| 3152 | return 0; |
| 3153 | } |
| 3154 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3155 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3156 | { |
| 3157 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3158 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3159 | enum intel_engine_id id; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3160 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3161 | intel_runtime_pm_get(dev_priv); |
| 3162 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3163 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3164 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 3165 | struct drm_i915_gem_request *rq; |
| 3166 | struct rb_node *rb; |
| 3167 | u64 addr; |
| 3168 | |
| 3169 | seq_printf(m, "%s\n", engine->name); |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame^] | 3170 | seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms]\n", |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3171 | intel_engine_get_seqno(engine), |
Chris Wilson | cb399ea | 2016-11-01 10:03:16 +0000 | [diff] [blame] | 3172 | intel_engine_last_submit(engine), |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3173 | engine->hangcheck.seqno, |
Mika Kuoppala | 3fe3b03 | 2016-11-18 15:09:04 +0200 | [diff] [blame^] | 3174 | jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp)); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3175 | |
| 3176 | rcu_read_lock(); |
| 3177 | |
| 3178 | seq_printf(m, "\tRequests:\n"); |
| 3179 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3180 | rq = list_first_entry(&engine->timeline->requests, |
| 3181 | struct drm_i915_gem_request, link); |
| 3182 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3183 | print_request(m, rq, "\t\tfirst "); |
| 3184 | |
Chris Wilson | 73cb970 | 2016-10-28 13:58:46 +0100 | [diff] [blame] | 3185 | rq = list_last_entry(&engine->timeline->requests, |
| 3186 | struct drm_i915_gem_request, link); |
| 3187 | if (&rq->link != &engine->timeline->requests) |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3188 | print_request(m, rq, "\t\tlast "); |
| 3189 | |
| 3190 | rq = i915_gem_find_active_request(engine); |
| 3191 | if (rq) { |
| 3192 | print_request(m, rq, "\t\tactive "); |
| 3193 | seq_printf(m, |
| 3194 | "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n", |
| 3195 | rq->head, rq->postfix, rq->tail, |
| 3196 | rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, |
| 3197 | rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); |
| 3198 | } |
| 3199 | |
| 3200 | seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n", |
| 3201 | I915_READ(RING_START(engine->mmio_base)), |
| 3202 | rq ? i915_ggtt_offset(rq->ring->vma) : 0); |
| 3203 | seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n", |
| 3204 | I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR, |
| 3205 | rq ? rq->ring->head : 0); |
| 3206 | seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n", |
| 3207 | I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR, |
| 3208 | rq ? rq->ring->tail : 0); |
| 3209 | seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n", |
| 3210 | I915_READ(RING_CTL(engine->mmio_base)), |
| 3211 | I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : ""); |
| 3212 | |
| 3213 | rcu_read_unlock(); |
| 3214 | |
| 3215 | addr = intel_engine_get_active_head(engine); |
| 3216 | seq_printf(m, "\tACTHD: 0x%08x_%08x\n", |
| 3217 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3218 | addr = intel_engine_get_last_batch_head(engine); |
| 3219 | seq_printf(m, "\tBBADDR: 0x%08x_%08x\n", |
| 3220 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3221 | |
| 3222 | if (i915.enable_execlists) { |
| 3223 | u32 ptr, read, write; |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3224 | struct rb_node *rb; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3225 | |
| 3226 | seq_printf(m, "\tExeclist status: 0x%08x %08x\n", |
| 3227 | I915_READ(RING_EXECLIST_STATUS_LO(engine)), |
| 3228 | I915_READ(RING_EXECLIST_STATUS_HI(engine))); |
| 3229 | |
| 3230 | ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
| 3231 | read = GEN8_CSB_READ_PTR(ptr); |
| 3232 | write = GEN8_CSB_WRITE_PTR(ptr); |
| 3233 | seq_printf(m, "\tExeclist CSB read %d, write %d\n", |
| 3234 | read, write); |
| 3235 | if (read >= GEN8_CSB_ENTRIES) |
| 3236 | read = 0; |
| 3237 | if (write >= GEN8_CSB_ENTRIES) |
| 3238 | write = 0; |
| 3239 | if (read > write) |
| 3240 | write += GEN8_CSB_ENTRIES; |
| 3241 | while (read < write) { |
| 3242 | unsigned int idx = ++read % GEN8_CSB_ENTRIES; |
| 3243 | |
| 3244 | seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n", |
| 3245 | idx, |
| 3246 | I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)), |
| 3247 | I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx))); |
| 3248 | } |
| 3249 | |
| 3250 | rcu_read_lock(); |
| 3251 | rq = READ_ONCE(engine->execlist_port[0].request); |
| 3252 | if (rq) |
| 3253 | print_request(m, rq, "\t\tELSP[0] "); |
| 3254 | else |
| 3255 | seq_printf(m, "\t\tELSP[0] idle\n"); |
| 3256 | rq = READ_ONCE(engine->execlist_port[1].request); |
| 3257 | if (rq) |
| 3258 | print_request(m, rq, "\t\tELSP[1] "); |
| 3259 | else |
| 3260 | seq_printf(m, "\t\tELSP[1] idle\n"); |
| 3261 | rcu_read_unlock(); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3262 | |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3263 | spin_lock_irq(&engine->timeline->lock); |
Chris Wilson | 20311bd | 2016-11-14 20:41:03 +0000 | [diff] [blame] | 3264 | for (rb = engine->execlist_first; rb; rb = rb_next(rb)) { |
| 3265 | rq = rb_entry(rb, typeof(*rq), priotree.node); |
Chris Wilson | c8247c0 | 2016-10-27 01:03:43 +0100 | [diff] [blame] | 3266 | print_request(m, rq, "\t\tQ "); |
| 3267 | } |
Chris Wilson | 663f71e | 2016-11-14 20:41:00 +0000 | [diff] [blame] | 3268 | spin_unlock_irq(&engine->timeline->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3269 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 3270 | seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n", |
| 3271 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 3272 | seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n", |
| 3273 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 3274 | seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n", |
| 3275 | I915_READ(RING_PP_DIR_DCLV(engine))); |
| 3276 | } |
| 3277 | |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 3278 | spin_lock_irq(&b->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3279 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 3280 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 3281 | |
| 3282 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 3283 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 3284 | } |
Chris Wilson | f6168e3 | 2016-10-28 13:58:55 +0100 | [diff] [blame] | 3285 | spin_unlock_irq(&b->lock); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3286 | |
| 3287 | seq_puts(m, "\n"); |
| 3288 | } |
| 3289 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3290 | intel_runtime_pm_put(dev_priv); |
| 3291 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3292 | return 0; |
| 3293 | } |
| 3294 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3295 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3296 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3297 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3298 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3299 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3300 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3301 | enum intel_engine_id id; |
| 3302 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3303 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3304 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3305 | seq_puts(m, "Semaphores are disabled\n"); |
| 3306 | return 0; |
| 3307 | } |
| 3308 | |
| 3309 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3310 | if (ret) |
| 3311 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3312 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3313 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3314 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3315 | struct page *page; |
| 3316 | uint64_t *seqno; |
| 3317 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3318 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3319 | |
| 3320 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3321 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3322 | uint64_t offset; |
| 3323 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3324 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3325 | |
| 3326 | seq_puts(m, " Last signal:"); |
| 3327 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3328 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3329 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3330 | seqno[offset], offset * 8); |
| 3331 | } |
| 3332 | seq_putc(m, '\n'); |
| 3333 | |
| 3334 | seq_puts(m, " Last wait: "); |
| 3335 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3336 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3337 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3338 | seqno[offset], offset * 8); |
| 3339 | } |
| 3340 | seq_putc(m, '\n'); |
| 3341 | |
| 3342 | } |
| 3343 | kunmap_atomic(seqno); |
| 3344 | } else { |
| 3345 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3346 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3347 | for (j = 0; j < num_rings; j++) |
| 3348 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3349 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3350 | seq_putc(m, '\n'); |
| 3351 | } |
| 3352 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3353 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3354 | mutex_unlock(&dev->struct_mutex); |
| 3355 | return 0; |
| 3356 | } |
| 3357 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3358 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3359 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3360 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3361 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3362 | int i; |
| 3363 | |
| 3364 | drm_modeset_lock_all(dev); |
| 3365 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3366 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3367 | |
| 3368 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); |
Maarten Lankhorst | 2dd66ebd | 2016-03-14 09:27:52 +0100 | [diff] [blame] | 3369 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
| 3370 | pll->config.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3371 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3372 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 3373 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 3374 | pll->config.hw_state.dpll_md); |
| 3375 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 3376 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 3377 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3378 | } |
| 3379 | drm_modeset_unlock_all(dev); |
| 3380 | |
| 3381 | return 0; |
| 3382 | } |
| 3383 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3384 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3385 | { |
| 3386 | int i; |
| 3387 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3388 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3389 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3390 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3391 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3392 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3393 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3394 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3395 | if (ret) |
| 3396 | return ret; |
| 3397 | |
| 3398 | intel_runtime_pm_get(dev_priv); |
| 3399 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3400 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3401 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3402 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3403 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3404 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3405 | i915_reg_t addr; |
| 3406 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3407 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3408 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3409 | addr = workarounds->reg[i].addr; |
| 3410 | mask = workarounds->reg[i].mask; |
| 3411 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3412 | read = I915_READ(addr); |
| 3413 | ok = (value & mask) == (read & mask); |
| 3414 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n", |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3415 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3416 | } |
| 3417 | |
| 3418 | intel_runtime_pm_put(dev_priv); |
| 3419 | mutex_unlock(&dev->struct_mutex); |
| 3420 | |
| 3421 | return 0; |
| 3422 | } |
| 3423 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3424 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3425 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3426 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3427 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3428 | struct skl_ddb_allocation *ddb; |
| 3429 | struct skl_ddb_entry *entry; |
| 3430 | enum pipe pipe; |
| 3431 | int plane; |
| 3432 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3433 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3434 | return 0; |
| 3435 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3436 | drm_modeset_lock_all(dev); |
| 3437 | |
| 3438 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3439 | |
| 3440 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3441 | |
| 3442 | for_each_pipe(dev_priv, pipe) { |
| 3443 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3444 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3445 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3446 | entry = &ddb->plane[pipe][plane]; |
| 3447 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3448 | entry->start, entry->end, |
| 3449 | skl_ddb_entry_size(entry)); |
| 3450 | } |
| 3451 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3452 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3453 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3454 | entry->end, skl_ddb_entry_size(entry)); |
| 3455 | } |
| 3456 | |
| 3457 | drm_modeset_unlock_all(dev); |
| 3458 | |
| 3459 | return 0; |
| 3460 | } |
| 3461 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3462 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3463 | struct drm_device *dev, |
| 3464 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3465 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3466 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3467 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3468 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3469 | struct drm_connector *connector; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3470 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3471 | drm_for_each_connector(connector, dev) { |
| 3472 | if (connector->state->crtc != &intel_crtc->base) |
| 3473 | continue; |
| 3474 | |
| 3475 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3476 | } |
| 3477 | |
| 3478 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3479 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3480 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3481 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3482 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3483 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3484 | else |
| 3485 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3486 | |
| 3487 | seq_puts(m, "\n\n"); |
| 3488 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3489 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3490 | struct intel_panel *panel; |
| 3491 | |
| 3492 | mutex_lock(&drrs->mutex); |
| 3493 | /* DRRS Supported */ |
| 3494 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3495 | |
| 3496 | /* disable_drrs() will make drrs->dp NULL */ |
| 3497 | if (!drrs->dp) { |
| 3498 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3499 | mutex_unlock(&drrs->mutex); |
| 3500 | return; |
| 3501 | } |
| 3502 | |
| 3503 | panel = &drrs->dp->attached_connector->panel; |
| 3504 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3505 | drrs->busy_frontbuffer_bits); |
| 3506 | |
| 3507 | seq_puts(m, "\n\t\t"); |
| 3508 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3509 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3510 | vrefresh = panel->fixed_mode->vrefresh; |
| 3511 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3512 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3513 | vrefresh = panel->downclock_mode->vrefresh; |
| 3514 | } else { |
| 3515 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3516 | drrs->refresh_rate_type); |
| 3517 | mutex_unlock(&drrs->mutex); |
| 3518 | return; |
| 3519 | } |
| 3520 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3521 | |
| 3522 | seq_puts(m, "\n\t\t"); |
| 3523 | mutex_unlock(&drrs->mutex); |
| 3524 | } else { |
| 3525 | /* DRRS not supported. Print the VBT parameter*/ |
| 3526 | seq_puts(m, "\tDRRS Supported : No"); |
| 3527 | } |
| 3528 | seq_puts(m, "\n"); |
| 3529 | } |
| 3530 | |
| 3531 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3532 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3533 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3534 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3535 | struct intel_crtc *intel_crtc; |
| 3536 | int active_crtc_cnt = 0; |
| 3537 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3538 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3539 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3540 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3541 | active_crtc_cnt++; |
| 3542 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3543 | |
| 3544 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3545 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3546 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3547 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3548 | |
| 3549 | if (!active_crtc_cnt) |
| 3550 | seq_puts(m, "No active crtc found\n"); |
| 3551 | |
| 3552 | return 0; |
| 3553 | } |
| 3554 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3555 | struct pipe_crc_info { |
| 3556 | const char *name; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3557 | struct drm_i915_private *dev_priv; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3558 | enum pipe pipe; |
| 3559 | }; |
| 3560 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3561 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3562 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3563 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3564 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3565 | struct intel_encoder *intel_encoder; |
| 3566 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3567 | struct drm_connector *connector; |
| 3568 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3569 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3570 | drm_for_each_connector(connector, dev) { |
| 3571 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3572 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3573 | |
| 3574 | intel_encoder = intel_attached_encoder(connector); |
| 3575 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3576 | continue; |
| 3577 | |
| 3578 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3579 | if (!intel_dig_port->dp.can_mst) |
| 3580 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3581 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3582 | seq_printf(m, "MST Source Port %c\n", |
| 3583 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3584 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3585 | } |
| 3586 | drm_modeset_unlock_all(dev); |
| 3587 | return 0; |
| 3588 | } |
| 3589 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3590 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3591 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3592 | struct pipe_crc_info *info = inode->i_private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3593 | struct drm_i915_private *dev_priv = info->dev_priv; |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3594 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3595 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3596 | if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes) |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 3597 | return -ENODEV; |
| 3598 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3599 | spin_lock_irq(&pipe_crc->lock); |
| 3600 | |
| 3601 | if (pipe_crc->opened) { |
| 3602 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3603 | return -EBUSY; /* already open */ |
| 3604 | } |
| 3605 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3606 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3607 | filep->private_data = inode->i_private; |
| 3608 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3609 | spin_unlock_irq(&pipe_crc->lock); |
| 3610 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3611 | return 0; |
| 3612 | } |
| 3613 | |
| 3614 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 3615 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3616 | struct pipe_crc_info *info = inode->i_private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3617 | struct drm_i915_private *dev_priv = info->dev_priv; |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3618 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3619 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3620 | spin_lock_irq(&pipe_crc->lock); |
| 3621 | pipe_crc->opened = false; |
| 3622 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3623 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3624 | return 0; |
| 3625 | } |
| 3626 | |
| 3627 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 3628 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 3629 | /* account for \'0' */ |
| 3630 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 3631 | |
| 3632 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 3633 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3634 | assert_spin_locked(&pipe_crc->lock); |
| 3635 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3636 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3637 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3638 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3639 | static ssize_t |
| 3640 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 3641 | loff_t *pos) |
| 3642 | { |
| 3643 | struct pipe_crc_info *info = filep->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3644 | struct drm_i915_private *dev_priv = info->dev_priv; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3645 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3646 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3647 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3648 | ssize_t bytes_read; |
| 3649 | |
| 3650 | /* |
| 3651 | * Don't allow user space to provide buffers not big enough to hold |
| 3652 | * a line of data. |
| 3653 | */ |
| 3654 | if (count < PIPE_CRC_LINE_LEN) |
| 3655 | return -EINVAL; |
| 3656 | |
| 3657 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 3658 | return 0; |
| 3659 | |
| 3660 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3661 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3662 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3663 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3664 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3665 | if (filep->f_flags & O_NONBLOCK) { |
| 3666 | spin_unlock_irq(&pipe_crc->lock); |
| 3667 | return -EAGAIN; |
| 3668 | } |
| 3669 | |
| 3670 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 3671 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 3672 | if (ret) { |
| 3673 | spin_unlock_irq(&pipe_crc->lock); |
| 3674 | return ret; |
| 3675 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3676 | } |
| 3677 | |
| 3678 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3679 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3680 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3681 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3682 | while (n_entries > 0) { |
| 3683 | struct intel_pipe_crc_entry *entry = |
| 3684 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3685 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3686 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3687 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3688 | break; |
| 3689 | |
| 3690 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3691 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3692 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3693 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3694 | "%8u %8x %8x %8x %8x %8x\n", |
| 3695 | entry->frame, entry->crc[0], |
| 3696 | entry->crc[1], entry->crc[2], |
| 3697 | entry->crc[3], entry->crc[4]); |
| 3698 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3699 | spin_unlock_irq(&pipe_crc->lock); |
| 3700 | |
Rodrigo Vivi | 4e9121e | 2016-08-03 08:22:57 -0700 | [diff] [blame] | 3701 | if (copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN)) |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3702 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3703 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3704 | user_buf += PIPE_CRC_LINE_LEN; |
| 3705 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3706 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3707 | spin_lock_irq(&pipe_crc->lock); |
| 3708 | } |
| 3709 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3710 | spin_unlock_irq(&pipe_crc->lock); |
| 3711 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3712 | return bytes_read; |
| 3713 | } |
| 3714 | |
| 3715 | static const struct file_operations i915_pipe_crc_fops = { |
| 3716 | .owner = THIS_MODULE, |
| 3717 | .open = i915_pipe_crc_open, |
| 3718 | .read = i915_pipe_crc_read, |
| 3719 | .release = i915_pipe_crc_release, |
| 3720 | }; |
| 3721 | |
| 3722 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3723 | { |
| 3724 | .name = "i915_pipe_A_crc", |
| 3725 | .pipe = PIPE_A, |
| 3726 | }, |
| 3727 | { |
| 3728 | .name = "i915_pipe_B_crc", |
| 3729 | .pipe = PIPE_B, |
| 3730 | }, |
| 3731 | { |
| 3732 | .name = "i915_pipe_C_crc", |
| 3733 | .pipe = PIPE_C, |
| 3734 | }, |
| 3735 | }; |
| 3736 | |
| 3737 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3738 | enum pipe pipe) |
| 3739 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3740 | struct drm_i915_private *dev_priv = to_i915(minor->dev); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3741 | struct dentry *ent; |
| 3742 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3743 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3744 | info->dev_priv = dev_priv; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3745 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3746 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3747 | if (!ent) |
| 3748 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3749 | |
| 3750 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3751 | } |
| 3752 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3753 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3754 | "none", |
| 3755 | "plane1", |
| 3756 | "plane2", |
| 3757 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3758 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3759 | "TV", |
| 3760 | "DP-B", |
| 3761 | "DP-C", |
| 3762 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3763 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3764 | }; |
| 3765 | |
| 3766 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3767 | { |
| 3768 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3769 | return pipe_crc_sources[source]; |
| 3770 | } |
| 3771 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3772 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3773 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3774 | struct drm_i915_private *dev_priv = m->private; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3775 | int i; |
| 3776 | |
| 3777 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3778 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3779 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3780 | |
| 3781 | return 0; |
| 3782 | } |
| 3783 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3784 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3785 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3786 | return single_open(file, display_crc_ctl_show, inode->i_private); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3787 | } |
| 3788 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3789 | static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source, |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3790 | uint32_t *val) |
| 3791 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3792 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3793 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3794 | |
| 3795 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3796 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3797 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3798 | break; |
| 3799 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3800 | *val = 0; |
| 3801 | break; |
| 3802 | default: |
| 3803 | return -EINVAL; |
| 3804 | } |
| 3805 | |
| 3806 | return 0; |
| 3807 | } |
| 3808 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3809 | static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv, |
| 3810 | enum pipe pipe, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3811 | enum intel_pipe_crc_source *source) |
| 3812 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3813 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3814 | struct intel_encoder *encoder; |
| 3815 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3816 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3817 | int ret = 0; |
| 3818 | |
| 3819 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3820 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3821 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3822 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3823 | if (!encoder->base.crtc) |
| 3824 | continue; |
| 3825 | |
| 3826 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3827 | |
| 3828 | if (crtc->pipe != pipe) |
| 3829 | continue; |
| 3830 | |
| 3831 | switch (encoder->type) { |
| 3832 | case INTEL_OUTPUT_TVOUT: |
| 3833 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3834 | break; |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 3835 | case INTEL_OUTPUT_DP: |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3836 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3837 | dig_port = enc_to_dig_port(&encoder->base); |
| 3838 | switch (dig_port->port) { |
| 3839 | case PORT_B: |
| 3840 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3841 | break; |
| 3842 | case PORT_C: |
| 3843 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3844 | break; |
| 3845 | case PORT_D: |
| 3846 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3847 | break; |
| 3848 | default: |
| 3849 | WARN(1, "nonexisting DP port %c\n", |
| 3850 | port_name(dig_port->port)); |
| 3851 | break; |
| 3852 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3853 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3854 | default: |
| 3855 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3856 | } |
| 3857 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3858 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3859 | |
| 3860 | return ret; |
| 3861 | } |
| 3862 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3863 | static int vlv_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3864 | enum pipe pipe, |
| 3865 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3866 | uint32_t *val) |
| 3867 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3868 | bool need_stable_symbols = false; |
| 3869 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3870 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3871 | int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3872 | if (ret) |
| 3873 | return ret; |
| 3874 | } |
| 3875 | |
| 3876 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3877 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3878 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3879 | break; |
| 3880 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3881 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3882 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3883 | break; |
| 3884 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3885 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3886 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3887 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3888 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3889 | if (!IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3890 | return -EINVAL; |
| 3891 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3892 | need_stable_symbols = true; |
| 3893 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3894 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3895 | *val = 0; |
| 3896 | break; |
| 3897 | default: |
| 3898 | return -EINVAL; |
| 3899 | } |
| 3900 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3901 | /* |
| 3902 | * When the pipe CRC tap point is after the transcoders we need |
| 3903 | * to tweak symbol-level features to produce a deterministic series of |
| 3904 | * symbols for a given frame. We need to reset those features only once |
| 3905 | * a frame (instead of every nth symbol): |
| 3906 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3907 | * link (SDVO) |
| 3908 | * - DisplayPort scrambling: used for EMI reduction |
| 3909 | */ |
| 3910 | if (need_stable_symbols) { |
| 3911 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3912 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3913 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3914 | switch (pipe) { |
| 3915 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3916 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3917 | break; |
| 3918 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3919 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3920 | break; |
| 3921 | case PIPE_C: |
| 3922 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3923 | break; |
| 3924 | default: |
| 3925 | return -EINVAL; |
| 3926 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3927 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3928 | } |
| 3929 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3930 | return 0; |
| 3931 | } |
| 3932 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3933 | static int i9xx_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3934 | enum pipe pipe, |
| 3935 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3936 | uint32_t *val) |
| 3937 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3938 | bool need_stable_symbols = false; |
| 3939 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3940 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3941 | int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3942 | if (ret) |
| 3943 | return ret; |
| 3944 | } |
| 3945 | |
| 3946 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3947 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3948 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3949 | break; |
| 3950 | case INTEL_PIPE_CRC_SOURCE_TV: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3951 | if (!SUPPORTS_TV(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3952 | return -EINVAL; |
| 3953 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3954 | break; |
| 3955 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3956 | if (!IS_G4X(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3957 | return -EINVAL; |
| 3958 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3959 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3960 | break; |
| 3961 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3962 | if (!IS_G4X(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3963 | return -EINVAL; |
| 3964 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3965 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3966 | break; |
| 3967 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3968 | if (!IS_G4X(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3969 | return -EINVAL; |
| 3970 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3971 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3972 | break; |
| 3973 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3974 | *val = 0; |
| 3975 | break; |
| 3976 | default: |
| 3977 | return -EINVAL; |
| 3978 | } |
| 3979 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3980 | /* |
| 3981 | * When the pipe CRC tap point is after the transcoders we need |
| 3982 | * to tweak symbol-level features to produce a deterministic series of |
| 3983 | * symbols for a given frame. We need to reset those features only once |
| 3984 | * a frame (instead of every nth symbol): |
| 3985 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3986 | * link (SDVO) |
| 3987 | * - DisplayPort scrambling: used for EMI reduction |
| 3988 | */ |
| 3989 | if (need_stable_symbols) { |
| 3990 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3991 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3992 | WARN_ON(!IS_G4X(dev_priv)); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3993 | |
| 3994 | I915_WRITE(PORT_DFT_I9XX, |
| 3995 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3996 | |
| 3997 | if (pipe == PIPE_A) |
| 3998 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3999 | else |
| 4000 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 4001 | |
| 4002 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 4003 | } |
| 4004 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 4005 | return 0; |
| 4006 | } |
| 4007 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4008 | static void vlv_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv, |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4009 | enum pipe pipe) |
| 4010 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4011 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 4012 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 4013 | switch (pipe) { |
| 4014 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4015 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 4016 | break; |
| 4017 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4018 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 4019 | break; |
| 4020 | case PIPE_C: |
| 4021 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 4022 | break; |
| 4023 | default: |
| 4024 | return; |
| 4025 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4026 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 4027 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 4028 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 4029 | |
| 4030 | } |
| 4031 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4032 | static void g4x_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv, |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4033 | enum pipe pipe) |
| 4034 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4035 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 4036 | |
| 4037 | if (pipe == PIPE_A) |
| 4038 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 4039 | else |
| 4040 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 4041 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 4042 | |
| 4043 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 4044 | I915_WRITE(PORT_DFT_I9XX, |
| 4045 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 4046 | } |
| 4047 | } |
| 4048 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4049 | static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4050 | uint32_t *val) |
| 4051 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4052 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4053 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 4054 | |
| 4055 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4056 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4057 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 4058 | break; |
| 4059 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4060 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 4061 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4062 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 4063 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 4064 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4065 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4066 | *val = 0; |
| 4067 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4068 | default: |
| 4069 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4070 | } |
| 4071 | |
| 4072 | return 0; |
| 4073 | } |
| 4074 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4075 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv, |
| 4076 | bool enable) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4077 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4078 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 4079 | struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, PIPE_A); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4080 | struct intel_crtc_state *pipe_config; |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4081 | struct drm_atomic_state *state; |
| 4082 | int ret = 0; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4083 | |
| 4084 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4085 | state = drm_atomic_state_alloc(dev); |
| 4086 | if (!state) { |
| 4087 | ret = -ENOMEM; |
| 4088 | goto out; |
| 4089 | } |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4090 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4091 | state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base); |
| 4092 | pipe_config = intel_atomic_get_crtc_state(state, crtc); |
| 4093 | if (IS_ERR(pipe_config)) { |
| 4094 | ret = PTR_ERR(pipe_config); |
| 4095 | goto out; |
| 4096 | } |
| 4097 | |
| 4098 | pipe_config->pch_pfit.force_thru = enable; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4099 | if (pipe_config->cpu_transcoder == TRANSCODER_EDP && |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4100 | pipe_config->pch_pfit.enabled != enable) |
| 4101 | pipe_config->base.connectors_changed = true; |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 4102 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4103 | ret = drm_atomic_commit(state); |
| 4104 | out: |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4105 | WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret); |
Chris Wilson | 0853695 | 2016-10-14 13:18:18 +0100 | [diff] [blame] | 4106 | drm_modeset_unlock_all(dev); |
| 4107 | drm_atomic_state_put(state); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4108 | } |
| 4109 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4110 | static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv, |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4111 | enum pipe pipe, |
| 4112 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4113 | uint32_t *val) |
| 4114 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4115 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4116 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 4117 | |
| 4118 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4119 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4120 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 4121 | break; |
| 4122 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4123 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 4124 | break; |
| 4125 | case INTEL_PIPE_CRC_SOURCE_PF: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4126 | if (IS_HASWELL(dev_priv) && pipe == PIPE_A) |
| 4127 | hsw_trans_edp_pipe_A_crc_wa(dev_priv, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4128 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4129 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 4130 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4131 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4132 | *val = 0; |
| 4133 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4134 | default: |
| 4135 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4136 | } |
| 4137 | |
| 4138 | return 0; |
| 4139 | } |
| 4140 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4141 | static int pipe_crc_set_source(struct drm_i915_private *dev_priv, |
| 4142 | enum pipe pipe, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4143 | enum intel_pipe_crc_source source) |
| 4144 | { |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4145 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Ville Syrjälä | b91eb5c | 2016-10-31 22:37:09 +0200 | [diff] [blame] | 4146 | struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4147 | enum intel_display_power_domain power_domain; |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 4148 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4149 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4150 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4151 | if (pipe_crc->source == source) |
| 4152 | return 0; |
| 4153 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 4154 | /* forbid changing the source without going back to 'none' */ |
| 4155 | if (pipe_crc->source && source) |
| 4156 | return -EINVAL; |
| 4157 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4158 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 4159 | if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) { |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 4160 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 4161 | return -EIO; |
| 4162 | } |
| 4163 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4164 | if (IS_GEN2(dev_priv)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4165 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4166 | else if (INTEL_GEN(dev_priv) < 5) |
| 4167 | ret = i9xx_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val); |
| 4168 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 4169 | ret = vlv_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val); |
| 4170 | else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4171 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4172 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4173 | ret = ivb_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4174 | |
| 4175 | if (ret != 0) |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4176 | goto out; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4177 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4178 | /* none -> real source transition */ |
| 4179 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4180 | struct intel_pipe_crc_entry *entries; |
| 4181 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4182 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 4183 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 4184 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 4185 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 4186 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4187 | GFP_KERNEL); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4188 | if (!entries) { |
| 4189 | ret = -ENOMEM; |
| 4190 | goto out; |
| 4191 | } |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4192 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4193 | /* |
| 4194 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 4195 | * enabled and disabled dynamically based on package C states, |
| 4196 | * user space can't make reliable use of the CRCs, so let's just |
| 4197 | * completely disable it. |
| 4198 | */ |
| 4199 | hsw_disable_ips(crtc); |
| 4200 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4201 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 4202 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4203 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4204 | pipe_crc->head = 0; |
| 4205 | pipe_crc->tail = 0; |
| 4206 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4207 | } |
| 4208 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4209 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4210 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4211 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 4212 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 4213 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4214 | /* real source -> none transition */ |
| 4215 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4216 | struct intel_pipe_crc_entry *entries; |
Ville Syrjälä | 9818783 | 2016-10-31 22:37:10 +0200 | [diff] [blame] | 4217 | struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, |
| 4218 | pipe); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4219 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4220 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 4221 | pipe_name(pipe)); |
| 4222 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4223 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4224 | if (crtc->base.state->active) |
Ville Syrjälä | 0f0f74b | 2016-10-31 22:37:06 +0200 | [diff] [blame] | 4225 | intel_wait_for_vblank(dev_priv, pipe); |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4226 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 4227 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4228 | spin_lock_irq(&pipe_crc->lock); |
| 4229 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4230 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 4231 | pipe_crc->head = 0; |
| 4232 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4233 | spin_unlock_irq(&pipe_crc->lock); |
| 4234 | |
| 4235 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4236 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4237 | if (IS_G4X(dev_priv)) |
| 4238 | g4x_undo_pipe_scramble_reset(dev_priv, pipe); |
| 4239 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 4240 | vlv_undo_pipe_scramble_reset(dev_priv, pipe); |
| 4241 | else if (IS_HASWELL(dev_priv) && pipe == PIPE_A) |
| 4242 | hsw_trans_edp_pipe_A_crc_wa(dev_priv, false); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4243 | |
| 4244 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4245 | } |
| 4246 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4247 | ret = 0; |
| 4248 | |
| 4249 | out: |
| 4250 | intel_display_power_put(dev_priv, power_domain); |
| 4251 | |
| 4252 | return ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4253 | } |
| 4254 | |
| 4255 | /* |
| 4256 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4257 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 4258 | * object: 'pipe' |
| 4259 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4260 | * source: (none | plane1 | plane2 | pf) |
| 4261 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 4262 | * |
| 4263 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4264 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 4265 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4266 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4267 | static int display_crc_ctl_tokenize(char *buf, char *words[], int max_words) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4268 | { |
| 4269 | int n_words = 0; |
| 4270 | |
| 4271 | while (*buf) { |
| 4272 | char *end; |
| 4273 | |
| 4274 | /* skip leading white space */ |
| 4275 | buf = skip_spaces(buf); |
| 4276 | if (!*buf) |
| 4277 | break; /* end of buffer */ |
| 4278 | |
| 4279 | /* find end of word */ |
| 4280 | for (end = buf; *end && !isspace(*end); end++) |
| 4281 | ; |
| 4282 | |
| 4283 | if (n_words == max_words) { |
| 4284 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 4285 | max_words); |
| 4286 | return -EINVAL; /* ran out of words[] before bytes */ |
| 4287 | } |
| 4288 | |
| 4289 | if (*end) |
| 4290 | *end++ = '\0'; |
| 4291 | words[n_words++] = buf; |
| 4292 | buf = end; |
| 4293 | } |
| 4294 | |
| 4295 | return n_words; |
| 4296 | } |
| 4297 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4298 | enum intel_pipe_crc_object { |
| 4299 | PIPE_CRC_OBJECT_PIPE, |
| 4300 | }; |
| 4301 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 4302 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4303 | "pipe", |
| 4304 | }; |
| 4305 | |
| 4306 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4307 | display_crc_ctl_parse_object(const char *buf, enum intel_pipe_crc_object *o) |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4308 | { |
| 4309 | int i; |
| 4310 | |
| 4311 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 4312 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4313 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4314 | return 0; |
| 4315 | } |
| 4316 | |
| 4317 | return -EINVAL; |
| 4318 | } |
| 4319 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4320 | static int display_crc_ctl_parse_pipe(const char *buf, enum pipe *pipe) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4321 | { |
| 4322 | const char name = buf[0]; |
| 4323 | |
| 4324 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 4325 | return -EINVAL; |
| 4326 | |
| 4327 | *pipe = name - 'A'; |
| 4328 | |
| 4329 | return 0; |
| 4330 | } |
| 4331 | |
| 4332 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4333 | display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4334 | { |
| 4335 | int i; |
| 4336 | |
| 4337 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 4338 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4339 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4340 | return 0; |
| 4341 | } |
| 4342 | |
| 4343 | return -EINVAL; |
| 4344 | } |
| 4345 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4346 | static int display_crc_ctl_parse(struct drm_i915_private *dev_priv, |
| 4347 | char *buf, size_t len) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4348 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4349 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4350 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4351 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4352 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4353 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4354 | enum intel_pipe_crc_source source; |
| 4355 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4356 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4357 | if (n_words != N_WORDS) { |
| 4358 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 4359 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4360 | return -EINVAL; |
| 4361 | } |
| 4362 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4363 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4364 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4365 | return -EINVAL; |
| 4366 | } |
| 4367 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4368 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4369 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 4370 | return -EINVAL; |
| 4371 | } |
| 4372 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4373 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4374 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4375 | return -EINVAL; |
| 4376 | } |
| 4377 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4378 | return pipe_crc_set_source(dev_priv, pipe, source); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4379 | } |
| 4380 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4381 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 4382 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4383 | { |
| 4384 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4385 | struct drm_i915_private *dev_priv = m->private; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4386 | char *tmpbuf; |
| 4387 | int ret; |
| 4388 | |
| 4389 | if (len == 0) |
| 4390 | return 0; |
| 4391 | |
| 4392 | if (len > PAGE_SIZE - 1) { |
| 4393 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 4394 | PAGE_SIZE); |
| 4395 | return -E2BIG; |
| 4396 | } |
| 4397 | |
| 4398 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 4399 | if (!tmpbuf) |
| 4400 | return -ENOMEM; |
| 4401 | |
| 4402 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 4403 | ret = -EFAULT; |
| 4404 | goto out; |
| 4405 | } |
| 4406 | tmpbuf[len] = '\0'; |
| 4407 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4408 | ret = display_crc_ctl_parse(dev_priv, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4409 | |
| 4410 | out: |
| 4411 | kfree(tmpbuf); |
| 4412 | if (ret < 0) |
| 4413 | return ret; |
| 4414 | |
| 4415 | *offp += len; |
| 4416 | return len; |
| 4417 | } |
| 4418 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4419 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4420 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4421 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4422 | .read = seq_read, |
| 4423 | .llseek = seq_lseek, |
| 4424 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4425 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4426 | }; |
| 4427 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4428 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4429 | const char __user *ubuf, |
| 4430 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4431 | { |
| 4432 | char *input_buffer; |
| 4433 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4434 | struct drm_device *dev; |
| 4435 | struct drm_connector *connector; |
| 4436 | struct list_head *connector_list; |
| 4437 | struct intel_dp *intel_dp; |
| 4438 | int val = 0; |
| 4439 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 4440 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4441 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4442 | connector_list = &dev->mode_config.connector_list; |
| 4443 | |
| 4444 | if (len == 0) |
| 4445 | return 0; |
| 4446 | |
| 4447 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 4448 | if (!input_buffer) |
| 4449 | return -ENOMEM; |
| 4450 | |
| 4451 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 4452 | status = -EFAULT; |
| 4453 | goto out; |
| 4454 | } |
| 4455 | |
| 4456 | input_buffer[len] = '\0'; |
| 4457 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 4458 | |
| 4459 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4460 | if (connector->connector_type != |
| 4461 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4462 | continue; |
| 4463 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 4464 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4465 | connector->encoder != NULL) { |
| 4466 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4467 | status = kstrtoint(input_buffer, 10, &val); |
| 4468 | if (status < 0) |
| 4469 | goto out; |
| 4470 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 4471 | /* To prevent erroneous activation of the compliance |
| 4472 | * testing code, only accept an actual value of 1 here |
| 4473 | */ |
| 4474 | if (val == 1) |
| 4475 | intel_dp->compliance_test_active = 1; |
| 4476 | else |
| 4477 | intel_dp->compliance_test_active = 0; |
| 4478 | } |
| 4479 | } |
| 4480 | out: |
| 4481 | kfree(input_buffer); |
| 4482 | if (status < 0) |
| 4483 | return status; |
| 4484 | |
| 4485 | *offp += len; |
| 4486 | return len; |
| 4487 | } |
| 4488 | |
| 4489 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 4490 | { |
| 4491 | struct drm_device *dev = m->private; |
| 4492 | struct drm_connector *connector; |
| 4493 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4494 | struct intel_dp *intel_dp; |
| 4495 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4496 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4497 | if (connector->connector_type != |
| 4498 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4499 | continue; |
| 4500 | |
| 4501 | if (connector->status == connector_status_connected && |
| 4502 | connector->encoder != NULL) { |
| 4503 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4504 | if (intel_dp->compliance_test_active) |
| 4505 | seq_puts(m, "1"); |
| 4506 | else |
| 4507 | seq_puts(m, "0"); |
| 4508 | } else |
| 4509 | seq_puts(m, "0"); |
| 4510 | } |
| 4511 | |
| 4512 | return 0; |
| 4513 | } |
| 4514 | |
| 4515 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4516 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4517 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4518 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4519 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4520 | return single_open(file, i915_displayport_test_active_show, |
| 4521 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4522 | } |
| 4523 | |
| 4524 | static const struct file_operations i915_displayport_test_active_fops = { |
| 4525 | .owner = THIS_MODULE, |
| 4526 | .open = i915_displayport_test_active_open, |
| 4527 | .read = seq_read, |
| 4528 | .llseek = seq_lseek, |
| 4529 | .release = single_release, |
| 4530 | .write = i915_displayport_test_active_write |
| 4531 | }; |
| 4532 | |
| 4533 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 4534 | { |
| 4535 | struct drm_device *dev = m->private; |
| 4536 | struct drm_connector *connector; |
| 4537 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4538 | struct intel_dp *intel_dp; |
| 4539 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4540 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4541 | if (connector->connector_type != |
| 4542 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4543 | continue; |
| 4544 | |
| 4545 | if (connector->status == connector_status_connected && |
| 4546 | connector->encoder != NULL) { |
| 4547 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4548 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 4549 | } else |
| 4550 | seq_puts(m, "0"); |
| 4551 | } |
| 4552 | |
| 4553 | return 0; |
| 4554 | } |
| 4555 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4556 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4557 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4558 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4559 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4560 | return single_open(file, i915_displayport_test_data_show, |
| 4561 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4562 | } |
| 4563 | |
| 4564 | static const struct file_operations i915_displayport_test_data_fops = { |
| 4565 | .owner = THIS_MODULE, |
| 4566 | .open = i915_displayport_test_data_open, |
| 4567 | .read = seq_read, |
| 4568 | .llseek = seq_lseek, |
| 4569 | .release = single_release |
| 4570 | }; |
| 4571 | |
| 4572 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 4573 | { |
| 4574 | struct drm_device *dev = m->private; |
| 4575 | struct drm_connector *connector; |
| 4576 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4577 | struct intel_dp *intel_dp; |
| 4578 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4579 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4580 | if (connector->connector_type != |
| 4581 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4582 | continue; |
| 4583 | |
| 4584 | if (connector->status == connector_status_connected && |
| 4585 | connector->encoder != NULL) { |
| 4586 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4587 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 4588 | } else |
| 4589 | seq_puts(m, "0"); |
| 4590 | } |
| 4591 | |
| 4592 | return 0; |
| 4593 | } |
| 4594 | |
| 4595 | static int i915_displayport_test_type_open(struct inode *inode, |
| 4596 | struct file *file) |
| 4597 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4598 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4599 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4600 | return single_open(file, i915_displayport_test_type_show, |
| 4601 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4602 | } |
| 4603 | |
| 4604 | static const struct file_operations i915_displayport_test_type_fops = { |
| 4605 | .owner = THIS_MODULE, |
| 4606 | .open = i915_displayport_test_type_open, |
| 4607 | .read = seq_read, |
| 4608 | .llseek = seq_lseek, |
| 4609 | .release = single_release |
| 4610 | }; |
| 4611 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4612 | static void wm_latency_show(struct seq_file *m, const uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4613 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4614 | struct drm_i915_private *dev_priv = m->private; |
| 4615 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4616 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4617 | int num_levels; |
| 4618 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4619 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4620 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4621 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4622 | num_levels = 1; |
| 4623 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 4624 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4625 | |
| 4626 | drm_modeset_lock_all(dev); |
| 4627 | |
| 4628 | for (level = 0; level < num_levels; level++) { |
| 4629 | unsigned int latency = wm[level]; |
| 4630 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4631 | /* |
| 4632 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4633 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4634 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4635 | if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) || |
| 4636 | IS_CHERRYVIEW(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4637 | latency *= 10; |
| 4638 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4639 | latency *= 5; |
| 4640 | |
| 4641 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4642 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4643 | } |
| 4644 | |
| 4645 | drm_modeset_unlock_all(dev); |
| 4646 | } |
| 4647 | |
| 4648 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 4649 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4650 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4651 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4652 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4653 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4654 | latencies = dev_priv->wm.skl_latency; |
| 4655 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4656 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4657 | |
| 4658 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4659 | |
| 4660 | return 0; |
| 4661 | } |
| 4662 | |
| 4663 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4664 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4665 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4666 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4667 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4668 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4669 | latencies = dev_priv->wm.skl_latency; |
| 4670 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4671 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4672 | |
| 4673 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4674 | |
| 4675 | return 0; |
| 4676 | } |
| 4677 | |
| 4678 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4679 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4680 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4681 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4682 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4683 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4684 | latencies = dev_priv->wm.skl_latency; |
| 4685 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4686 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4687 | |
| 4688 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4689 | |
| 4690 | return 0; |
| 4691 | } |
| 4692 | |
| 4693 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4694 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4695 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4696 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4697 | if (INTEL_GEN(dev_priv) < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4698 | return -ENODEV; |
| 4699 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4700 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4701 | } |
| 4702 | |
| 4703 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4704 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4705 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4706 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4707 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4708 | return -ENODEV; |
| 4709 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4710 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4711 | } |
| 4712 | |
| 4713 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4714 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4715 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4716 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4717 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4718 | return -ENODEV; |
| 4719 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4720 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4721 | } |
| 4722 | |
| 4723 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4724 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4725 | { |
| 4726 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4727 | struct drm_i915_private *dev_priv = m->private; |
| 4728 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4729 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4730 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4731 | int level; |
| 4732 | int ret; |
| 4733 | char tmp[32]; |
| 4734 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4735 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4736 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4737 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4738 | num_levels = 1; |
| 4739 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 4740 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4741 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4742 | if (len >= sizeof(tmp)) |
| 4743 | return -EINVAL; |
| 4744 | |
| 4745 | if (copy_from_user(tmp, ubuf, len)) |
| 4746 | return -EFAULT; |
| 4747 | |
| 4748 | tmp[len] = '\0'; |
| 4749 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4750 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4751 | &new[0], &new[1], &new[2], &new[3], |
| 4752 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4753 | if (ret != num_levels) |
| 4754 | return -EINVAL; |
| 4755 | |
| 4756 | drm_modeset_lock_all(dev); |
| 4757 | |
| 4758 | for (level = 0; level < num_levels; level++) |
| 4759 | wm[level] = new[level]; |
| 4760 | |
| 4761 | drm_modeset_unlock_all(dev); |
| 4762 | |
| 4763 | return len; |
| 4764 | } |
| 4765 | |
| 4766 | |
| 4767 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4768 | size_t len, loff_t *offp) |
| 4769 | { |
| 4770 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4771 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4772 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4773 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4774 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4775 | latencies = dev_priv->wm.skl_latency; |
| 4776 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4777 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4778 | |
| 4779 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4780 | } |
| 4781 | |
| 4782 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4783 | size_t len, loff_t *offp) |
| 4784 | { |
| 4785 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4786 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4787 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4788 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4789 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4790 | latencies = dev_priv->wm.skl_latency; |
| 4791 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4792 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4793 | |
| 4794 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4795 | } |
| 4796 | |
| 4797 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4798 | size_t len, loff_t *offp) |
| 4799 | { |
| 4800 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4801 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4802 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4803 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4804 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4805 | latencies = dev_priv->wm.skl_latency; |
| 4806 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4807 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4808 | |
| 4809 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4810 | } |
| 4811 | |
| 4812 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4813 | .owner = THIS_MODULE, |
| 4814 | .open = pri_wm_latency_open, |
| 4815 | .read = seq_read, |
| 4816 | .llseek = seq_lseek, |
| 4817 | .release = single_release, |
| 4818 | .write = pri_wm_latency_write |
| 4819 | }; |
| 4820 | |
| 4821 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4822 | .owner = THIS_MODULE, |
| 4823 | .open = spr_wm_latency_open, |
| 4824 | .read = seq_read, |
| 4825 | .llseek = seq_lseek, |
| 4826 | .release = single_release, |
| 4827 | .write = spr_wm_latency_write |
| 4828 | }; |
| 4829 | |
| 4830 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4831 | .owner = THIS_MODULE, |
| 4832 | .open = cur_wm_latency_open, |
| 4833 | .read = seq_read, |
| 4834 | .llseek = seq_lseek, |
| 4835 | .release = single_release, |
| 4836 | .write = cur_wm_latency_write |
| 4837 | }; |
| 4838 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4839 | static int |
| 4840 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4841 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4842 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4843 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4844 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4845 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4846 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4847 | } |
| 4848 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4849 | static int |
| 4850 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4851 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4852 | struct drm_i915_private *dev_priv = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4853 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4854 | /* |
| 4855 | * There is no safeguard against this debugfs entry colliding |
| 4856 | * with the hangcheck calling same i915_handle_error() in |
| 4857 | * parallel, causing an explosion. For now we assume that the |
| 4858 | * test harness is responsible enough not to inject gpu hangs |
| 4859 | * while it is writing to 'i915_wedged' |
| 4860 | */ |
| 4861 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4862 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4863 | return -EAGAIN; |
| 4864 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4865 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4866 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4867 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4868 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4869 | } |
| 4870 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4871 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4872 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4873 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4874 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4875 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4876 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4877 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4878 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4879 | |
| 4880 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4881 | return 0; |
| 4882 | } |
| 4883 | |
| 4884 | static int |
| 4885 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4886 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4887 | struct drm_i915_private *dev_priv = data; |
| 4888 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4889 | int ret; |
| 4890 | |
| 4891 | /* Lock against concurrent debugfs callers */ |
| 4892 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4893 | if (ret) |
| 4894 | return ret; |
| 4895 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4896 | mutex_unlock(&dev->struct_mutex); |
| 4897 | |
| 4898 | return 0; |
| 4899 | } |
| 4900 | |
| 4901 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4902 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4903 | "0x%08llx\n"); |
| 4904 | |
| 4905 | static int |
| 4906 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4907 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4908 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4909 | |
| 4910 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4911 | |
| 4912 | return 0; |
| 4913 | } |
| 4914 | |
| 4915 | static int |
| 4916 | i915_ring_test_irq_set(void *data, u64 val) |
| 4917 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4918 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4919 | |
Chris Wilson | 3a122c2 | 2016-06-17 14:35:05 +0100 | [diff] [blame] | 4920 | val &= INTEL_INFO(dev_priv)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4921 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4922 | dev_priv->gpu_error.test_irq_rings = val; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4923 | |
| 4924 | return 0; |
| 4925 | } |
| 4926 | |
| 4927 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4928 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4929 | "0x%08llx\n"); |
| 4930 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4931 | #define DROP_UNBOUND 0x1 |
| 4932 | #define DROP_BOUND 0x2 |
| 4933 | #define DROP_RETIRE 0x4 |
| 4934 | #define DROP_ACTIVE 0x8 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4935 | #define DROP_FREED 0x10 |
| 4936 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4937 | DROP_BOUND | \ |
| 4938 | DROP_RETIRE | \ |
| 4939 | DROP_ACTIVE | \ |
| 4940 | DROP_FREED) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4941 | static int |
| 4942 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4943 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4944 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4945 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4946 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4947 | } |
| 4948 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4949 | static int |
| 4950 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4951 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4952 | struct drm_i915_private *dev_priv = data; |
| 4953 | struct drm_device *dev = &dev_priv->drm; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4954 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4955 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4956 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4957 | |
| 4958 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4959 | * on ioctls on -EAGAIN. */ |
| 4960 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4961 | if (ret) |
| 4962 | return ret; |
| 4963 | |
| 4964 | if (val & DROP_ACTIVE) { |
Chris Wilson | 22dd3bb | 2016-09-09 14:11:50 +0100 | [diff] [blame] | 4965 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4966 | I915_WAIT_INTERRUPTIBLE | |
| 4967 | I915_WAIT_LOCKED); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4968 | if (ret) |
| 4969 | goto unlock; |
| 4970 | } |
| 4971 | |
| 4972 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4973 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4974 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4975 | if (val & DROP_BOUND) |
| 4976 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4977 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4978 | if (val & DROP_UNBOUND) |
| 4979 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4980 | |
| 4981 | unlock: |
| 4982 | mutex_unlock(&dev->struct_mutex); |
| 4983 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4984 | if (val & DROP_FREED) { |
| 4985 | synchronize_rcu(); |
| 4986 | flush_work(&dev_priv->mm.free_work); |
| 4987 | } |
| 4988 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4989 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4990 | } |
| 4991 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4992 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4993 | i915_drop_caches_get, i915_drop_caches_set, |
| 4994 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4995 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4996 | static int |
| 4997 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4998 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4999 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5000 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5001 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5002 | return -ENODEV; |
| 5003 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 5004 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5005 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5006 | } |
| 5007 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5008 | static int |
| 5009 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5010 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5011 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5012 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5013 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5014 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5015 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5016 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5017 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5018 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5019 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5020 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5021 | if (ret) |
| 5022 | return ret; |
| 5023 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5024 | /* |
| 5025 | * Turbo will still be enabled, but won't go above the set value. |
| 5026 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5027 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5028 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5029 | hw_max = dev_priv->rps.max_freq; |
| 5030 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 5031 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5032 | if (val < hw_min || val > hw_max || val < dev_priv->rps.min_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5033 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 5034 | return -EINVAL; |
| 5035 | } |
| 5036 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5037 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5038 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 5039 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5040 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5041 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5042 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5043 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5044 | } |
| 5045 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5046 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 5047 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 5048 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5049 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5050 | static int |
| 5051 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5052 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5053 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5054 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 5055 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5056 | return -ENODEV; |
| 5057 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 5058 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5059 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5060 | } |
| 5061 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5062 | static int |
| 5063 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5064 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5065 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5066 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5067 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5068 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 5069 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5070 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5071 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5072 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5073 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5074 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5075 | if (ret) |
| 5076 | return ret; |
| 5077 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5078 | /* |
| 5079 | * Turbo will still be enabled, but won't go below the set value. |
| 5080 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5081 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5082 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5083 | hw_max = dev_priv->rps.max_freq; |
| 5084 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5085 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5086 | if (val < hw_min || |
| 5087 | val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5088 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 5089 | return -EINVAL; |
| 5090 | } |
| 5091 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5092 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5093 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 5094 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5095 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5096 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5097 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5098 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5099 | } |
| 5100 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5101 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 5102 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 5103 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5104 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5105 | static int |
| 5106 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5107 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5108 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5109 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5110 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5111 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5112 | return -ENODEV; |
| 5113 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5114 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 5115 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5116 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5117 | |
| 5118 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5119 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5120 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5121 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5122 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5123 | } |
| 5124 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5125 | static int |
| 5126 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5127 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5128 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5129 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5130 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5131 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5132 | return -ENODEV; |
| 5133 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5134 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5135 | return -EINVAL; |
| 5136 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5137 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5138 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5139 | |
| 5140 | /* Update the cache sharing policy here as well */ |
| 5141 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 5142 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 5143 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 5144 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 5145 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5146 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5147 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5148 | } |
| 5149 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5150 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 5151 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 5152 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5153 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5154 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5155 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5156 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 5157 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5158 | int ss; |
| 5159 | u32 sig1[ss_max], sig2[ss_max]; |
| 5160 | |
| 5161 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 5162 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 5163 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 5164 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 5165 | |
| 5166 | for (ss = 0; ss < ss_max; ss++) { |
| 5167 | unsigned int eu_cnt; |
| 5168 | |
| 5169 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 5170 | /* skip disabled subslice */ |
| 5171 | continue; |
| 5172 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5173 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5174 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5175 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 5176 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 5177 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 5178 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5179 | sseu->eu_total += eu_cnt; |
| 5180 | sseu->eu_per_subslice = max_t(unsigned int, |
| 5181 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5182 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5183 | } |
| 5184 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5185 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5186 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5187 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5188 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5189 | int s, ss; |
| 5190 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 5191 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5192 | /* BXT has a single slice and at most 3 subslices. */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5193 | if (IS_BROXTON(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5194 | s_max = 1; |
| 5195 | ss_max = 3; |
| 5196 | } |
| 5197 | |
| 5198 | for (s = 0; s < s_max; s++) { |
| 5199 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 5200 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 5201 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 5202 | } |
| 5203 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5204 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 5205 | GEN9_PGCTL_SSA_EU19_ACK | |
| 5206 | GEN9_PGCTL_SSA_EU210_ACK | |
| 5207 | GEN9_PGCTL_SSA_EU311_ACK; |
| 5208 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 5209 | GEN9_PGCTL_SSB_EU19_ACK | |
| 5210 | GEN9_PGCTL_SSB_EU210_ACK | |
| 5211 | GEN9_PGCTL_SSB_EU311_ACK; |
| 5212 | |
| 5213 | for (s = 0; s < s_max; s++) { |
| 5214 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 5215 | /* skip disabled slice */ |
| 5216 | continue; |
| 5217 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5218 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5219 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5220 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5221 | sseu->subslice_mask = |
| 5222 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5223 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5224 | for (ss = 0; ss < ss_max; ss++) { |
| 5225 | unsigned int eu_cnt; |
| 5226 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5227 | if (IS_BROXTON(dev_priv)) { |
| 5228 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 5229 | /* skip disabled subslice */ |
| 5230 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5231 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5232 | sseu->subslice_mask |= BIT(ss); |
| 5233 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5234 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5235 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 5236 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5237 | sseu->eu_total += eu_cnt; |
| 5238 | sseu->eu_per_subslice = max_t(unsigned int, |
| 5239 | sseu->eu_per_subslice, |
| 5240 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5241 | } |
| 5242 | } |
| 5243 | } |
| 5244 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5245 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5246 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5247 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5248 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5249 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5250 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5251 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5252 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5253 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5254 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 5255 | sseu->eu_per_subslice = |
| 5256 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5257 | sseu->eu_total = sseu->eu_per_subslice * |
| 5258 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5259 | |
| 5260 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 5261 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 5262 | u8 subslice_7eu = |
| 5263 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5264 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5265 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5266 | } |
| 5267 | } |
| 5268 | } |
| 5269 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5270 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 5271 | const struct sseu_dev_info *sseu) |
| 5272 | { |
| 5273 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 5274 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 5275 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 5276 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 5277 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5278 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5279 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5280 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5281 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 5282 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 5283 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5284 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5285 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5286 | seq_printf(m, " %s EU Total: %u\n", type, |
| 5287 | sseu->eu_total); |
| 5288 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 5289 | sseu->eu_per_subslice); |
| 5290 | |
| 5291 | if (!is_available_info) |
| 5292 | return; |
| 5293 | |
| 5294 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 5295 | if (HAS_POOLED_EU(dev_priv)) |
| 5296 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 5297 | |
| 5298 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 5299 | yesno(sseu->has_slice_pg)); |
| 5300 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 5301 | yesno(sseu->has_subslice_pg)); |
| 5302 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 5303 | yesno(sseu->has_eu_pg)); |
| 5304 | } |
| 5305 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5306 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 5307 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5308 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5309 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5310 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5311 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5312 | return -ENODEV; |
| 5313 | |
| 5314 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5315 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5316 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5317 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5318 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5319 | |
| 5320 | intel_runtime_pm_get(dev_priv); |
| 5321 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5322 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5323 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5324 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5325 | broadwell_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5326 | } else if (INTEL_GEN(dev_priv) >= 9) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5327 | gen9_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5328 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5329 | |
| 5330 | intel_runtime_pm_put(dev_priv); |
| 5331 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5332 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5333 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5334 | return 0; |
| 5335 | } |
| 5336 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5337 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 5338 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5339 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5340 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5341 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5342 | return 0; |
| 5343 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5344 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5345 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5346 | |
| 5347 | return 0; |
| 5348 | } |
| 5349 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 5350 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5351 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5352 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5353 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5354 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5355 | return 0; |
| 5356 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5357 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5358 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5359 | |
| 5360 | return 0; |
| 5361 | } |
| 5362 | |
| 5363 | static const struct file_operations i915_forcewake_fops = { |
| 5364 | .owner = THIS_MODULE, |
| 5365 | .open = i915_forcewake_open, |
| 5366 | .release = i915_forcewake_release, |
| 5367 | }; |
| 5368 | |
| 5369 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 5370 | { |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5371 | struct dentry *ent; |
| 5372 | |
| 5373 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5374 | S_IRUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5375 | root, to_i915(minor->dev), |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5376 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5377 | if (!ent) |
| 5378 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5379 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5380 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5381 | } |
| 5382 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5383 | static int i915_debugfs_create(struct dentry *root, |
| 5384 | struct drm_minor *minor, |
| 5385 | const char *name, |
| 5386 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5387 | { |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5388 | struct dentry *ent; |
| 5389 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5390 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5391 | S_IRUGO | S_IWUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5392 | root, to_i915(minor->dev), |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5393 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5394 | if (!ent) |
| 5395 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5396 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5397 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5398 | } |
| 5399 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5400 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 5401 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 5402 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 5403 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 5404 | {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 5405 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 5406 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5407 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 5408 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 5409 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5410 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 5411 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 5412 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 5413 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 5414 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 5415 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 5416 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 5417 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 5418 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 5419 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 5420 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 5421 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 5422 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 5423 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 5424 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 5425 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 5426 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 5427 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 5428 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 5429 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 5430 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 5431 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 5432 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 5433 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 5434 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 5435 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 5436 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 5437 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 5438 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 5439 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 5440 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 5441 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 5442 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 5443 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 5444 | {"i915_engine_info", i915_engine_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 5445 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 5446 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 5447 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 5448 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 5449 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5450 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 5451 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 5452 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5453 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5454 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5455 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5456 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5457 | const char *name; |
| 5458 | const struct file_operations *fops; |
| 5459 | } i915_debugfs_files[] = { |
| 5460 | {"i915_wedged", &i915_wedged_fops}, |
| 5461 | {"i915_max_freq", &i915_max_freq_fops}, |
| 5462 | {"i915_min_freq", &i915_min_freq_fops}, |
| 5463 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 5464 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 5465 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5466 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 5467 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5468 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 5469 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5470 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 5471 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 5472 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 5473 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 5474 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 5475 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 5476 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 5477 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 5478 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
| 5479 | {"i915_guc_log_control", &i915_guc_log_control_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5480 | }; |
| 5481 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5482 | void intel_display_crc_init(struct drm_i915_private *dev_priv) |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5483 | { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5484 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5485 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 5486 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5487 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5488 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 5489 | pipe_crc->opened = false; |
| 5490 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5491 | init_waitqueue_head(&pipe_crc->wq); |
| 5492 | } |
| 5493 | } |
| 5494 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 5495 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5496 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5497 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5498 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 5499 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5500 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 5501 | if (ret) |
| 5502 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5503 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5504 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 5505 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 5506 | if (ret) |
| 5507 | return ret; |
| 5508 | } |
| 5509 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5510 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5511 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 5512 | i915_debugfs_files[i].name, |
| 5513 | i915_debugfs_files[i].fops); |
| 5514 | if (ret) |
| 5515 | return ret; |
| 5516 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 5517 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5518 | return drm_debugfs_create_files(i915_debugfs_list, |
| 5519 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5520 | minor->debugfs_root, minor); |
| 5521 | } |
| 5522 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 5523 | void i915_debugfs_unregister(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5524 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5525 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5526 | int i; |
| 5527 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5528 | drm_debugfs_remove_files(i915_debugfs_list, |
| 5529 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5530 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5531 | drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5532 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5533 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 5534 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5535 | struct drm_info_list *info_list = |
| 5536 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 5537 | |
| 5538 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5539 | } |
| 5540 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5541 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5542 | struct drm_info_list *info_list = |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5543 | (struct drm_info_list *)i915_debugfs_files[i].fops; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5544 | |
| 5545 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5546 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5547 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5548 | |
| 5549 | struct dpcd_block { |
| 5550 | /* DPCD dump start address. */ |
| 5551 | unsigned int offset; |
| 5552 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 5553 | unsigned int end; |
| 5554 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 5555 | size_t size; |
| 5556 | /* Only valid for eDP. */ |
| 5557 | bool edp; |
| 5558 | }; |
| 5559 | |
| 5560 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 5561 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 5562 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 5563 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 5564 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 5565 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 5566 | { .offset = DP_SET_POWER }, |
| 5567 | { .offset = DP_EDP_DPCD_REV }, |
| 5568 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 5569 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 5570 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 5571 | }; |
| 5572 | |
| 5573 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 5574 | { |
| 5575 | struct drm_connector *connector = m->private; |
| 5576 | struct intel_dp *intel_dp = |
| 5577 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5578 | uint8_t buf[16]; |
| 5579 | ssize_t err; |
| 5580 | int i; |
| 5581 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 5582 | if (connector->status != connector_status_connected) |
| 5583 | return -ENODEV; |
| 5584 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5585 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 5586 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 5587 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 5588 | |
| 5589 | if (b->edp && |
| 5590 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 5591 | continue; |
| 5592 | |
| 5593 | /* low tech for now */ |
| 5594 | if (WARN_ON(size > sizeof(buf))) |
| 5595 | continue; |
| 5596 | |
| 5597 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 5598 | if (err <= 0) { |
| 5599 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 5600 | size, b->offset, err); |
| 5601 | continue; |
| 5602 | } |
| 5603 | |
| 5604 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 5605 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5606 | |
| 5607 | return 0; |
| 5608 | } |
| 5609 | |
| 5610 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5611 | { |
| 5612 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5613 | } |
| 5614 | |
| 5615 | static const struct file_operations i915_dpcd_fops = { |
| 5616 | .owner = THIS_MODULE, |
| 5617 | .open = i915_dpcd_open, |
| 5618 | .read = seq_read, |
| 5619 | .llseek = seq_lseek, |
| 5620 | .release = single_release, |
| 5621 | }; |
| 5622 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5623 | static int i915_panel_show(struct seq_file *m, void *data) |
| 5624 | { |
| 5625 | struct drm_connector *connector = m->private; |
| 5626 | struct intel_dp *intel_dp = |
| 5627 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5628 | |
| 5629 | if (connector->status != connector_status_connected) |
| 5630 | return -ENODEV; |
| 5631 | |
| 5632 | seq_printf(m, "Panel power up delay: %d\n", |
| 5633 | intel_dp->panel_power_up_delay); |
| 5634 | seq_printf(m, "Panel power down delay: %d\n", |
| 5635 | intel_dp->panel_power_down_delay); |
| 5636 | seq_printf(m, "Backlight on delay: %d\n", |
| 5637 | intel_dp->backlight_on_delay); |
| 5638 | seq_printf(m, "Backlight off delay: %d\n", |
| 5639 | intel_dp->backlight_off_delay); |
| 5640 | |
| 5641 | return 0; |
| 5642 | } |
| 5643 | |
| 5644 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 5645 | { |
| 5646 | return single_open(file, i915_panel_show, inode->i_private); |
| 5647 | } |
| 5648 | |
| 5649 | static const struct file_operations i915_panel_fops = { |
| 5650 | .owner = THIS_MODULE, |
| 5651 | .open = i915_panel_open, |
| 5652 | .read = seq_read, |
| 5653 | .llseek = seq_lseek, |
| 5654 | .release = single_release, |
| 5655 | }; |
| 5656 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5657 | /** |
| 5658 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5659 | * @connector: pointer to a registered drm_connector |
| 5660 | * |
| 5661 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5662 | * drm_debugfs_connector_remove(). |
| 5663 | * |
| 5664 | * Returns 0 on success, negative error codes on error. |
| 5665 | */ |
| 5666 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5667 | { |
| 5668 | struct dentry *root = connector->debugfs_entry; |
| 5669 | |
| 5670 | /* The connector must have been registered beforehands. */ |
| 5671 | if (!root) |
| 5672 | return -ENODEV; |
| 5673 | |
| 5674 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5675 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5676 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5677 | connector, &i915_dpcd_fops); |
| 5678 | |
| 5679 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5680 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5681 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5682 | |
| 5683 | return 0; |
| 5684 | } |