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; |
| 220 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 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 | } |
| 230 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 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; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 393 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
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; |
| 410 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 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; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 496 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
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) { |
| 550 | struct intel_engine_cs *engine = i915_gem_request_get_engine(work->flip_queued_req); |
| 551 | |
| 552 | seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n", |
| 553 | engine->name, |
| 554 | i915_gem_request_get_seqno(work->flip_queued_req), |
| 555 | dev_priv->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 | { |
| 634 | struct pid *pid = rq->ctx->pid; |
| 635 | struct task_struct *task; |
| 636 | |
| 637 | rcu_read_lock(); |
| 638 | task = pid ? pid_task(pid, PIDTYPE_PID) : NULL; |
| 639 | seq_printf(m, "%s%x [%x:%x] @ %d: %s [%d]\n", prefix, |
| 640 | rq->fence.seqno, rq->ctx->hw_id, rq->fence.seqno, |
| 641 | jiffies_to_msecs(jiffies - rq->emitted_jiffies), |
| 642 | task ? task->comm : "<unknown>", |
| 643 | task ? task->pid : -1); |
| 644 | rcu_read_unlock(); |
| 645 | } |
| 646 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 647 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 648 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 649 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 650 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 651 | struct drm_i915_gem_request *req; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 652 | struct intel_engine_cs *engine; |
| 653 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 654 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 655 | |
| 656 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 657 | if (ret) |
| 658 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 659 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 660 | any = 0; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 661 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 662 | int count; |
| 663 | |
| 664 | count = 0; |
Chris Wilson | efdf7c0 | 2016-08-04 07:52:33 +0100 | [diff] [blame] | 665 | list_for_each_entry(req, &engine->request_list, link) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 666 | count++; |
| 667 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 668 | continue; |
| 669 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 670 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 671 | list_for_each_entry(req, &engine->request_list, link) |
| 672 | print_request(m, req, " "); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 673 | |
| 674 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 675 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 676 | mutex_unlock(&dev->struct_mutex); |
| 677 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 678 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 679 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 680 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 681 | return 0; |
| 682 | } |
| 683 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 684 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 685 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 686 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 687 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 688 | struct rb_node *rb; |
| 689 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 690 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 691 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 692 | |
| 693 | spin_lock(&b->lock); |
| 694 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 695 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 696 | |
| 697 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 698 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 699 | } |
| 700 | spin_unlock(&b->lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 701 | } |
| 702 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 703 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 704 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 705 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 706 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 707 | enum intel_engine_id id; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 708 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 709 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 710 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 711 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 712 | return 0; |
| 713 | } |
| 714 | |
| 715 | |
| 716 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 717 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 718 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 719 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 720 | enum intel_engine_id id; |
Chris Wilson | 4bb0504 | 2016-09-03 07:53:43 +0100 | [diff] [blame] | 721 | int i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 722 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 723 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 724 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 725 | if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 726 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 727 | I915_READ(GEN8_MASTER_IRQ)); |
| 728 | |
| 729 | seq_printf(m, "Display IER:\t%08x\n", |
| 730 | I915_READ(VLV_IER)); |
| 731 | seq_printf(m, "Display IIR:\t%08x\n", |
| 732 | I915_READ(VLV_IIR)); |
| 733 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 734 | I915_READ(VLV_IIR_RW)); |
| 735 | seq_printf(m, "Display IMR:\t%08x\n", |
| 736 | I915_READ(VLV_IMR)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 737 | for_each_pipe(dev_priv, pipe) { |
| 738 | enum intel_display_power_domain power_domain; |
| 739 | |
| 740 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 741 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 742 | power_domain)) { |
| 743 | seq_printf(m, "Pipe %c power disabled\n", |
| 744 | pipe_name(pipe)); |
| 745 | continue; |
| 746 | } |
| 747 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 748 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 749 | pipe_name(pipe), |
| 750 | I915_READ(PIPESTAT(pipe))); |
| 751 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 752 | intel_display_power_put(dev_priv, power_domain); |
| 753 | } |
| 754 | |
| 755 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 756 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 757 | I915_READ(PORT_HOTPLUG_EN)); |
| 758 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 759 | I915_READ(VLV_DPFLIPSTAT)); |
| 760 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 761 | I915_READ(DPINVGTT)); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 762 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 763 | |
| 764 | for (i = 0; i < 4; i++) { |
| 765 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 766 | i, I915_READ(GEN8_GT_IMR(i))); |
| 767 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 768 | i, I915_READ(GEN8_GT_IIR(i))); |
| 769 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 770 | i, I915_READ(GEN8_GT_IER(i))); |
| 771 | } |
| 772 | |
| 773 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 774 | I915_READ(GEN8_PCU_IMR)); |
| 775 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 776 | I915_READ(GEN8_PCU_IIR)); |
| 777 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 778 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 779 | } else if (INTEL_GEN(dev_priv) >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 780 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 781 | I915_READ(GEN8_MASTER_IRQ)); |
| 782 | |
| 783 | for (i = 0; i < 4; i++) { |
| 784 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 785 | i, I915_READ(GEN8_GT_IMR(i))); |
| 786 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 787 | i, I915_READ(GEN8_GT_IIR(i))); |
| 788 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 789 | i, I915_READ(GEN8_GT_IER(i))); |
| 790 | } |
| 791 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 792 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 793 | enum intel_display_power_domain power_domain; |
| 794 | |
| 795 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 796 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 797 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 798 | seq_printf(m, "Pipe %c power disabled\n", |
| 799 | pipe_name(pipe)); |
| 800 | continue; |
| 801 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 802 | seq_printf(m, "Pipe %c IMR:\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_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 805 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 806 | pipe_name(pipe), |
| 807 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 808 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 809 | pipe_name(pipe), |
| 810 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 811 | |
| 812 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 816 | I915_READ(GEN8_DE_PORT_IMR)); |
| 817 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 818 | I915_READ(GEN8_DE_PORT_IIR)); |
| 819 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 820 | I915_READ(GEN8_DE_PORT_IER)); |
| 821 | |
| 822 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 823 | I915_READ(GEN8_DE_MISC_IMR)); |
| 824 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 825 | I915_READ(GEN8_DE_MISC_IIR)); |
| 826 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 827 | I915_READ(GEN8_DE_MISC_IER)); |
| 828 | |
| 829 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 830 | I915_READ(GEN8_PCU_IMR)); |
| 831 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 832 | I915_READ(GEN8_PCU_IIR)); |
| 833 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 834 | I915_READ(GEN8_PCU_IER)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 835 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 836 | seq_printf(m, "Display IER:\t%08x\n", |
| 837 | I915_READ(VLV_IER)); |
| 838 | seq_printf(m, "Display IIR:\t%08x\n", |
| 839 | I915_READ(VLV_IIR)); |
| 840 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 841 | I915_READ(VLV_IIR_RW)); |
| 842 | seq_printf(m, "Display IMR:\t%08x\n", |
| 843 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 844 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 845 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 846 | pipe_name(pipe), |
| 847 | I915_READ(PIPESTAT(pipe))); |
| 848 | |
| 849 | seq_printf(m, "Master IER:\t%08x\n", |
| 850 | I915_READ(VLV_MASTER_IER)); |
| 851 | |
| 852 | seq_printf(m, "Render IER:\t%08x\n", |
| 853 | I915_READ(GTIER)); |
| 854 | seq_printf(m, "Render IIR:\t%08x\n", |
| 855 | I915_READ(GTIIR)); |
| 856 | seq_printf(m, "Render IMR:\t%08x\n", |
| 857 | I915_READ(GTIMR)); |
| 858 | |
| 859 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 860 | I915_READ(GEN6_PMIER)); |
| 861 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 862 | I915_READ(GEN6_PMIIR)); |
| 863 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 864 | I915_READ(GEN6_PMIMR)); |
| 865 | |
| 866 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 867 | I915_READ(PORT_HOTPLUG_EN)); |
| 868 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 869 | I915_READ(VLV_DPFLIPSTAT)); |
| 870 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 871 | I915_READ(DPINVGTT)); |
| 872 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 873 | } else if (!HAS_PCH_SPLIT(dev_priv)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 874 | seq_printf(m, "Interrupt enable: %08x\n", |
| 875 | I915_READ(IER)); |
| 876 | seq_printf(m, "Interrupt identity: %08x\n", |
| 877 | I915_READ(IIR)); |
| 878 | seq_printf(m, "Interrupt mask: %08x\n", |
| 879 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 880 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 881 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 882 | pipe_name(pipe), |
| 883 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 884 | } else { |
| 885 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 886 | I915_READ(DEIER)); |
| 887 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 888 | I915_READ(DEIIR)); |
| 889 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 890 | I915_READ(DEIMR)); |
| 891 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 892 | I915_READ(SDEIER)); |
| 893 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 894 | I915_READ(SDEIIR)); |
| 895 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 896 | I915_READ(SDEIMR)); |
| 897 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 898 | I915_READ(GTIER)); |
| 899 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 900 | I915_READ(GTIIR)); |
| 901 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 902 | I915_READ(GTIMR)); |
| 903 | } |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 904 | for_each_engine(engine, dev_priv, id) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 905 | if (INTEL_GEN(dev_priv) >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 906 | seq_printf(m, |
| 907 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 908 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 909 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 910 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 911 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 912 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 913 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 914 | return 0; |
| 915 | } |
| 916 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 917 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 918 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 919 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 920 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 921 | int i, ret; |
| 922 | |
| 923 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 924 | if (ret) |
| 925 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 926 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 927 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 928 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 929 | struct i915_vma *vma = dev_priv->fence_regs[i].vma; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 930 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 931 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 932 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 933 | if (!vma) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 934 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 935 | else |
Chris Wilson | 49ef529 | 2016-08-18 17:17:00 +0100 | [diff] [blame] | 936 | describe_obj(m, vma->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 937 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 938 | } |
| 939 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 940 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 941 | return 0; |
| 942 | } |
| 943 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 944 | static int i915_hws_info(struct seq_file *m, void *data) |
| 945 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 946 | struct drm_info_node *node = m->private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 947 | struct drm_i915_private *dev_priv = node_to_i915(node); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 948 | struct intel_engine_cs *engine; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 949 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 950 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 951 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 952 | engine = dev_priv->engine[(uintptr_t)node->info_ent->data]; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 953 | hws = engine->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 954 | if (hws == NULL) |
| 955 | return 0; |
| 956 | |
| 957 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 958 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 959 | i * 4, |
| 960 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 961 | } |
| 962 | return 0; |
| 963 | } |
| 964 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 965 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
| 966 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 967 | static ssize_t |
| 968 | i915_error_state_write(struct file *filp, |
| 969 | const char __user *ubuf, |
| 970 | size_t cnt, |
| 971 | loff_t *ppos) |
| 972 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 973 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 974 | |
| 975 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
Chris Wilson | 662d19e | 2016-09-01 21:55:10 +0100 | [diff] [blame] | 976 | i915_destroy_error_state(error_priv->dev); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 977 | |
| 978 | return cnt; |
| 979 | } |
| 980 | |
| 981 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 982 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 983 | struct drm_i915_private *dev_priv = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 984 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 985 | |
| 986 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 987 | if (!error_priv) |
| 988 | return -ENOMEM; |
| 989 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 990 | error_priv->dev = &dev_priv->drm; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 991 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 992 | i915_error_state_get(&dev_priv->drm, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 993 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 994 | file->private_data = error_priv; |
| 995 | |
| 996 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 997 | } |
| 998 | |
| 999 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 1000 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1001 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1002 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1003 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1004 | kfree(error_priv); |
| 1005 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1010 | size_t count, loff_t *pos) |
| 1011 | { |
| 1012 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1013 | struct drm_i915_error_state_buf error_str; |
| 1014 | loff_t tmp_pos = 0; |
| 1015 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1016 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1017 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1018 | ret = i915_error_state_buf_init(&error_str, |
| 1019 | to_i915(error_priv->dev), count, *pos); |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1020 | if (ret) |
| 1021 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1022 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1023 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1024 | if (ret) |
| 1025 | goto out; |
| 1026 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1027 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1028 | error_str.buf, |
| 1029 | error_str.bytes); |
| 1030 | |
| 1031 | if (ret_count < 0) |
| 1032 | ret = ret_count; |
| 1033 | else |
| 1034 | *pos = error_str.start + ret_count; |
| 1035 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1036 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1037 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | static const struct file_operations i915_error_state_fops = { |
| 1041 | .owner = THIS_MODULE, |
| 1042 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1043 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1044 | .write = i915_error_state_write, |
| 1045 | .llseek = default_llseek, |
| 1046 | .release = i915_error_state_release, |
| 1047 | }; |
| 1048 | |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 1049 | #endif |
| 1050 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1051 | static int |
| 1052 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1053 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1054 | struct drm_i915_private *dev_priv = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1055 | int ret; |
| 1056 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1057 | ret = mutex_lock_interruptible(&dev_priv->drm.struct_mutex); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1058 | if (ret) |
| 1059 | return ret; |
| 1060 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1061 | *val = dev_priv->next_seqno; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1062 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1063 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1064 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1065 | } |
| 1066 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1067 | static int |
| 1068 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1069 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1070 | struct drm_i915_private *dev_priv = data; |
| 1071 | struct drm_device *dev = &dev_priv->drm; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1072 | int ret; |
| 1073 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1074 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1075 | if (ret) |
| 1076 | return ret; |
| 1077 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 1078 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1079 | mutex_unlock(&dev->struct_mutex); |
| 1080 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1081 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1082 | } |
| 1083 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1084 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1085 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1086 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1087 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1088 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1089 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1090 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1091 | struct drm_device *dev = &dev_priv->drm; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1092 | int ret = 0; |
| 1093 | |
| 1094 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1095 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1096 | if (IS_GEN5(dev_priv)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1097 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1098 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1099 | |
| 1100 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1101 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1102 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1103 | MEMSTAT_VID_SHIFT); |
| 1104 | seq_printf(m, "Current P-state: %d\n", |
| 1105 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1106 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1107 | u32 freq_sts; |
| 1108 | |
| 1109 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1110 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1111 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1112 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1113 | |
| 1114 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1115 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1116 | |
| 1117 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1118 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1119 | |
| 1120 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1121 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1122 | |
| 1123 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1124 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1125 | |
| 1126 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1127 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1128 | |
| 1129 | seq_printf(m, |
| 1130 | "efficient (RPe) frequency: %d MHz\n", |
| 1131 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1132 | mutex_unlock(&dev_priv->rps.hw_lock); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1133 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1134 | u32 rp_state_limits; |
| 1135 | u32 gt_perf_status; |
| 1136 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1137 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1138 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1139 | u32 rpupei, rpcurup, rpprevup; |
| 1140 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1141 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1142 | int max_freq; |
| 1143 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1144 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1145 | if (IS_BROXTON(dev_priv)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1146 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1147 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1148 | } else { |
| 1149 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1150 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1151 | } |
| 1152 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1153 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1154 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1155 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1156 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1157 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1158 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1159 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1160 | reqf = I915_READ(GEN6_RPNSWREQ); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1161 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1162 | reqf >>= 23; |
| 1163 | else { |
| 1164 | reqf &= ~GEN6_TURBO_DISABLE; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1165 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1166 | reqf >>= 24; |
| 1167 | else |
| 1168 | reqf >>= 25; |
| 1169 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1170 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1171 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1172 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1173 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1174 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1175 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1176 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1177 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1178 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1179 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1180 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1181 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1182 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1183 | if (IS_GEN9(dev_priv)) |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1184 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1185 | else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1186 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1187 | else |
| 1188 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1189 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1190 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1191 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1192 | mutex_unlock(&dev->struct_mutex); |
| 1193 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1194 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1195 | pm_ier = I915_READ(GEN6_PMIER); |
| 1196 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1197 | pm_isr = I915_READ(GEN6_PMISR); |
| 1198 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1199 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1200 | } else { |
| 1201 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1202 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1203 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1204 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1205 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1206 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1207 | 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] | 1208 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 1209 | 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] | 1210 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1211 | seq_printf(m, "Render p-state ratio: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1212 | (gt_perf_status & (IS_GEN9(dev_priv) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1213 | seq_printf(m, "Render p-state VID: %d\n", |
| 1214 | gt_perf_status & 0xff); |
| 1215 | seq_printf(m, "Render p-state limit: %d\n", |
| 1216 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1217 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1218 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1219 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1220 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1221 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1222 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1223 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1224 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1225 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1226 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1227 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1228 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1229 | seq_printf(m, "Up threshold: %d%%\n", |
| 1230 | dev_priv->rps.up_threshold); |
| 1231 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1232 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1233 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1234 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1235 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1236 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1237 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1238 | seq_printf(m, "Down threshold: %d%%\n", |
| 1239 | dev_priv->rps.down_threshold); |
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 >> 0 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1242 | rp_state_cap >> 16) & 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, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1246 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1247 | |
| 1248 | max_freq = (rp_state_cap & 0xff00) >> 8; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1249 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1250 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1251 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1252 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1253 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1254 | max_freq = (IS_BROXTON(dev_priv) ? rp_state_cap >> 16 : |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1255 | rp_state_cap >> 0) & 0xff; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1256 | max_freq *= (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1257 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1258 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1259 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1260 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1261 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1262 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1263 | seq_printf(m, "Current freq: %d MHz\n", |
| 1264 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1265 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1266 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1267 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1268 | seq_printf(m, "Min freq: %d MHz\n", |
| 1269 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1270 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1271 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1272 | seq_printf(m, "Max freq: %d MHz\n", |
| 1273 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1274 | seq_printf(m, |
| 1275 | "efficient (RPe) frequency: %d MHz\n", |
| 1276 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1277 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1278 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1279 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1280 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1281 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1282 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1283 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1284 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1285 | out: |
| 1286 | intel_runtime_pm_put(dev_priv); |
| 1287 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1288 | } |
| 1289 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1290 | static void i915_instdone_info(struct drm_i915_private *dev_priv, |
| 1291 | struct seq_file *m, |
| 1292 | struct intel_instdone *instdone) |
| 1293 | { |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1294 | int slice; |
| 1295 | int subslice; |
| 1296 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1297 | seq_printf(m, "\t\tINSTDONE: 0x%08x\n", |
| 1298 | instdone->instdone); |
| 1299 | |
| 1300 | if (INTEL_GEN(dev_priv) <= 3) |
| 1301 | return; |
| 1302 | |
| 1303 | seq_printf(m, "\t\tSC_INSTDONE: 0x%08x\n", |
| 1304 | instdone->slice_common); |
| 1305 | |
| 1306 | if (INTEL_GEN(dev_priv) <= 6) |
| 1307 | return; |
| 1308 | |
Ben Widawsky | f9e6137 | 2016-09-20 16:54:33 +0300 | [diff] [blame] | 1309 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1310 | seq_printf(m, "\t\tSAMPLER_INSTDONE[%d][%d]: 0x%08x\n", |
| 1311 | slice, subslice, instdone->sampler[slice][subslice]); |
| 1312 | |
| 1313 | for_each_instdone_slice_subslice(dev_priv, slice, subslice) |
| 1314 | seq_printf(m, "\t\tROW_INSTDONE[%d][%d]: 0x%08x\n", |
| 1315 | slice, subslice, instdone->row[slice][subslice]); |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1316 | } |
| 1317 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1318 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1319 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1320 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1321 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1322 | u64 acthd[I915_NUM_ENGINES]; |
| 1323 | u32 seqno[I915_NUM_ENGINES]; |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1324 | struct intel_instdone instdone; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1325 | enum intel_engine_id id; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1326 | |
Chris Wilson | 8af29b0 | 2016-09-09 14:11:47 +0100 | [diff] [blame] | 1327 | if (test_bit(I915_WEDGED, &dev_priv->gpu_error.flags)) |
| 1328 | seq_printf(m, "Wedged\n"); |
| 1329 | if (test_bit(I915_RESET_IN_PROGRESS, &dev_priv->gpu_error.flags)) |
| 1330 | seq_printf(m, "Reset in progress\n"); |
| 1331 | if (waitqueue_active(&dev_priv->gpu_error.wait_queue)) |
| 1332 | seq_printf(m, "Waiter holding struct mutex\n"); |
| 1333 | if (waitqueue_active(&dev_priv->gpu_error.reset_queue)) |
| 1334 | seq_printf(m, "struct_mutex blocked for reset\n"); |
| 1335 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1336 | if (!i915.enable_hangcheck) { |
| 1337 | seq_printf(m, "Hangcheck disabled\n"); |
| 1338 | return 0; |
| 1339 | } |
| 1340 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1341 | intel_runtime_pm_get(dev_priv); |
| 1342 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1343 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1344 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1345 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1346 | } |
| 1347 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1348 | intel_engine_get_instdone(dev_priv->engine[RCS], &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1349 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1350 | intel_runtime_pm_put(dev_priv); |
| 1351 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1352 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1353 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1354 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1355 | jiffies)); |
| 1356 | } else |
| 1357 | seq_printf(m, "Hangcheck inactive\n"); |
| 1358 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1359 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1360 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 1361 | struct rb_node *rb; |
| 1362 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1363 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 14fd0d6 | 2016-04-07 07:29:10 +0100 | [diff] [blame] | 1364 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
| 1365 | engine->hangcheck.seqno, |
| 1366 | seqno[id], |
| 1367 | engine->last_submitted_seqno); |
Chris Wilson | 83348ba | 2016-08-09 17:47:51 +0100 | [diff] [blame] | 1368 | seq_printf(m, "\twaiters? %s, fake irq active? %s\n", |
| 1369 | yesno(intel_engine_has_waiter(engine)), |
| 1370 | yesno(test_bit(engine->id, |
| 1371 | &dev_priv->gpu_error.missed_irq_rings))); |
Chris Wilson | 33f5371 | 2016-10-04 21:11:32 +0100 | [diff] [blame] | 1372 | spin_lock(&b->lock); |
| 1373 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 1374 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 1375 | |
| 1376 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 1377 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 1378 | } |
| 1379 | spin_unlock(&b->lock); |
| 1380 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1381 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1382 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1383 | (long long)acthd[id]); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1384 | seq_printf(m, "\tscore = %d\n", engine->hangcheck.score); |
| 1385 | seq_printf(m, "\taction = %d\n", engine->hangcheck.action); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1386 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1387 | if (engine->id == RCS) { |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1388 | seq_puts(m, "\tinstdone read =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1389 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1390 | i915_instdone_info(dev_priv, m, &instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1391 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1392 | seq_puts(m, "\tinstdone accu =\n"); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1393 | |
Ben Widawsky | d636951 | 2016-09-20 16:54:32 +0300 | [diff] [blame] | 1394 | i915_instdone_info(dev_priv, m, |
| 1395 | &engine->hangcheck.instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1396 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | return 0; |
| 1400 | } |
| 1401 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1402 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1403 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1404 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1405 | u32 rgvmodectl, rstdbyctl; |
| 1406 | u16 crstandvid; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1407 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1408 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1409 | |
| 1410 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1411 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1412 | crstandvid = I915_READ16(CRSTANDVID); |
| 1413 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1414 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1415 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1416 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1417 | seq_printf(m, "Boost freq: %d\n", |
| 1418 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1419 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1420 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1421 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1422 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1423 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1424 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1425 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1426 | seq_printf(m, "Starting frequency: P%d\n", |
| 1427 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1428 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1429 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1430 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1431 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1432 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1433 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1434 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1435 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1436 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1437 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1438 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1439 | break; |
| 1440 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1441 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1442 | break; |
| 1443 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1444 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1445 | break; |
| 1446 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1447 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1448 | break; |
| 1449 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1450 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1451 | break; |
| 1452 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1453 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1454 | break; |
| 1455 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1456 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1457 | break; |
| 1458 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1459 | |
| 1460 | return 0; |
| 1461 | } |
| 1462 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1463 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1464 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1465 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1466 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1467 | |
| 1468 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1469 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1470 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1471 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1472 | fw_domain->wake_count); |
| 1473 | } |
| 1474 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1475 | |
| 1476 | return 0; |
| 1477 | } |
| 1478 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1479 | static int vlv_drpc_info(struct seq_file *m) |
| 1480 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1481 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1482 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1483 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1484 | intel_runtime_pm_get(dev_priv); |
| 1485 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1486 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1487 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1488 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1489 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1490 | intel_runtime_pm_put(dev_priv); |
| 1491 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1492 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1493 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1494 | seq_printf(m, "Turbo enabled: %s\n", |
| 1495 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1496 | seq_printf(m, "HW control enabled: %s\n", |
| 1497 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1498 | seq_printf(m, "SW control enabled: %s\n", |
| 1499 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1500 | GEN6_RP_MEDIA_SW_MODE)); |
| 1501 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1502 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1503 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1504 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1505 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1506 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1507 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1508 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1509 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1510 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1511 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1512 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1513 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1514 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1515 | } |
| 1516 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1517 | static int gen6_drpc_info(struct seq_file *m) |
| 1518 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1519 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1520 | struct drm_device *dev = &dev_priv->drm; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1521 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1522 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1523 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1524 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1525 | |
| 1526 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1527 | if (ret) |
| 1528 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1529 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1530 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1531 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1532 | 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] | 1533 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1534 | |
| 1535 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1536 | seq_puts(m, "RC information inaccurate because somebody " |
| 1537 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1538 | } else { |
| 1539 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1540 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1541 | udelay(10); |
| 1542 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1543 | } |
| 1544 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1545 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1546 | 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] | 1547 | |
| 1548 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1549 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1550 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1551 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1552 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1553 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1554 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1555 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1556 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1557 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1558 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1559 | intel_runtime_pm_put(dev_priv); |
| 1560 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1561 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1562 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1563 | seq_printf(m, "HW control enabled: %s\n", |
| 1564 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1565 | seq_printf(m, "SW control enabled: %s\n", |
| 1566 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1567 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1568 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1569 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1570 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1571 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1572 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1573 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1574 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1575 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1576 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1577 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1578 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1579 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1580 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1581 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1582 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1583 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1584 | case GEN6_RC0: |
| 1585 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1586 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1587 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1588 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1589 | break; |
| 1590 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1591 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1592 | break; |
| 1593 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1594 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1595 | break; |
| 1596 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1597 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1598 | break; |
| 1599 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1600 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1601 | break; |
| 1602 | } |
| 1603 | |
| 1604 | seq_printf(m, "Core Power Down: %s\n", |
| 1605 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1606 | if (INTEL_GEN(dev_priv) >= 9) { |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1607 | seq_printf(m, "Render Power Well: %s\n", |
| 1608 | (gen9_powergate_status & |
| 1609 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1610 | seq_printf(m, "Media Power Well: %s\n", |
| 1611 | (gen9_powergate_status & |
| 1612 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1613 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1614 | |
| 1615 | /* Not exactly sure what this is */ |
| 1616 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1617 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1618 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1619 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1620 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1621 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1622 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1623 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1624 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1625 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1626 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1627 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1628 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1629 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1630 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1631 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1632 | } |
| 1633 | |
| 1634 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1635 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1636 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1637 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1638 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1639 | return vlv_drpc_info(m); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1640 | else if (INTEL_GEN(dev_priv) >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1641 | return gen6_drpc_info(m); |
| 1642 | else |
| 1643 | return ironlake_drpc_info(m); |
| 1644 | } |
| 1645 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1646 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1647 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1648 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1649 | |
| 1650 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1651 | dev_priv->fb_tracking.busy_bits); |
| 1652 | |
| 1653 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1654 | dev_priv->fb_tracking.flip_bits); |
| 1655 | |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1659 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1660 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1661 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1662 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1663 | if (!HAS_FBC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1664 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1665 | return 0; |
| 1666 | } |
| 1667 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1668 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1669 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1670 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1671 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1672 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1673 | else |
| 1674 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1675 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1676 | |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1677 | if (intel_fbc_is_active(dev_priv) && INTEL_GEN(dev_priv) >= 7) { |
| 1678 | uint32_t mask = INTEL_GEN(dev_priv) >= 8 ? |
| 1679 | BDW_FBC_COMPRESSION_MASK : |
| 1680 | IVB_FBC_COMPRESSION_MASK; |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1681 | seq_printf(m, "Compressing: %s\n", |
Paulo Zanoni | 0fc6a9d | 2016-10-21 13:55:46 -0200 | [diff] [blame] | 1682 | yesno(I915_READ(FBC_STATUS2) & mask)); |
| 1683 | } |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1684 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1685 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1686 | intel_runtime_pm_put(dev_priv); |
| 1687 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1688 | return 0; |
| 1689 | } |
| 1690 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1691 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1692 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1693 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1694 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1695 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1696 | return -ENODEV; |
| 1697 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1698 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1699 | |
| 1700 | return 0; |
| 1701 | } |
| 1702 | |
| 1703 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1704 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1705 | struct drm_i915_private *dev_priv = data; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1706 | u32 reg; |
| 1707 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1708 | if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev_priv)) |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1709 | return -ENODEV; |
| 1710 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1711 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1712 | |
| 1713 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1714 | dev_priv->fbc.false_color = val; |
| 1715 | |
| 1716 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1717 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1718 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1719 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1720 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1721 | return 0; |
| 1722 | } |
| 1723 | |
| 1724 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1725 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1726 | "%llu\n"); |
| 1727 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1728 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1729 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1730 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1731 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1732 | if (!HAS_IPS(dev_priv)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1733 | seq_puts(m, "not supported\n"); |
| 1734 | return 0; |
| 1735 | } |
| 1736 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1737 | intel_runtime_pm_get(dev_priv); |
| 1738 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1739 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1740 | yesno(i915.enable_ips)); |
| 1741 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1742 | if (INTEL_GEN(dev_priv) >= 8) { |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1743 | seq_puts(m, "Currently: unknown\n"); |
| 1744 | } else { |
| 1745 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1746 | seq_puts(m, "Currently: enabled\n"); |
| 1747 | else |
| 1748 | seq_puts(m, "Currently: disabled\n"); |
| 1749 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1750 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1751 | intel_runtime_pm_put(dev_priv); |
| 1752 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1753 | return 0; |
| 1754 | } |
| 1755 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1756 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1757 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1758 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1759 | bool sr_enabled = false; |
| 1760 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1761 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1762 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1763 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1764 | if (HAS_PCH_SPLIT(dev_priv)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1765 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1766 | else if (IS_CRESTLINE(dev_priv) || IS_G4X(dev_priv) || |
| 1767 | IS_I945G(dev_priv) || IS_I945GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1768 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1769 | else if (IS_I915GM(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1770 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1771 | else if (IS_PINEVIEW(dev_priv)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1772 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1773 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1774 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1775 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 1776 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1777 | intel_runtime_pm_put(dev_priv); |
| 1778 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1779 | seq_printf(m, "self-refresh: %s\n", |
| 1780 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1781 | |
| 1782 | return 0; |
| 1783 | } |
| 1784 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1785 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1786 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1787 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1788 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1789 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1790 | int ret; |
| 1791 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1792 | if (!IS_GEN5(dev_priv)) |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1793 | return -ENODEV; |
| 1794 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1795 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1796 | if (ret) |
| 1797 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1798 | |
| 1799 | temp = i915_mch_val(dev_priv); |
| 1800 | chipset = i915_chipset_val(dev_priv); |
| 1801 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1802 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1803 | |
| 1804 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1805 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1806 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1807 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1808 | |
| 1809 | return 0; |
| 1810 | } |
| 1811 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1812 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1813 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1814 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1815 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1816 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1817 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1818 | |
Carlos Santa | 2631034 | 2016-08-17 12:30:41 -0700 | [diff] [blame] | 1819 | if (!HAS_LLC(dev_priv)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1820 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1821 | return 0; |
| 1822 | } |
| 1823 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1824 | intel_runtime_pm_get(dev_priv); |
| 1825 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1826 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1827 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1828 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1829 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1830 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1831 | /* Convert GT frequency to 50 HZ units */ |
| 1832 | min_gpu_freq = |
| 1833 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1834 | max_gpu_freq = |
| 1835 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1836 | } else { |
| 1837 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1838 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1839 | } |
| 1840 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1841 | 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] | 1842 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1843 | 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] | 1844 | ia_freq = gpu_freq; |
| 1845 | sandybridge_pcode_read(dev_priv, |
| 1846 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1847 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1848 | 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] | 1849 | intel_gpu_freq(dev_priv, (gpu_freq * |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1850 | (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ? |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1851 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1852 | ((ia_freq >> 0) & 0xff) * 100, |
| 1853 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1854 | } |
| 1855 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1856 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1857 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1858 | out: |
| 1859 | intel_runtime_pm_put(dev_priv); |
| 1860 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1861 | } |
| 1862 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1863 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1864 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1865 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1866 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1867 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1868 | int ret; |
| 1869 | |
| 1870 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1871 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1872 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1873 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1874 | if (opregion->header) |
| 1875 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1876 | |
| 1877 | mutex_unlock(&dev->struct_mutex); |
| 1878 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1879 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1880 | return 0; |
| 1881 | } |
| 1882 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1883 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1884 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1885 | struct intel_opregion *opregion = &node_to_i915(m->private)->opregion; |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1886 | |
| 1887 | if (opregion->vbt) |
| 1888 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1889 | |
| 1890 | return 0; |
| 1891 | } |
| 1892 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1893 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1894 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1895 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1896 | struct drm_device *dev = &dev_priv->drm; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1897 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1898 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1899 | int ret; |
| 1900 | |
| 1901 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1902 | if (ret) |
| 1903 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1904 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1905 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1906 | if (dev_priv->fbdev) { |
| 1907 | fbdev_fb = to_intel_framebuffer(dev_priv->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1908 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1909 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1910 | fbdev_fb->base.width, |
| 1911 | fbdev_fb->base.height, |
| 1912 | fbdev_fb->base.depth, |
| 1913 | fbdev_fb->base.bits_per_pixel, |
| 1914 | fbdev_fb->base.modifier[0], |
| 1915 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 1916 | describe_obj(m, fbdev_fb->obj); |
| 1917 | seq_putc(m, '\n'); |
| 1918 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1919 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1920 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1921 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1922 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1923 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1924 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1925 | continue; |
| 1926 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1927 | 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] | 1928 | fb->base.width, |
| 1929 | fb->base.height, |
| 1930 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1931 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1932 | fb->base.modifier[0], |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 1933 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1934 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1935 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1936 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1937 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1938 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1939 | |
| 1940 | return 0; |
| 1941 | } |
| 1942 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1943 | 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] | 1944 | { |
| 1945 | 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] | 1946 | ring->space, ring->head, ring->tail, |
| 1947 | ring->last_retired_head); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1948 | } |
| 1949 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1950 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1951 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 1952 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 1953 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1954 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 1955 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1956 | enum intel_engine_id id; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1957 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1958 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1959 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1960 | if (ret) |
| 1961 | return ret; |
| 1962 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1963 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 1964 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1965 | if (ctx->pid) { |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1966 | struct task_struct *task; |
| 1967 | |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1968 | task = get_pid_task(ctx->pid, PIDTYPE_PID); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1969 | if (task) { |
| 1970 | seq_printf(m, "(%s [%d]) ", |
| 1971 | task->comm, task->pid); |
| 1972 | put_task_struct(task); |
| 1973 | } |
Chris Wilson | c84455b | 2016-08-15 10:49:08 +0100 | [diff] [blame] | 1974 | } else if (IS_ERR(ctx->file_priv)) { |
| 1975 | seq_puts(m, "(deleted) "); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 1976 | } else { |
| 1977 | seq_puts(m, "(kernel) "); |
| 1978 | } |
| 1979 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1980 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 1981 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1982 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 1983 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 1984 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 1985 | |
| 1986 | seq_printf(m, "%s: ", engine->name); |
| 1987 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 1988 | if (ce->state) |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 1989 | describe_obj(m, ce->state->obj); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 1990 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1991 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1992 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1993 | } |
| 1994 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1995 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1996 | } |
| 1997 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1998 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1999 | |
| 2000 | return 0; |
| 2001 | } |
| 2002 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2003 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2004 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2005 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2006 | { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2007 | struct i915_vma *vma = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2008 | struct page *page; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2009 | int j; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2010 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2011 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2012 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2013 | if (!vma) { |
| 2014 | seq_puts(m, "\tFake context\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2015 | return; |
| 2016 | } |
| 2017 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2018 | if (vma->flags & I915_VMA_GLOBAL_BIND) |
| 2019 | seq_printf(m, "\tBound in GGTT at 0x%08x\n", |
Chris Wilson | bde13eb | 2016-08-15 10:49:07 +0100 | [diff] [blame] | 2020 | i915_ggtt_offset(vma)); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2021 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2022 | if (i915_gem_object_pin_pages(vma->obj)) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2023 | seq_puts(m, "\tFailed to get pages for context object\n\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2024 | return; |
| 2025 | } |
| 2026 | |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2027 | page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN); |
| 2028 | if (page) { |
| 2029 | u32 *reg_state = kmap_atomic(page); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2030 | |
| 2031 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
Chris Wilson | bf3783e | 2016-08-15 10:48:54 +0100 | [diff] [blame] | 2032 | seq_printf(m, |
| 2033 | "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2034 | j * 4, |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2035 | reg_state[j], reg_state[j + 1], |
| 2036 | reg_state[j + 2], reg_state[j + 3]); |
| 2037 | } |
| 2038 | kunmap_atomic(reg_state); |
| 2039 | } |
| 2040 | |
Chris Wilson | a4f5ea6 | 2016-10-28 13:58:35 +0100 | [diff] [blame] | 2041 | i915_gem_object_unpin_pages(vma->obj); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2042 | seq_putc(m, '\n'); |
| 2043 | } |
| 2044 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2045 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2046 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2047 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2048 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2049 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2050 | struct i915_gem_context *ctx; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2051 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2052 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2053 | |
| 2054 | if (!i915.enable_execlists) { |
| 2055 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
| 2059 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2060 | if (ret) |
| 2061 | return ret; |
| 2062 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2063 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2064 | for_each_engine(engine, dev_priv, id) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2065 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2066 | |
| 2067 | mutex_unlock(&dev->struct_mutex); |
| 2068 | |
| 2069 | return 0; |
| 2070 | } |
| 2071 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2072 | static const char *swizzle_string(unsigned swizzle) |
| 2073 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2074 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2075 | case I915_BIT_6_SWIZZLE_NONE: |
| 2076 | return "none"; |
| 2077 | case I915_BIT_6_SWIZZLE_9: |
| 2078 | return "bit9"; |
| 2079 | case I915_BIT_6_SWIZZLE_9_10: |
| 2080 | return "bit9/bit10"; |
| 2081 | case I915_BIT_6_SWIZZLE_9_11: |
| 2082 | return "bit9/bit11"; |
| 2083 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2084 | return "bit9/bit10/bit11"; |
| 2085 | case I915_BIT_6_SWIZZLE_9_17: |
| 2086 | return "bit9/bit17"; |
| 2087 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2088 | return "bit9/bit10/bit17"; |
| 2089 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2090 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2091 | } |
| 2092 | |
| 2093 | return "bug"; |
| 2094 | } |
| 2095 | |
| 2096 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2097 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2098 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2099 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2100 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2101 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2102 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2103 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2104 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2105 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2106 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2107 | if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2108 | seq_printf(m, "DDC = 0x%08x\n", |
| 2109 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2110 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2111 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2112 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2113 | I915_READ16(C0DRB3)); |
| 2114 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2115 | I915_READ16(C1DRB3)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2116 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2117 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2118 | I915_READ(MAD_DIMM_C0)); |
| 2119 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2120 | I915_READ(MAD_DIMM_C1)); |
| 2121 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2122 | I915_READ(MAD_DIMM_C2)); |
| 2123 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2124 | I915_READ(TILECTL)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2125 | if (INTEL_GEN(dev_priv) >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2126 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2127 | I915_READ(GAMTARBMODE)); |
| 2128 | else |
| 2129 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2130 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2131 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2132 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2133 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2134 | |
| 2135 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2136 | seq_puts(m, "L-shaped memory detected\n"); |
| 2137 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2138 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2139 | |
| 2140 | return 0; |
| 2141 | } |
| 2142 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2143 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2144 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2145 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2146 | struct seq_file *m = data; |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2147 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2148 | |
| 2149 | if (!ppgtt) { |
| 2150 | seq_printf(m, " no ppgtt for context %d\n", |
| 2151 | ctx->user_handle); |
| 2152 | return 0; |
| 2153 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2154 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2155 | if (i915_gem_context_is_default(ctx)) |
| 2156 | seq_puts(m, " default context:\n"); |
| 2157 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2158 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2159 | ppgtt->debug_dump(ppgtt, m); |
| 2160 | |
| 2161 | return 0; |
| 2162 | } |
| 2163 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2164 | static void gen8_ppgtt_info(struct seq_file *m, |
| 2165 | struct drm_i915_private *dev_priv) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2166 | { |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2167 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2168 | struct intel_engine_cs *engine; |
| 2169 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2170 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2171 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2172 | if (!ppgtt) |
| 2173 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2174 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2175 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2176 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2177 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2178 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2179 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2180 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2181 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2182 | } |
| 2183 | } |
| 2184 | } |
| 2185 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2186 | static void gen6_ppgtt_info(struct seq_file *m, |
| 2187 | struct drm_i915_private *dev_priv) |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2188 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2189 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2190 | enum intel_engine_id id; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2191 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2192 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2193 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2194 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2195 | for_each_engine(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2196 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2197 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2198 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2199 | I915_READ(RING_MODE_GEN7(engine))); |
| 2200 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2201 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2202 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2203 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2204 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2205 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2206 | } |
| 2207 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2208 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2209 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2210 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2211 | 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] | 2212 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2213 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2214 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2215 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2216 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2217 | } |
| 2218 | |
| 2219 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2220 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2221 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2222 | struct drm_device *dev = &dev_priv->drm; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2223 | struct drm_file *file; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2224 | int ret; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2225 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2226 | mutex_lock(&dev->filelist_mutex); |
| 2227 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2228 | if (ret) |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2229 | goto out_unlock; |
| 2230 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2231 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2232 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2233 | if (INTEL_GEN(dev_priv) >= 8) |
| 2234 | gen8_ppgtt_info(m, dev_priv); |
| 2235 | else if (INTEL_GEN(dev_priv) >= 6) |
| 2236 | gen6_ppgtt_info(m, dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2237 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2238 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2239 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2240 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2241 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2242 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2243 | if (!task) { |
| 2244 | ret = -ESRCH; |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2245 | goto out_rpm; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2246 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2247 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2248 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2249 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2250 | (void *)(unsigned long)m); |
| 2251 | } |
| 2252 | |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2253 | out_rpm: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2254 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2255 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 637ee29 | 2016-08-22 14:28:20 +0100 | [diff] [blame] | 2256 | out_unlock: |
| 2257 | mutex_unlock(&dev->filelist_mutex); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2258 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2259 | } |
| 2260 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2261 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2262 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2263 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2264 | enum intel_engine_id id; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2265 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2266 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2267 | for_each_engine(engine, i915, id) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2268 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2269 | |
| 2270 | return count; |
| 2271 | } |
| 2272 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2273 | static const char *rps_power_to_str(unsigned int power) |
| 2274 | { |
| 2275 | static const char * const strings[] = { |
| 2276 | [LOW_POWER] = "low power", |
| 2277 | [BETWEEN] = "mixed", |
| 2278 | [HIGH_POWER] = "high power", |
| 2279 | }; |
| 2280 | |
| 2281 | if (power >= ARRAY_SIZE(strings) || !strings[power]) |
| 2282 | return "unknown"; |
| 2283 | |
| 2284 | return strings[power]; |
| 2285 | } |
| 2286 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2287 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2288 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2289 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2290 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2291 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2292 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2293 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2294 | seq_printf(m, "GPU busy? %s [%x]\n", |
| 2295 | yesno(dev_priv->gt.awake), dev_priv->gt.active_engines); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2296 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2297 | seq_printf(m, "Frequency requested %d\n", |
| 2298 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 2299 | 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] | 2300 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2301 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2302 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2303 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2304 | seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", |
| 2305 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq), |
| 2306 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
| 2307 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2308 | |
| 2309 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2310 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2311 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2312 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2313 | struct task_struct *task; |
| 2314 | |
| 2315 | rcu_read_lock(); |
| 2316 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2317 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2318 | task ? task->comm : "<unknown>", |
| 2319 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2320 | file_priv->rps.boosts, |
| 2321 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2322 | rcu_read_unlock(); |
| 2323 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2324 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2325 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2326 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2327 | |
Chris Wilson | 7466c29 | 2016-08-15 09:49:33 +0100 | [diff] [blame] | 2328 | if (INTEL_GEN(dev_priv) >= 6 && |
| 2329 | dev_priv->rps.enabled && |
| 2330 | dev_priv->gt.active_engines) { |
| 2331 | u32 rpup, rpupei; |
| 2332 | u32 rpdown, rpdownei; |
| 2333 | |
| 2334 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 2335 | rpup = I915_READ_FW(GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; |
| 2336 | rpupei = I915_READ_FW(GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; |
| 2337 | rpdown = I915_READ_FW(GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; |
| 2338 | rpdownei = I915_READ_FW(GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; |
| 2339 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 2340 | |
| 2341 | seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", |
| 2342 | rps_power_to_str(dev_priv->rps.power)); |
| 2343 | seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", |
| 2344 | 100 * rpup / rpupei, |
| 2345 | dev_priv->rps.up_threshold); |
| 2346 | seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", |
| 2347 | 100 * rpdown / rpdownei, |
| 2348 | dev_priv->rps.down_threshold); |
| 2349 | } else { |
| 2350 | seq_puts(m, "\nRPS Autotuning inactive\n"); |
| 2351 | } |
| 2352 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2353 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2354 | } |
| 2355 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2356 | static int i915_llc(struct seq_file *m, void *data) |
| 2357 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2358 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2359 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2360 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2361 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev_priv))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2362 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2363 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2364 | |
| 2365 | return 0; |
| 2366 | } |
| 2367 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2368 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2369 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2370 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2371 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
| 2372 | u32 tmp, i; |
| 2373 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2374 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2375 | return 0; |
| 2376 | |
| 2377 | seq_printf(m, "GuC firmware status:\n"); |
| 2378 | seq_printf(m, "\tpath: %s\n", |
| 2379 | guc_fw->guc_fw_path); |
| 2380 | seq_printf(m, "\tfetch: %s\n", |
| 2381 | intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status)); |
| 2382 | seq_printf(m, "\tload: %s\n", |
| 2383 | intel_guc_fw_status_repr(guc_fw->guc_fw_load_status)); |
| 2384 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2385 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
| 2386 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2387 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2388 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2389 | guc_fw->header_offset, guc_fw->header_size); |
| 2390 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2391 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2392 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2393 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2394 | |
| 2395 | tmp = I915_READ(GUC_STATUS); |
| 2396 | |
| 2397 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2398 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2399 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2400 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2401 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2402 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2403 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2404 | seq_puts(m, "\nScratch registers:\n"); |
| 2405 | for (i = 0; i < 16; i++) |
| 2406 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2407 | |
| 2408 | return 0; |
| 2409 | } |
| 2410 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2411 | static void i915_guc_log_info(struct seq_file *m, |
| 2412 | struct drm_i915_private *dev_priv) |
| 2413 | { |
| 2414 | struct intel_guc *guc = &dev_priv->guc; |
| 2415 | |
| 2416 | seq_puts(m, "\nGuC logging stats:\n"); |
| 2417 | |
| 2418 | seq_printf(m, "\tISR: flush count %10u, overflow count %10u\n", |
| 2419 | guc->log.flush_count[GUC_ISR_LOG_BUFFER], |
| 2420 | guc->log.total_overflow_count[GUC_ISR_LOG_BUFFER]); |
| 2421 | |
| 2422 | seq_printf(m, "\tDPC: flush count %10u, overflow count %10u\n", |
| 2423 | guc->log.flush_count[GUC_DPC_LOG_BUFFER], |
| 2424 | guc->log.total_overflow_count[GUC_DPC_LOG_BUFFER]); |
| 2425 | |
| 2426 | seq_printf(m, "\tCRASH: flush count %10u, overflow count %10u\n", |
| 2427 | guc->log.flush_count[GUC_CRASH_DUMP_LOG_BUFFER], |
| 2428 | guc->log.total_overflow_count[GUC_CRASH_DUMP_LOG_BUFFER]); |
| 2429 | |
| 2430 | seq_printf(m, "\tTotal flush interrupt count: %u\n", |
| 2431 | guc->log.flush_interrupt_count); |
| 2432 | |
| 2433 | seq_printf(m, "\tCapture miss count: %u\n", |
| 2434 | guc->log.capture_miss_count); |
| 2435 | } |
| 2436 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2437 | static void i915_guc_client_info(struct seq_file *m, |
| 2438 | struct drm_i915_private *dev_priv, |
| 2439 | struct i915_guc_client *client) |
| 2440 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2441 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2442 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2443 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2444 | |
| 2445 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2446 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2447 | seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", |
| 2448 | client->doorbell_id, client->doorbell_offset, client->cookie); |
| 2449 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2450 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2451 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2452 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2453 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2454 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2455 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2456 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2457 | u64 submissions = client->submissions[id]; |
| 2458 | tot += submissions; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2459 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2460 | submissions, engine->name); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2461 | } |
| 2462 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2463 | } |
| 2464 | |
| 2465 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2466 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2467 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2468 | struct drm_device *dev = &dev_priv->drm; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2469 | struct intel_guc guc; |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 2470 | struct i915_guc_client client = {}; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2471 | struct intel_engine_cs *engine; |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2472 | enum intel_engine_id id; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2473 | u64 total = 0; |
| 2474 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2475 | if (!HAS_GUC_SCHED(dev_priv)) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2476 | return 0; |
| 2477 | |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2478 | if (mutex_lock_interruptible(&dev->struct_mutex)) |
| 2479 | return 0; |
| 2480 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2481 | /* 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] | 2482 | guc = dev_priv->guc; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2483 | if (guc.execbuf_client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2484 | client = *guc.execbuf_client; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2485 | |
| 2486 | mutex_unlock(&dev->struct_mutex); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2487 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2488 | seq_printf(m, "Doorbell map:\n"); |
| 2489 | seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc.doorbell_bitmap); |
| 2490 | seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc.db_cacheline); |
| 2491 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2492 | seq_printf(m, "GuC total action count: %llu\n", guc.action_count); |
| 2493 | seq_printf(m, "GuC action failure count: %u\n", guc.action_fail); |
| 2494 | seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd); |
| 2495 | seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status); |
| 2496 | seq_printf(m, "GuC last action error code: %d\n", guc.action_err); |
| 2497 | |
| 2498 | seq_printf(m, "\nGuC submissions:\n"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 2499 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2500 | u64 submissions = guc.submissions[id]; |
| 2501 | total += submissions; |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2502 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Dave Gordon | c18468c | 2016-08-09 15:19:22 +0100 | [diff] [blame] | 2503 | engine->name, submissions, guc.last_seqno[id]); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2504 | } |
| 2505 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2506 | |
| 2507 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client); |
| 2508 | i915_guc_client_info(m, dev_priv, &client); |
| 2509 | |
Akash Goel | 5aa1ee4 | 2016-10-12 21:54:36 +0530 | [diff] [blame] | 2510 | i915_guc_log_info(m, dev_priv); |
| 2511 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2512 | /* Add more as required ... */ |
| 2513 | |
| 2514 | return 0; |
| 2515 | } |
| 2516 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2517 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2518 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2519 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2520 | struct drm_i915_gem_object *obj; |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2521 | int i = 0, pg; |
| 2522 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2523 | if (!dev_priv->guc.log.vma) |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2524 | return 0; |
| 2525 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 2526 | obj = dev_priv->guc.log.vma->obj; |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 2527 | for (pg = 0; pg < obj->base.size / PAGE_SIZE; pg++) { |
| 2528 | u32 *log = kmap_atomic(i915_gem_object_get_page(obj, pg)); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2529 | |
| 2530 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2531 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2532 | *(log + i), *(log + i + 1), |
| 2533 | *(log + i + 2), *(log + i + 3)); |
| 2534 | |
| 2535 | kunmap_atomic(log); |
| 2536 | } |
| 2537 | |
| 2538 | seq_putc(m, '\n'); |
| 2539 | |
| 2540 | return 0; |
| 2541 | } |
| 2542 | |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 2543 | static int i915_guc_log_control_get(void *data, u64 *val) |
| 2544 | { |
| 2545 | struct drm_device *dev = data; |
| 2546 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2547 | |
| 2548 | if (!dev_priv->guc.log.vma) |
| 2549 | return -EINVAL; |
| 2550 | |
| 2551 | *val = i915.guc_log_level; |
| 2552 | |
| 2553 | return 0; |
| 2554 | } |
| 2555 | |
| 2556 | static int i915_guc_log_control_set(void *data, u64 val) |
| 2557 | { |
| 2558 | struct drm_device *dev = data; |
| 2559 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 2560 | int ret; |
| 2561 | |
| 2562 | if (!dev_priv->guc.log.vma) |
| 2563 | return -EINVAL; |
| 2564 | |
| 2565 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2566 | if (ret) |
| 2567 | return ret; |
| 2568 | |
| 2569 | intel_runtime_pm_get(dev_priv); |
| 2570 | ret = i915_guc_log_control(dev_priv, val); |
| 2571 | intel_runtime_pm_put(dev_priv); |
| 2572 | |
| 2573 | mutex_unlock(&dev->struct_mutex); |
| 2574 | return ret; |
| 2575 | } |
| 2576 | |
| 2577 | DEFINE_SIMPLE_ATTRIBUTE(i915_guc_log_control_fops, |
| 2578 | i915_guc_log_control_get, i915_guc_log_control_set, |
| 2579 | "%lld\n"); |
| 2580 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2581 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2582 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2583 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2584 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2585 | u32 stat[3]; |
| 2586 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2587 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2588 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2589 | if (!HAS_PSR(dev_priv)) { |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2590 | seq_puts(m, "PSR not supported\n"); |
| 2591 | return 0; |
| 2592 | } |
| 2593 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2594 | intel_runtime_pm_get(dev_priv); |
| 2595 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2596 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2597 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2598 | 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] | 2599 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2600 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2601 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2602 | dev_priv->psr.busy_frontbuffer_bits); |
| 2603 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2604 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2605 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2606 | if (HAS_DDI(dev_priv)) |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2607 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2608 | else { |
| 2609 | for_each_pipe(dev_priv, pipe) { |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2610 | enum transcoder cpu_transcoder = |
| 2611 | intel_pipe_to_cpu_transcoder(dev_priv, pipe); |
| 2612 | enum intel_display_power_domain power_domain; |
| 2613 | |
| 2614 | power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder); |
| 2615 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 2616 | power_domain)) |
| 2617 | continue; |
| 2618 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2619 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2620 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2621 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2622 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2623 | enabled = true; |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 2624 | |
| 2625 | intel_display_power_put(dev_priv, power_domain); |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2626 | } |
| 2627 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2628 | |
| 2629 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2630 | yesno(dev_priv->psr.link_standby)); |
| 2631 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2632 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2633 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2634 | if (!HAS_DDI(dev_priv)) |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2635 | for_each_pipe(dev_priv, pipe) { |
| 2636 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2637 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2638 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2639 | } |
| 2640 | seq_puts(m, "\n"); |
| 2641 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2642 | /* |
| 2643 | * VLV/CHV PSR has no kind of performance counter |
| 2644 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2645 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2646 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2647 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2648 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2649 | |
| 2650 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2651 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2652 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2653 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2654 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2655 | return 0; |
| 2656 | } |
| 2657 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2658 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2659 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2660 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2661 | struct drm_device *dev = &dev_priv->drm; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2662 | struct intel_connector *connector; |
| 2663 | struct intel_dp *intel_dp = NULL; |
| 2664 | int ret; |
| 2665 | u8 crc[6]; |
| 2666 | |
| 2667 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2668 | for_each_intel_connector(dev, connector) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2669 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2670 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2671 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2672 | continue; |
| 2673 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2674 | crtc = connector->base.state->crtc; |
| 2675 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2676 | continue; |
| 2677 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2678 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2679 | continue; |
| 2680 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2681 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2682 | |
| 2683 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2684 | if (ret) |
| 2685 | goto out; |
| 2686 | |
| 2687 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2688 | crc[0], crc[1], crc[2], |
| 2689 | crc[3], crc[4], crc[5]); |
| 2690 | goto out; |
| 2691 | } |
| 2692 | ret = -ENODEV; |
| 2693 | out: |
| 2694 | drm_modeset_unlock_all(dev); |
| 2695 | return ret; |
| 2696 | } |
| 2697 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2698 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2699 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2700 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2701 | u64 power; |
| 2702 | u32 units; |
| 2703 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2704 | if (INTEL_GEN(dev_priv) < 6) |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2705 | return -ENODEV; |
| 2706 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2707 | intel_runtime_pm_get(dev_priv); |
| 2708 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2709 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2710 | power = (power & 0x1f00) >> 8; |
| 2711 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2712 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2713 | power *= units; |
| 2714 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2715 | intel_runtime_pm_put(dev_priv); |
| 2716 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2717 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2718 | |
| 2719 | return 0; |
| 2720 | } |
| 2721 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2722 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2723 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2724 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2725 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2726 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2727 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2728 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2729 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2730 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2731 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2732 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2733 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2734 | seq_printf(m, "Usage count: %d\n", |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2735 | atomic_read(&dev_priv->drm.dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2736 | #else |
| 2737 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2738 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2739 | seq_printf(m, "PCI device power state: %s [%d]\n", |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 2740 | pci_power_name(pdev->current_state), |
| 2741 | pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2742 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2743 | return 0; |
| 2744 | } |
| 2745 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2746 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2747 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2748 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2749 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2750 | int i; |
| 2751 | |
| 2752 | mutex_lock(&power_domains->lock); |
| 2753 | |
| 2754 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2755 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2756 | struct i915_power_well *power_well; |
| 2757 | enum intel_display_power_domain power_domain; |
| 2758 | |
| 2759 | power_well = &power_domains->power_wells[i]; |
| 2760 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2761 | power_well->count); |
| 2762 | |
| 2763 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2764 | power_domain++) { |
| 2765 | if (!(BIT(power_domain) & power_well->domains)) |
| 2766 | continue; |
| 2767 | |
| 2768 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2769 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2770 | power_domains->domain_use_count[power_domain]); |
| 2771 | } |
| 2772 | } |
| 2773 | |
| 2774 | mutex_unlock(&power_domains->lock); |
| 2775 | |
| 2776 | return 0; |
| 2777 | } |
| 2778 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2779 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2780 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2781 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2782 | struct intel_csr *csr; |
| 2783 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2784 | if (!HAS_CSR(dev_priv)) { |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2785 | seq_puts(m, "not supported\n"); |
| 2786 | return 0; |
| 2787 | } |
| 2788 | |
| 2789 | csr = &dev_priv->csr; |
| 2790 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2791 | intel_runtime_pm_get(dev_priv); |
| 2792 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2793 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2794 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2795 | |
| 2796 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2797 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2798 | |
| 2799 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2800 | CSR_VERSION_MINOR(csr->version)); |
| 2801 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2802 | if (IS_SKYLAKE(dev_priv) && csr->version >= CSR_VERSION(1, 6)) { |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2803 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2804 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2805 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2806 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2807 | } else if (IS_BROXTON(dev_priv) && csr->version >= CSR_VERSION(1, 4)) { |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2808 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2809 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2810 | } |
| 2811 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2812 | out: |
| 2813 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2814 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2815 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2816 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2817 | intel_runtime_pm_put(dev_priv); |
| 2818 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2819 | return 0; |
| 2820 | } |
| 2821 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2822 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2823 | struct drm_display_mode *mode) |
| 2824 | { |
| 2825 | int i; |
| 2826 | |
| 2827 | for (i = 0; i < tabs; i++) |
| 2828 | seq_putc(m, '\t'); |
| 2829 | |
| 2830 | 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", |
| 2831 | mode->base.id, mode->name, |
| 2832 | mode->vrefresh, mode->clock, |
| 2833 | mode->hdisplay, mode->hsync_start, |
| 2834 | mode->hsync_end, mode->htotal, |
| 2835 | mode->vdisplay, mode->vsync_start, |
| 2836 | mode->vsync_end, mode->vtotal, |
| 2837 | mode->type, mode->flags); |
| 2838 | } |
| 2839 | |
| 2840 | static void intel_encoder_info(struct seq_file *m, |
| 2841 | struct intel_crtc *intel_crtc, |
| 2842 | struct intel_encoder *intel_encoder) |
| 2843 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2844 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2845 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2846 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2847 | struct intel_connector *intel_connector; |
| 2848 | struct drm_encoder *encoder; |
| 2849 | |
| 2850 | encoder = &intel_encoder->base; |
| 2851 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2852 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2853 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2854 | struct drm_connector *connector = &intel_connector->base; |
| 2855 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2856 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2857 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2858 | drm_get_connector_status_name(connector->status)); |
| 2859 | if (connector->status == connector_status_connected) { |
| 2860 | struct drm_display_mode *mode = &crtc->mode; |
| 2861 | seq_printf(m, ", mode:\n"); |
| 2862 | intel_seq_print_mode(m, 2, mode); |
| 2863 | } else { |
| 2864 | seq_putc(m, '\n'); |
| 2865 | } |
| 2866 | } |
| 2867 | } |
| 2868 | |
| 2869 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2870 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2871 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 2872 | struct drm_device *dev = &dev_priv->drm; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2873 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2874 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2875 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2876 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2877 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2878 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2879 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2880 | fb->base.id, plane_state->src_x >> 16, |
| 2881 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2882 | else |
| 2883 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2884 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2885 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2886 | } |
| 2887 | |
| 2888 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2889 | { |
| 2890 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2891 | |
| 2892 | seq_printf(m, "\tfixed mode:\n"); |
| 2893 | intel_seq_print_mode(m, 2, mode); |
| 2894 | } |
| 2895 | |
| 2896 | static void intel_dp_info(struct seq_file *m, |
| 2897 | struct intel_connector *intel_connector) |
| 2898 | { |
| 2899 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2900 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2901 | |
| 2902 | 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] | 2903 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2904 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2905 | intel_panel_info(m, &intel_connector->panel); |
Mika Kahola | 80209e5 | 2016-09-09 14:10:57 +0300 | [diff] [blame] | 2906 | |
| 2907 | drm_dp_downstream_debug(m, intel_dp->dpcd, intel_dp->downstream_ports, |
| 2908 | &intel_dp->aux); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2909 | } |
| 2910 | |
| 2911 | static void intel_hdmi_info(struct seq_file *m, |
| 2912 | struct intel_connector *intel_connector) |
| 2913 | { |
| 2914 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2915 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2916 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2917 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2918 | } |
| 2919 | |
| 2920 | static void intel_lvds_info(struct seq_file *m, |
| 2921 | struct intel_connector *intel_connector) |
| 2922 | { |
| 2923 | intel_panel_info(m, &intel_connector->panel); |
| 2924 | } |
| 2925 | |
| 2926 | static void intel_connector_info(struct seq_file *m, |
| 2927 | struct drm_connector *connector) |
| 2928 | { |
| 2929 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2930 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2931 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2932 | |
| 2933 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2934 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2935 | drm_get_connector_status_name(connector->status)); |
| 2936 | if (connector->status == connector_status_connected) { |
| 2937 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2938 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2939 | connector->display_info.width_mm, |
| 2940 | connector->display_info.height_mm); |
| 2941 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2942 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2943 | seq_printf(m, "\tCEA rev: %d\n", |
| 2944 | connector->display_info.cea_rev); |
| 2945 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2946 | |
| 2947 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 2948 | return; |
| 2949 | |
| 2950 | switch (connector->connector_type) { |
| 2951 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 2952 | case DRM_MODE_CONNECTOR_eDP: |
Dhinakaran Pandiyan | be754b1 | 2016-09-28 23:55:04 -0700 | [diff] [blame] | 2953 | intel_dp_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2954 | break; |
| 2955 | case DRM_MODE_CONNECTOR_LVDS: |
| 2956 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2957 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 2958 | break; |
| 2959 | case DRM_MODE_CONNECTOR_HDMIA: |
| 2960 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 2961 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 2962 | intel_hdmi_info(m, intel_connector); |
| 2963 | break; |
| 2964 | default: |
| 2965 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2966 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2967 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2968 | seq_printf(m, "\tmodes:\n"); |
| 2969 | list_for_each_entry(mode, &connector->modes, head) |
| 2970 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2971 | } |
| 2972 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2973 | static bool cursor_active(struct drm_i915_private *dev_priv, int pipe) |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2974 | { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2975 | u32 state; |
| 2976 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2977 | if (IS_845G(dev_priv) || IS_I865G(dev_priv)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 2978 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2979 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2980 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2981 | |
| 2982 | return state; |
| 2983 | } |
| 2984 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 2985 | static bool cursor_position(struct drm_i915_private *dev_priv, |
| 2986 | int pipe, int *x, int *y) |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2987 | { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2988 | u32 pos; |
| 2989 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2990 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2991 | |
| 2992 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2993 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2994 | *x = -*x; |
| 2995 | |
| 2996 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2997 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2998 | *y = -*y; |
| 2999 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3000 | return cursor_active(dev_priv, pipe); |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3001 | } |
| 3002 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3003 | static const char *plane_type(enum drm_plane_type type) |
| 3004 | { |
| 3005 | switch (type) { |
| 3006 | case DRM_PLANE_TYPE_OVERLAY: |
| 3007 | return "OVL"; |
| 3008 | case DRM_PLANE_TYPE_PRIMARY: |
| 3009 | return "PRI"; |
| 3010 | case DRM_PLANE_TYPE_CURSOR: |
| 3011 | return "CUR"; |
| 3012 | /* |
| 3013 | * Deliberately omitting default: to generate compiler warnings |
| 3014 | * when a new drm_plane_type gets added. |
| 3015 | */ |
| 3016 | } |
| 3017 | |
| 3018 | return "unknown"; |
| 3019 | } |
| 3020 | |
| 3021 | static const char *plane_rotation(unsigned int rotation) |
| 3022 | { |
| 3023 | static char buf[48]; |
| 3024 | /* |
| 3025 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3026 | * will print them all to visualize if the values are misused |
| 3027 | */ |
| 3028 | snprintf(buf, sizeof(buf), |
| 3029 | "%s%s%s%s%s%s(0x%08x)", |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 3030 | (rotation & DRM_ROTATE_0) ? "0 " : "", |
| 3031 | (rotation & DRM_ROTATE_90) ? "90 " : "", |
| 3032 | (rotation & DRM_ROTATE_180) ? "180 " : "", |
| 3033 | (rotation & DRM_ROTATE_270) ? "270 " : "", |
| 3034 | (rotation & DRM_REFLECT_X) ? "FLIPX " : "", |
| 3035 | (rotation & DRM_REFLECT_Y) ? "FLIPY " : "", |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3036 | rotation); |
| 3037 | |
| 3038 | return buf; |
| 3039 | } |
| 3040 | |
| 3041 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3042 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3043 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3044 | struct drm_device *dev = &dev_priv->drm; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3045 | struct intel_plane *intel_plane; |
| 3046 | |
| 3047 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3048 | struct drm_plane_state *state; |
| 3049 | struct drm_plane *plane = &intel_plane->base; |
Eric Engestrom | d382814 | 2016-08-15 16:29:55 +0100 | [diff] [blame] | 3050 | char *format_name; |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3051 | |
| 3052 | if (!plane->state) { |
| 3053 | seq_puts(m, "plane->state is NULL!\n"); |
| 3054 | continue; |
| 3055 | } |
| 3056 | |
| 3057 | state = plane->state; |
| 3058 | |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3059 | if (state->fb) { |
| 3060 | format_name = drm_get_format_name(state->fb->pixel_format); |
| 3061 | } else { |
| 3062 | format_name = kstrdup("N/A", GFP_KERNEL); |
| 3063 | } |
| 3064 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3065 | 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", |
| 3066 | plane->base.id, |
| 3067 | plane_type(intel_plane->base.type), |
| 3068 | state->crtc_x, state->crtc_y, |
| 3069 | state->crtc_w, state->crtc_h, |
| 3070 | (state->src_x >> 16), |
| 3071 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3072 | (state->src_y >> 16), |
| 3073 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3074 | (state->src_w >> 16), |
| 3075 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3076 | (state->src_h >> 16), |
| 3077 | ((state->src_h & 0xffff) * 15625) >> 10, |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3078 | format_name, |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3079 | plane_rotation(state->rotation)); |
Eric Engestrom | 90844f0 | 2016-08-15 01:02:38 +0100 | [diff] [blame] | 3080 | |
| 3081 | kfree(format_name); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3082 | } |
| 3083 | } |
| 3084 | |
| 3085 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3086 | { |
| 3087 | struct intel_crtc_state *pipe_config; |
| 3088 | int num_scalers = intel_crtc->num_scalers; |
| 3089 | int i; |
| 3090 | |
| 3091 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3092 | |
| 3093 | /* Not all platformas have a scaler */ |
| 3094 | if (num_scalers) { |
| 3095 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3096 | num_scalers, |
| 3097 | pipe_config->scaler_state.scaler_users, |
| 3098 | pipe_config->scaler_state.scaler_id); |
| 3099 | |
| 3100 | for (i = 0; i < SKL_NUM_SCALERS; i++) { |
| 3101 | struct intel_scaler *sc = |
| 3102 | &pipe_config->scaler_state.scalers[i]; |
| 3103 | |
| 3104 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3105 | i, yesno(sc->in_use), sc->mode); |
| 3106 | } |
| 3107 | seq_puts(m, "\n"); |
| 3108 | } else { |
| 3109 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3110 | } |
| 3111 | } |
| 3112 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3113 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3114 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3115 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3116 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3117 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3118 | struct drm_connector *connector; |
| 3119 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3120 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3121 | drm_modeset_lock_all(dev); |
| 3122 | seq_printf(m, "CRTC info\n"); |
| 3123 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3124 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3125 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3126 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3127 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3128 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3129 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3130 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3131 | 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] | 3132 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3133 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3134 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3135 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3136 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3137 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3138 | intel_crtc_info(m, crtc); |
| 3139 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3140 | active = cursor_position(dev_priv, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3141 | 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] | 3142 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3143 | x, y, crtc->base.cursor->state->crtc_w, |
| 3144 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3145 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3146 | intel_scaler_info(m, crtc); |
| 3147 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3148 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3149 | |
| 3150 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3151 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3152 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | seq_printf(m, "\n"); |
| 3156 | seq_printf(m, "Connector info\n"); |
| 3157 | seq_printf(m, "--------------\n"); |
| 3158 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3159 | intel_connector_info(m, connector); |
| 3160 | } |
| 3161 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3162 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3163 | |
| 3164 | return 0; |
| 3165 | } |
| 3166 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3167 | static int i915_engine_info(struct seq_file *m, void *unused) |
| 3168 | { |
| 3169 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3170 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3171 | enum intel_engine_id id; |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3172 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3173 | intel_runtime_pm_get(dev_priv); |
| 3174 | |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3175 | for_each_engine(engine, dev_priv, id) { |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3176 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 3177 | struct drm_i915_gem_request *rq; |
| 3178 | struct rb_node *rb; |
| 3179 | u64 addr; |
| 3180 | |
| 3181 | seq_printf(m, "%s\n", engine->name); |
| 3182 | seq_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [score %d]\n", |
| 3183 | intel_engine_get_seqno(engine), |
| 3184 | engine->last_submitted_seqno, |
| 3185 | engine->hangcheck.seqno, |
| 3186 | engine->hangcheck.score); |
| 3187 | |
| 3188 | rcu_read_lock(); |
| 3189 | |
| 3190 | seq_printf(m, "\tRequests:\n"); |
| 3191 | |
| 3192 | rq = list_first_entry(&engine->request_list, |
| 3193 | struct drm_i915_gem_request, link); |
| 3194 | if (&rq->link != &engine->request_list) |
| 3195 | print_request(m, rq, "\t\tfirst "); |
| 3196 | |
| 3197 | rq = list_last_entry(&engine->request_list, |
| 3198 | struct drm_i915_gem_request, link); |
| 3199 | if (&rq->link != &engine->request_list) |
| 3200 | print_request(m, rq, "\t\tlast "); |
| 3201 | |
| 3202 | rq = i915_gem_find_active_request(engine); |
| 3203 | if (rq) { |
| 3204 | print_request(m, rq, "\t\tactive "); |
| 3205 | seq_printf(m, |
| 3206 | "\t\t[head %04x, postfix %04x, tail %04x, batch 0x%08x_%08x]\n", |
| 3207 | rq->head, rq->postfix, rq->tail, |
| 3208 | rq->batch ? upper_32_bits(rq->batch->node.start) : ~0u, |
| 3209 | rq->batch ? lower_32_bits(rq->batch->node.start) : ~0u); |
| 3210 | } |
| 3211 | |
| 3212 | seq_printf(m, "\tRING_START: 0x%08x [0x%08x]\n", |
| 3213 | I915_READ(RING_START(engine->mmio_base)), |
| 3214 | rq ? i915_ggtt_offset(rq->ring->vma) : 0); |
| 3215 | seq_printf(m, "\tRING_HEAD: 0x%08x [0x%08x]\n", |
| 3216 | I915_READ(RING_HEAD(engine->mmio_base)) & HEAD_ADDR, |
| 3217 | rq ? rq->ring->head : 0); |
| 3218 | seq_printf(m, "\tRING_TAIL: 0x%08x [0x%08x]\n", |
| 3219 | I915_READ(RING_TAIL(engine->mmio_base)) & TAIL_ADDR, |
| 3220 | rq ? rq->ring->tail : 0); |
| 3221 | seq_printf(m, "\tRING_CTL: 0x%08x [%s]\n", |
| 3222 | I915_READ(RING_CTL(engine->mmio_base)), |
| 3223 | I915_READ(RING_CTL(engine->mmio_base)) & (RING_WAIT | RING_WAIT_SEMAPHORE) ? "waiting" : ""); |
| 3224 | |
| 3225 | rcu_read_unlock(); |
| 3226 | |
| 3227 | addr = intel_engine_get_active_head(engine); |
| 3228 | seq_printf(m, "\tACTHD: 0x%08x_%08x\n", |
| 3229 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3230 | addr = intel_engine_get_last_batch_head(engine); |
| 3231 | seq_printf(m, "\tBBADDR: 0x%08x_%08x\n", |
| 3232 | upper_32_bits(addr), lower_32_bits(addr)); |
| 3233 | |
| 3234 | if (i915.enable_execlists) { |
| 3235 | u32 ptr, read, write; |
| 3236 | |
| 3237 | seq_printf(m, "\tExeclist status: 0x%08x %08x\n", |
| 3238 | I915_READ(RING_EXECLIST_STATUS_LO(engine)), |
| 3239 | I915_READ(RING_EXECLIST_STATUS_HI(engine))); |
| 3240 | |
| 3241 | ptr = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
| 3242 | read = GEN8_CSB_READ_PTR(ptr); |
| 3243 | write = GEN8_CSB_WRITE_PTR(ptr); |
| 3244 | seq_printf(m, "\tExeclist CSB read %d, write %d\n", |
| 3245 | read, write); |
| 3246 | if (read >= GEN8_CSB_ENTRIES) |
| 3247 | read = 0; |
| 3248 | if (write >= GEN8_CSB_ENTRIES) |
| 3249 | write = 0; |
| 3250 | if (read > write) |
| 3251 | write += GEN8_CSB_ENTRIES; |
| 3252 | while (read < write) { |
| 3253 | unsigned int idx = ++read % GEN8_CSB_ENTRIES; |
| 3254 | |
| 3255 | seq_printf(m, "\tExeclist CSB[%d]: 0x%08x, context: %d\n", |
| 3256 | idx, |
| 3257 | I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, idx)), |
| 3258 | I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, idx))); |
| 3259 | } |
| 3260 | |
| 3261 | rcu_read_lock(); |
| 3262 | rq = READ_ONCE(engine->execlist_port[0].request); |
| 3263 | if (rq) |
| 3264 | print_request(m, rq, "\t\tELSP[0] "); |
| 3265 | else |
| 3266 | seq_printf(m, "\t\tELSP[0] idle\n"); |
| 3267 | rq = READ_ONCE(engine->execlist_port[1].request); |
| 3268 | if (rq) |
| 3269 | print_request(m, rq, "\t\tELSP[1] "); |
| 3270 | else |
| 3271 | seq_printf(m, "\t\tELSP[1] idle\n"); |
| 3272 | rcu_read_unlock(); |
| 3273 | } else if (INTEL_GEN(dev_priv) > 6) { |
| 3274 | seq_printf(m, "\tPP_DIR_BASE: 0x%08x\n", |
| 3275 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 3276 | seq_printf(m, "\tPP_DIR_BASE_READ: 0x%08x\n", |
| 3277 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 3278 | seq_printf(m, "\tPP_DIR_DCLV: 0x%08x\n", |
| 3279 | I915_READ(RING_PP_DIR_DCLV(engine))); |
| 3280 | } |
| 3281 | |
| 3282 | spin_lock(&b->lock); |
| 3283 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 3284 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 3285 | |
| 3286 | seq_printf(m, "\t%s [%d] waiting for %x\n", |
| 3287 | w->tsk->comm, w->tsk->pid, w->seqno); |
| 3288 | } |
| 3289 | spin_unlock(&b->lock); |
| 3290 | |
| 3291 | seq_puts(m, "\n"); |
| 3292 | } |
| 3293 | |
Chris Wilson | 9c870d0 | 2016-10-24 13:42:15 +0100 | [diff] [blame] | 3294 | intel_runtime_pm_put(dev_priv); |
| 3295 | |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 3296 | return 0; |
| 3297 | } |
| 3298 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3299 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3300 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3301 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3302 | struct drm_device *dev = &dev_priv->drm; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3303 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3304 | int num_rings = INTEL_INFO(dev_priv)->num_rings; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3305 | enum intel_engine_id id; |
| 3306 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3307 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3308 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3309 | seq_puts(m, "Semaphores are disabled\n"); |
| 3310 | return 0; |
| 3311 | } |
| 3312 | |
| 3313 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3314 | if (ret) |
| 3315 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3316 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3317 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3318 | if (IS_BROADWELL(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3319 | struct page *page; |
| 3320 | uint64_t *seqno; |
| 3321 | |
Chris Wilson | 51d545d | 2016-08-15 10:49:02 +0100 | [diff] [blame] | 3322 | page = i915_gem_object_get_page(dev_priv->semaphore->obj, 0); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3323 | |
| 3324 | seqno = (uint64_t *)kmap_atomic(page); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3325 | for_each_engine(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3326 | uint64_t offset; |
| 3327 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3328 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3329 | |
| 3330 | seq_puts(m, " Last signal:"); |
| 3331 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3332 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3333 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3334 | seqno[offset], offset * 8); |
| 3335 | } |
| 3336 | seq_putc(m, '\n'); |
| 3337 | |
| 3338 | seq_puts(m, " Last wait: "); |
| 3339 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3340 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3341 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3342 | seqno[offset], offset * 8); |
| 3343 | } |
| 3344 | seq_putc(m, '\n'); |
| 3345 | |
| 3346 | } |
| 3347 | kunmap_atomic(seqno); |
| 3348 | } else { |
| 3349 | seq_puts(m, " Last signal:"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3350 | for_each_engine(engine, dev_priv, id) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3351 | for (j = 0; j < num_rings; j++) |
| 3352 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3353 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3354 | seq_putc(m, '\n'); |
| 3355 | } |
| 3356 | |
| 3357 | seq_puts(m, "\nSync seqno:\n"); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3358 | for_each_engine(engine, dev_priv, id) { |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 3359 | for (j = 0; j < num_rings; j++) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3360 | seq_printf(m, " 0x%08x ", |
| 3361 | engine->semaphore.sync_seqno[j]); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3362 | seq_putc(m, '\n'); |
| 3363 | } |
| 3364 | seq_putc(m, '\n'); |
| 3365 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3366 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3367 | mutex_unlock(&dev->struct_mutex); |
| 3368 | return 0; |
| 3369 | } |
| 3370 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3371 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3372 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3373 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3374 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3375 | int i; |
| 3376 | |
| 3377 | drm_modeset_lock_all(dev); |
| 3378 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3379 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3380 | |
| 3381 | 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] | 3382 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
| 3383 | pll->config.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3384 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3385 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 3386 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 3387 | pll->config.hw_state.dpll_md); |
| 3388 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 3389 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 3390 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3391 | } |
| 3392 | drm_modeset_unlock_all(dev); |
| 3393 | |
| 3394 | return 0; |
| 3395 | } |
| 3396 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3397 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3398 | { |
| 3399 | int i; |
| 3400 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3401 | struct intel_engine_cs *engine; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3402 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3403 | struct drm_device *dev = &dev_priv->drm; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3404 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3405 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3406 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3407 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3408 | if (ret) |
| 3409 | return ret; |
| 3410 | |
| 3411 | intel_runtime_pm_get(dev_priv); |
| 3412 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3413 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 3414 | for_each_engine(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3415 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3416 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3417 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3418 | i915_reg_t addr; |
| 3419 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3420 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3421 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3422 | addr = workarounds->reg[i].addr; |
| 3423 | mask = workarounds->reg[i].mask; |
| 3424 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3425 | read = I915_READ(addr); |
| 3426 | ok = (value & mask) == (read & mask); |
| 3427 | 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] | 3428 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3429 | } |
| 3430 | |
| 3431 | intel_runtime_pm_put(dev_priv); |
| 3432 | mutex_unlock(&dev->struct_mutex); |
| 3433 | |
| 3434 | return 0; |
| 3435 | } |
| 3436 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3437 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3438 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3439 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3440 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3441 | struct skl_ddb_allocation *ddb; |
| 3442 | struct skl_ddb_entry *entry; |
| 3443 | enum pipe pipe; |
| 3444 | int plane; |
| 3445 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3446 | if (INTEL_GEN(dev_priv) < 9) |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3447 | return 0; |
| 3448 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3449 | drm_modeset_lock_all(dev); |
| 3450 | |
| 3451 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3452 | |
| 3453 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3454 | |
| 3455 | for_each_pipe(dev_priv, pipe) { |
| 3456 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3457 | |
Matt Roper | 8b364b4 | 2016-10-26 15:51:28 -0700 | [diff] [blame] | 3458 | for_each_universal_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3459 | entry = &ddb->plane[pipe][plane]; |
| 3460 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3461 | entry->start, entry->end, |
| 3462 | skl_ddb_entry_size(entry)); |
| 3463 | } |
| 3464 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3465 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3466 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3467 | entry->end, skl_ddb_entry_size(entry)); |
| 3468 | } |
| 3469 | |
| 3470 | drm_modeset_unlock_all(dev); |
| 3471 | |
| 3472 | return 0; |
| 3473 | } |
| 3474 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3475 | static void drrs_status_per_crtc(struct seq_file *m, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3476 | struct drm_device *dev, |
| 3477 | struct intel_crtc *intel_crtc) |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3478 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3479 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3480 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3481 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3482 | struct drm_connector *connector; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3483 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3484 | drm_for_each_connector(connector, dev) { |
| 3485 | if (connector->state->crtc != &intel_crtc->base) |
| 3486 | continue; |
| 3487 | |
| 3488 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3489 | } |
| 3490 | |
| 3491 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3492 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3493 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3494 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3495 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3496 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3497 | else |
| 3498 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3499 | |
| 3500 | seq_puts(m, "\n\n"); |
| 3501 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3502 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3503 | struct intel_panel *panel; |
| 3504 | |
| 3505 | mutex_lock(&drrs->mutex); |
| 3506 | /* DRRS Supported */ |
| 3507 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3508 | |
| 3509 | /* disable_drrs() will make drrs->dp NULL */ |
| 3510 | if (!drrs->dp) { |
| 3511 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3512 | mutex_unlock(&drrs->mutex); |
| 3513 | return; |
| 3514 | } |
| 3515 | |
| 3516 | panel = &drrs->dp->attached_connector->panel; |
| 3517 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3518 | drrs->busy_frontbuffer_bits); |
| 3519 | |
| 3520 | seq_puts(m, "\n\t\t"); |
| 3521 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3522 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3523 | vrefresh = panel->fixed_mode->vrefresh; |
| 3524 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3525 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3526 | vrefresh = panel->downclock_mode->vrefresh; |
| 3527 | } else { |
| 3528 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3529 | drrs->refresh_rate_type); |
| 3530 | mutex_unlock(&drrs->mutex); |
| 3531 | return; |
| 3532 | } |
| 3533 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3534 | |
| 3535 | seq_puts(m, "\n\t\t"); |
| 3536 | mutex_unlock(&drrs->mutex); |
| 3537 | } else { |
| 3538 | /* DRRS not supported. Print the VBT parameter*/ |
| 3539 | seq_puts(m, "\tDRRS Supported : No"); |
| 3540 | } |
| 3541 | seq_puts(m, "\n"); |
| 3542 | } |
| 3543 | |
| 3544 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3545 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3546 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3547 | struct drm_device *dev = &dev_priv->drm; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3548 | struct intel_crtc *intel_crtc; |
| 3549 | int active_crtc_cnt = 0; |
| 3550 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3551 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3552 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3553 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3554 | active_crtc_cnt++; |
| 3555 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3556 | |
| 3557 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3558 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3559 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3560 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3561 | |
| 3562 | if (!active_crtc_cnt) |
| 3563 | seq_puts(m, "No active crtc found\n"); |
| 3564 | |
| 3565 | return 0; |
| 3566 | } |
| 3567 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3568 | struct pipe_crc_info { |
| 3569 | const char *name; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3570 | struct drm_i915_private *dev_priv; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3571 | enum pipe pipe; |
| 3572 | }; |
| 3573 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3574 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3575 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3576 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 3577 | struct drm_device *dev = &dev_priv->drm; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3578 | struct intel_encoder *intel_encoder; |
| 3579 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3580 | struct drm_connector *connector; |
| 3581 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3582 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3583 | drm_for_each_connector(connector, dev) { |
| 3584 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3585 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3586 | |
| 3587 | intel_encoder = intel_attached_encoder(connector); |
| 3588 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3589 | continue; |
| 3590 | |
| 3591 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3592 | if (!intel_dig_port->dp.can_mst) |
| 3593 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3594 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3595 | seq_printf(m, "MST Source Port %c\n", |
| 3596 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3597 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3598 | } |
| 3599 | drm_modeset_unlock_all(dev); |
| 3600 | return 0; |
| 3601 | } |
| 3602 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3603 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3604 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3605 | struct pipe_crc_info *info = inode->i_private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3606 | struct drm_i915_private *dev_priv = info->dev_priv; |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3607 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3608 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3609 | if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes) |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 3610 | return -ENODEV; |
| 3611 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3612 | spin_lock_irq(&pipe_crc->lock); |
| 3613 | |
| 3614 | if (pipe_crc->opened) { |
| 3615 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3616 | return -EBUSY; /* already open */ |
| 3617 | } |
| 3618 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3619 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3620 | filep->private_data = inode->i_private; |
| 3621 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3622 | spin_unlock_irq(&pipe_crc->lock); |
| 3623 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3624 | return 0; |
| 3625 | } |
| 3626 | |
| 3627 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 3628 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3629 | struct pipe_crc_info *info = inode->i_private; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3630 | struct drm_i915_private *dev_priv = info->dev_priv; |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3631 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3632 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3633 | spin_lock_irq(&pipe_crc->lock); |
| 3634 | pipe_crc->opened = false; |
| 3635 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3636 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3637 | return 0; |
| 3638 | } |
| 3639 | |
| 3640 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 3641 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 3642 | /* account for \'0' */ |
| 3643 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 3644 | |
| 3645 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 3646 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3647 | assert_spin_locked(&pipe_crc->lock); |
| 3648 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3649 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3650 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3651 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3652 | static ssize_t |
| 3653 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 3654 | loff_t *pos) |
| 3655 | { |
| 3656 | struct pipe_crc_info *info = filep->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3657 | struct drm_i915_private *dev_priv = info->dev_priv; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3658 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3659 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3660 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3661 | ssize_t bytes_read; |
| 3662 | |
| 3663 | /* |
| 3664 | * Don't allow user space to provide buffers not big enough to hold |
| 3665 | * a line of data. |
| 3666 | */ |
| 3667 | if (count < PIPE_CRC_LINE_LEN) |
| 3668 | return -EINVAL; |
| 3669 | |
| 3670 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 3671 | return 0; |
| 3672 | |
| 3673 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3674 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3675 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3676 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3677 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3678 | if (filep->f_flags & O_NONBLOCK) { |
| 3679 | spin_unlock_irq(&pipe_crc->lock); |
| 3680 | return -EAGAIN; |
| 3681 | } |
| 3682 | |
| 3683 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 3684 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 3685 | if (ret) { |
| 3686 | spin_unlock_irq(&pipe_crc->lock); |
| 3687 | return ret; |
| 3688 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3689 | } |
| 3690 | |
| 3691 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3692 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3693 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3694 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3695 | while (n_entries > 0) { |
| 3696 | struct intel_pipe_crc_entry *entry = |
| 3697 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3698 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3699 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3700 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3701 | break; |
| 3702 | |
| 3703 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3704 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3705 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3706 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3707 | "%8u %8x %8x %8x %8x %8x\n", |
| 3708 | entry->frame, entry->crc[0], |
| 3709 | entry->crc[1], entry->crc[2], |
| 3710 | entry->crc[3], entry->crc[4]); |
| 3711 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3712 | spin_unlock_irq(&pipe_crc->lock); |
| 3713 | |
Rodrigo Vivi | 4e9121e | 2016-08-03 08:22:57 -0700 | [diff] [blame] | 3714 | if (copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN)) |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3715 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3716 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3717 | user_buf += PIPE_CRC_LINE_LEN; |
| 3718 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3719 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3720 | spin_lock_irq(&pipe_crc->lock); |
| 3721 | } |
| 3722 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3723 | spin_unlock_irq(&pipe_crc->lock); |
| 3724 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3725 | return bytes_read; |
| 3726 | } |
| 3727 | |
| 3728 | static const struct file_operations i915_pipe_crc_fops = { |
| 3729 | .owner = THIS_MODULE, |
| 3730 | .open = i915_pipe_crc_open, |
| 3731 | .read = i915_pipe_crc_read, |
| 3732 | .release = i915_pipe_crc_release, |
| 3733 | }; |
| 3734 | |
| 3735 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3736 | { |
| 3737 | .name = "i915_pipe_A_crc", |
| 3738 | .pipe = PIPE_A, |
| 3739 | }, |
| 3740 | { |
| 3741 | .name = "i915_pipe_B_crc", |
| 3742 | .pipe = PIPE_B, |
| 3743 | }, |
| 3744 | { |
| 3745 | .name = "i915_pipe_C_crc", |
| 3746 | .pipe = PIPE_C, |
| 3747 | }, |
| 3748 | }; |
| 3749 | |
| 3750 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3751 | enum pipe pipe) |
| 3752 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3753 | struct drm_i915_private *dev_priv = to_i915(minor->dev); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3754 | struct dentry *ent; |
| 3755 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3756 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3757 | info->dev_priv = dev_priv; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3758 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3759 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3760 | if (!ent) |
| 3761 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3762 | |
| 3763 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3764 | } |
| 3765 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3766 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3767 | "none", |
| 3768 | "plane1", |
| 3769 | "plane2", |
| 3770 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3771 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3772 | "TV", |
| 3773 | "DP-B", |
| 3774 | "DP-C", |
| 3775 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3776 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3777 | }; |
| 3778 | |
| 3779 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3780 | { |
| 3781 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3782 | return pipe_crc_sources[source]; |
| 3783 | } |
| 3784 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3785 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3786 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3787 | struct drm_i915_private *dev_priv = m->private; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3788 | int i; |
| 3789 | |
| 3790 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3791 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3792 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3793 | |
| 3794 | return 0; |
| 3795 | } |
| 3796 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3797 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3798 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3799 | return single_open(file, display_crc_ctl_show, inode->i_private); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3800 | } |
| 3801 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3802 | 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] | 3803 | uint32_t *val) |
| 3804 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3805 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3806 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3807 | |
| 3808 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3809 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3810 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3811 | break; |
| 3812 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3813 | *val = 0; |
| 3814 | break; |
| 3815 | default: |
| 3816 | return -EINVAL; |
| 3817 | } |
| 3818 | |
| 3819 | return 0; |
| 3820 | } |
| 3821 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3822 | static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv, |
| 3823 | enum pipe pipe, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3824 | enum intel_pipe_crc_source *source) |
| 3825 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3826 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3827 | struct intel_encoder *encoder; |
| 3828 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3829 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3830 | int ret = 0; |
| 3831 | |
| 3832 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3833 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3834 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3835 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3836 | if (!encoder->base.crtc) |
| 3837 | continue; |
| 3838 | |
| 3839 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3840 | |
| 3841 | if (crtc->pipe != pipe) |
| 3842 | continue; |
| 3843 | |
| 3844 | switch (encoder->type) { |
| 3845 | case INTEL_OUTPUT_TVOUT: |
| 3846 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3847 | break; |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 3848 | case INTEL_OUTPUT_DP: |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3849 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3850 | dig_port = enc_to_dig_port(&encoder->base); |
| 3851 | switch (dig_port->port) { |
| 3852 | case PORT_B: |
| 3853 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3854 | break; |
| 3855 | case PORT_C: |
| 3856 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3857 | break; |
| 3858 | case PORT_D: |
| 3859 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3860 | break; |
| 3861 | default: |
| 3862 | WARN(1, "nonexisting DP port %c\n", |
| 3863 | port_name(dig_port->port)); |
| 3864 | break; |
| 3865 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3866 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3867 | default: |
| 3868 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3869 | } |
| 3870 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3871 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3872 | |
| 3873 | return ret; |
| 3874 | } |
| 3875 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3876 | 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] | 3877 | enum pipe pipe, |
| 3878 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3879 | uint32_t *val) |
| 3880 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3881 | bool need_stable_symbols = false; |
| 3882 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3883 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3884 | int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3885 | if (ret) |
| 3886 | return ret; |
| 3887 | } |
| 3888 | |
| 3889 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3890 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3891 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3892 | break; |
| 3893 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3894 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3895 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3896 | break; |
| 3897 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3898 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3899 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3900 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3901 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3902 | if (!IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3903 | return -EINVAL; |
| 3904 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3905 | need_stable_symbols = true; |
| 3906 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3907 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3908 | *val = 0; |
| 3909 | break; |
| 3910 | default: |
| 3911 | return -EINVAL; |
| 3912 | } |
| 3913 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3914 | /* |
| 3915 | * When the pipe CRC tap point is after the transcoders we need |
| 3916 | * to tweak symbol-level features to produce a deterministic series of |
| 3917 | * symbols for a given frame. We need to reset those features only once |
| 3918 | * a frame (instead of every nth symbol): |
| 3919 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3920 | * link (SDVO) |
| 3921 | * - DisplayPort scrambling: used for EMI reduction |
| 3922 | */ |
| 3923 | if (need_stable_symbols) { |
| 3924 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3925 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3926 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3927 | switch (pipe) { |
| 3928 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3929 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3930 | break; |
| 3931 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3932 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3933 | break; |
| 3934 | case PIPE_C: |
| 3935 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3936 | break; |
| 3937 | default: |
| 3938 | return -EINVAL; |
| 3939 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3940 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3941 | } |
| 3942 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3943 | return 0; |
| 3944 | } |
| 3945 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3946 | 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] | 3947 | enum pipe pipe, |
| 3948 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3949 | uint32_t *val) |
| 3950 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3951 | bool need_stable_symbols = false; |
| 3952 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3953 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3954 | int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3955 | if (ret) |
| 3956 | return ret; |
| 3957 | } |
| 3958 | |
| 3959 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3960 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3961 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3962 | break; |
| 3963 | case INTEL_PIPE_CRC_SOURCE_TV: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3964 | if (!SUPPORTS_TV(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3965 | return -EINVAL; |
| 3966 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3967 | break; |
| 3968 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3969 | if (!IS_G4X(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3970 | return -EINVAL; |
| 3971 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3972 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3973 | break; |
| 3974 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3975 | if (!IS_G4X(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3976 | return -EINVAL; |
| 3977 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3978 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3979 | break; |
| 3980 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 3981 | if (!IS_G4X(dev_priv)) |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3982 | return -EINVAL; |
| 3983 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3984 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3985 | break; |
| 3986 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3987 | *val = 0; |
| 3988 | break; |
| 3989 | default: |
| 3990 | return -EINVAL; |
| 3991 | } |
| 3992 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3993 | /* |
| 3994 | * When the pipe CRC tap point is after the transcoders we need |
| 3995 | * to tweak symbol-level features to produce a deterministic series of |
| 3996 | * symbols for a given frame. We need to reset those features only once |
| 3997 | * a frame (instead of every nth symbol): |
| 3998 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3999 | * link (SDVO) |
| 4000 | * - DisplayPort scrambling: used for EMI reduction |
| 4001 | */ |
| 4002 | if (need_stable_symbols) { |
| 4003 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 4004 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4005 | WARN_ON(!IS_G4X(dev_priv)); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4006 | |
| 4007 | I915_WRITE(PORT_DFT_I9XX, |
| 4008 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 4009 | |
| 4010 | if (pipe == PIPE_A) |
| 4011 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 4012 | else |
| 4013 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 4014 | |
| 4015 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 4016 | } |
| 4017 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 4018 | return 0; |
| 4019 | } |
| 4020 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4021 | 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] | 4022 | enum pipe pipe) |
| 4023 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4024 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 4025 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 4026 | switch (pipe) { |
| 4027 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4028 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 4029 | break; |
| 4030 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4031 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 4032 | break; |
| 4033 | case PIPE_C: |
| 4034 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 4035 | break; |
| 4036 | default: |
| 4037 | return; |
| 4038 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4039 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 4040 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 4041 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 4042 | |
| 4043 | } |
| 4044 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4045 | 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] | 4046 | enum pipe pipe) |
| 4047 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4048 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 4049 | |
| 4050 | if (pipe == PIPE_A) |
| 4051 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 4052 | else |
| 4053 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 4054 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 4055 | |
| 4056 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 4057 | I915_WRITE(PORT_DFT_I9XX, |
| 4058 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 4059 | } |
| 4060 | } |
| 4061 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4062 | 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] | 4063 | uint32_t *val) |
| 4064 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4065 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4066 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 4067 | |
| 4068 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4069 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4070 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 4071 | break; |
| 4072 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4073 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 4074 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4075 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 4076 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 4077 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4078 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4079 | *val = 0; |
| 4080 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4081 | default: |
| 4082 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4083 | } |
| 4084 | |
| 4085 | return 0; |
| 4086 | } |
| 4087 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4088 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv, |
| 4089 | bool enable) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4090 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4091 | struct drm_device *dev = &dev_priv->drm; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4092 | struct intel_crtc *crtc = |
| 4093 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4094 | struct intel_crtc_state *pipe_config; |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4095 | struct drm_atomic_state *state; |
| 4096 | int ret = 0; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4097 | |
| 4098 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4099 | state = drm_atomic_state_alloc(dev); |
| 4100 | if (!state) { |
| 4101 | ret = -ENOMEM; |
| 4102 | goto out; |
| 4103 | } |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4104 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4105 | state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base); |
| 4106 | pipe_config = intel_atomic_get_crtc_state(state, crtc); |
| 4107 | if (IS_ERR(pipe_config)) { |
| 4108 | ret = PTR_ERR(pipe_config); |
| 4109 | goto out; |
| 4110 | } |
| 4111 | |
| 4112 | pipe_config->pch_pfit.force_thru = enable; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4113 | if (pipe_config->cpu_transcoder == TRANSCODER_EDP && |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4114 | pipe_config->pch_pfit.enabled != enable) |
| 4115 | pipe_config->base.connectors_changed = true; |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 4116 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4117 | ret = drm_atomic_commit(state); |
| 4118 | out: |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4119 | WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret); |
Chris Wilson | 0853695 | 2016-10-14 13:18:18 +0100 | [diff] [blame] | 4120 | drm_modeset_unlock_all(dev); |
| 4121 | drm_atomic_state_put(state); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4122 | } |
| 4123 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4124 | 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] | 4125 | enum pipe pipe, |
| 4126 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4127 | uint32_t *val) |
| 4128 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4129 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4130 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 4131 | |
| 4132 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4133 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4134 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 4135 | break; |
| 4136 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4137 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 4138 | break; |
| 4139 | case INTEL_PIPE_CRC_SOURCE_PF: |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4140 | if (IS_HASWELL(dev_priv) && pipe == PIPE_A) |
| 4141 | hsw_trans_edp_pipe_A_crc_wa(dev_priv, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4142 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4143 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 4144 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4145 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4146 | *val = 0; |
| 4147 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4148 | default: |
| 4149 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4150 | } |
| 4151 | |
| 4152 | return 0; |
| 4153 | } |
| 4154 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4155 | static int pipe_crc_set_source(struct drm_i915_private *dev_priv, |
| 4156 | enum pipe pipe, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4157 | enum intel_pipe_crc_source source) |
| 4158 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4159 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4160 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4161 | struct intel_crtc *crtc = |
| 4162 | to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe)); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4163 | enum intel_display_power_domain power_domain; |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 4164 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4165 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4166 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4167 | if (pipe_crc->source == source) |
| 4168 | return 0; |
| 4169 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 4170 | /* forbid changing the source without going back to 'none' */ |
| 4171 | if (pipe_crc->source && source) |
| 4172 | return -EINVAL; |
| 4173 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4174 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 4175 | if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) { |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 4176 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 4177 | return -EIO; |
| 4178 | } |
| 4179 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4180 | if (IS_GEN2(dev_priv)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4181 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4182 | else if (INTEL_GEN(dev_priv) < 5) |
| 4183 | ret = i9xx_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val); |
| 4184 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 4185 | ret = vlv_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val); |
| 4186 | else if (IS_GEN5(dev_priv) || IS_GEN6(dev_priv)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4187 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4188 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4189 | ret = ivb_pipe_crc_ctl_reg(dev_priv, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4190 | |
| 4191 | if (ret != 0) |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4192 | goto out; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4193 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4194 | /* none -> real source transition */ |
| 4195 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4196 | struct intel_pipe_crc_entry *entries; |
| 4197 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4198 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 4199 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 4200 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 4201 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 4202 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4203 | GFP_KERNEL); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4204 | if (!entries) { |
| 4205 | ret = -ENOMEM; |
| 4206 | goto out; |
| 4207 | } |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4208 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4209 | /* |
| 4210 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 4211 | * enabled and disabled dynamically based on package C states, |
| 4212 | * user space can't make reliable use of the CRCs, so let's just |
| 4213 | * completely disable it. |
| 4214 | */ |
| 4215 | hsw_disable_ips(crtc); |
| 4216 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4217 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 4218 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4219 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4220 | pipe_crc->head = 0; |
| 4221 | pipe_crc->tail = 0; |
| 4222 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4223 | } |
| 4224 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4225 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4226 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4227 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 4228 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 4229 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4230 | /* real source -> none transition */ |
| 4231 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4232 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4233 | struct intel_crtc *crtc = |
| 4234 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4235 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4236 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 4237 | pipe_name(pipe)); |
| 4238 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4239 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4240 | if (crtc->base.state->active) |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4241 | intel_wait_for_vblank(dev, pipe); |
| 4242 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 4243 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4244 | spin_lock_irq(&pipe_crc->lock); |
| 4245 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4246 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 4247 | pipe_crc->head = 0; |
| 4248 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4249 | spin_unlock_irq(&pipe_crc->lock); |
| 4250 | |
| 4251 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4252 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4253 | if (IS_G4X(dev_priv)) |
| 4254 | g4x_undo_pipe_scramble_reset(dev_priv, pipe); |
| 4255 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 4256 | vlv_undo_pipe_scramble_reset(dev_priv, pipe); |
| 4257 | else if (IS_HASWELL(dev_priv) && pipe == PIPE_A) |
| 4258 | hsw_trans_edp_pipe_A_crc_wa(dev_priv, false); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4259 | |
| 4260 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4261 | } |
| 4262 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4263 | ret = 0; |
| 4264 | |
| 4265 | out: |
| 4266 | intel_display_power_put(dev_priv, power_domain); |
| 4267 | |
| 4268 | return ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4269 | } |
| 4270 | |
| 4271 | /* |
| 4272 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4273 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 4274 | * object: 'pipe' |
| 4275 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4276 | * source: (none | plane1 | plane2 | pf) |
| 4277 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 4278 | * |
| 4279 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4280 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 4281 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4282 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4283 | 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] | 4284 | { |
| 4285 | int n_words = 0; |
| 4286 | |
| 4287 | while (*buf) { |
| 4288 | char *end; |
| 4289 | |
| 4290 | /* skip leading white space */ |
| 4291 | buf = skip_spaces(buf); |
| 4292 | if (!*buf) |
| 4293 | break; /* end of buffer */ |
| 4294 | |
| 4295 | /* find end of word */ |
| 4296 | for (end = buf; *end && !isspace(*end); end++) |
| 4297 | ; |
| 4298 | |
| 4299 | if (n_words == max_words) { |
| 4300 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 4301 | max_words); |
| 4302 | return -EINVAL; /* ran out of words[] before bytes */ |
| 4303 | } |
| 4304 | |
| 4305 | if (*end) |
| 4306 | *end++ = '\0'; |
| 4307 | words[n_words++] = buf; |
| 4308 | buf = end; |
| 4309 | } |
| 4310 | |
| 4311 | return n_words; |
| 4312 | } |
| 4313 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4314 | enum intel_pipe_crc_object { |
| 4315 | PIPE_CRC_OBJECT_PIPE, |
| 4316 | }; |
| 4317 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 4318 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4319 | "pipe", |
| 4320 | }; |
| 4321 | |
| 4322 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4323 | 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] | 4324 | { |
| 4325 | int i; |
| 4326 | |
| 4327 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 4328 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4329 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4330 | return 0; |
| 4331 | } |
| 4332 | |
| 4333 | return -EINVAL; |
| 4334 | } |
| 4335 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4336 | 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] | 4337 | { |
| 4338 | const char name = buf[0]; |
| 4339 | |
| 4340 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 4341 | return -EINVAL; |
| 4342 | |
| 4343 | *pipe = name - 'A'; |
| 4344 | |
| 4345 | return 0; |
| 4346 | } |
| 4347 | |
| 4348 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4349 | 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] | 4350 | { |
| 4351 | int i; |
| 4352 | |
| 4353 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 4354 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4355 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4356 | return 0; |
| 4357 | } |
| 4358 | |
| 4359 | return -EINVAL; |
| 4360 | } |
| 4361 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4362 | static int display_crc_ctl_parse(struct drm_i915_private *dev_priv, |
| 4363 | char *buf, size_t len) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4364 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4365 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4366 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4367 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4368 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4369 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4370 | enum intel_pipe_crc_source source; |
| 4371 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4372 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4373 | if (n_words != N_WORDS) { |
| 4374 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 4375 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4376 | return -EINVAL; |
| 4377 | } |
| 4378 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4379 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4380 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4381 | return -EINVAL; |
| 4382 | } |
| 4383 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4384 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4385 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 4386 | return -EINVAL; |
| 4387 | } |
| 4388 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4389 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4390 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4391 | return -EINVAL; |
| 4392 | } |
| 4393 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4394 | return pipe_crc_set_source(dev_priv, pipe, source); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4395 | } |
| 4396 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4397 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 4398 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4399 | { |
| 4400 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4401 | struct drm_i915_private *dev_priv = m->private; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4402 | char *tmpbuf; |
| 4403 | int ret; |
| 4404 | |
| 4405 | if (len == 0) |
| 4406 | return 0; |
| 4407 | |
| 4408 | if (len > PAGE_SIZE - 1) { |
| 4409 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 4410 | PAGE_SIZE); |
| 4411 | return -E2BIG; |
| 4412 | } |
| 4413 | |
| 4414 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 4415 | if (!tmpbuf) |
| 4416 | return -ENOMEM; |
| 4417 | |
| 4418 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 4419 | ret = -EFAULT; |
| 4420 | goto out; |
| 4421 | } |
| 4422 | tmpbuf[len] = '\0'; |
| 4423 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4424 | ret = display_crc_ctl_parse(dev_priv, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4425 | |
| 4426 | out: |
| 4427 | kfree(tmpbuf); |
| 4428 | if (ret < 0) |
| 4429 | return ret; |
| 4430 | |
| 4431 | *offp += len; |
| 4432 | return len; |
| 4433 | } |
| 4434 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4435 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4436 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4437 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4438 | .read = seq_read, |
| 4439 | .llseek = seq_lseek, |
| 4440 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4441 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4442 | }; |
| 4443 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4444 | static ssize_t i915_displayport_test_active_write(struct file *file, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4445 | const char __user *ubuf, |
| 4446 | size_t len, loff_t *offp) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4447 | { |
| 4448 | char *input_buffer; |
| 4449 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4450 | struct drm_device *dev; |
| 4451 | struct drm_connector *connector; |
| 4452 | struct list_head *connector_list; |
| 4453 | struct intel_dp *intel_dp; |
| 4454 | int val = 0; |
| 4455 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 4456 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4457 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4458 | connector_list = &dev->mode_config.connector_list; |
| 4459 | |
| 4460 | if (len == 0) |
| 4461 | return 0; |
| 4462 | |
| 4463 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 4464 | if (!input_buffer) |
| 4465 | return -ENOMEM; |
| 4466 | |
| 4467 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 4468 | status = -EFAULT; |
| 4469 | goto out; |
| 4470 | } |
| 4471 | |
| 4472 | input_buffer[len] = '\0'; |
| 4473 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 4474 | |
| 4475 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4476 | if (connector->connector_type != |
| 4477 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4478 | continue; |
| 4479 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 4480 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4481 | connector->encoder != NULL) { |
| 4482 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4483 | status = kstrtoint(input_buffer, 10, &val); |
| 4484 | if (status < 0) |
| 4485 | goto out; |
| 4486 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 4487 | /* To prevent erroneous activation of the compliance |
| 4488 | * testing code, only accept an actual value of 1 here |
| 4489 | */ |
| 4490 | if (val == 1) |
| 4491 | intel_dp->compliance_test_active = 1; |
| 4492 | else |
| 4493 | intel_dp->compliance_test_active = 0; |
| 4494 | } |
| 4495 | } |
| 4496 | out: |
| 4497 | kfree(input_buffer); |
| 4498 | if (status < 0) |
| 4499 | return status; |
| 4500 | |
| 4501 | *offp += len; |
| 4502 | return len; |
| 4503 | } |
| 4504 | |
| 4505 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 4506 | { |
| 4507 | struct drm_device *dev = m->private; |
| 4508 | struct drm_connector *connector; |
| 4509 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4510 | struct intel_dp *intel_dp; |
| 4511 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4512 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4513 | if (connector->connector_type != |
| 4514 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4515 | continue; |
| 4516 | |
| 4517 | if (connector->status == connector_status_connected && |
| 4518 | connector->encoder != NULL) { |
| 4519 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4520 | if (intel_dp->compliance_test_active) |
| 4521 | seq_puts(m, "1"); |
| 4522 | else |
| 4523 | seq_puts(m, "0"); |
| 4524 | } else |
| 4525 | seq_puts(m, "0"); |
| 4526 | } |
| 4527 | |
| 4528 | return 0; |
| 4529 | } |
| 4530 | |
| 4531 | static int i915_displayport_test_active_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4532 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4533 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4534 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4535 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4536 | return single_open(file, i915_displayport_test_active_show, |
| 4537 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4538 | } |
| 4539 | |
| 4540 | static const struct file_operations i915_displayport_test_active_fops = { |
| 4541 | .owner = THIS_MODULE, |
| 4542 | .open = i915_displayport_test_active_open, |
| 4543 | .read = seq_read, |
| 4544 | .llseek = seq_lseek, |
| 4545 | .release = single_release, |
| 4546 | .write = i915_displayport_test_active_write |
| 4547 | }; |
| 4548 | |
| 4549 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 4550 | { |
| 4551 | struct drm_device *dev = m->private; |
| 4552 | struct drm_connector *connector; |
| 4553 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4554 | struct intel_dp *intel_dp; |
| 4555 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4556 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4557 | if (connector->connector_type != |
| 4558 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4559 | continue; |
| 4560 | |
| 4561 | if (connector->status == connector_status_connected && |
| 4562 | connector->encoder != NULL) { |
| 4563 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4564 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 4565 | } else |
| 4566 | seq_puts(m, "0"); |
| 4567 | } |
| 4568 | |
| 4569 | return 0; |
| 4570 | } |
| 4571 | static int i915_displayport_test_data_open(struct inode *inode, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4572 | struct file *file) |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4573 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4574 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4575 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4576 | return single_open(file, i915_displayport_test_data_show, |
| 4577 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | static const struct file_operations i915_displayport_test_data_fops = { |
| 4581 | .owner = THIS_MODULE, |
| 4582 | .open = i915_displayport_test_data_open, |
| 4583 | .read = seq_read, |
| 4584 | .llseek = seq_lseek, |
| 4585 | .release = single_release |
| 4586 | }; |
| 4587 | |
| 4588 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 4589 | { |
| 4590 | struct drm_device *dev = m->private; |
| 4591 | struct drm_connector *connector; |
| 4592 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4593 | struct intel_dp *intel_dp; |
| 4594 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4595 | list_for_each_entry(connector, connector_list, head) { |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4596 | if (connector->connector_type != |
| 4597 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4598 | continue; |
| 4599 | |
| 4600 | if (connector->status == connector_status_connected && |
| 4601 | connector->encoder != NULL) { |
| 4602 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4603 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 4604 | } else |
| 4605 | seq_puts(m, "0"); |
| 4606 | } |
| 4607 | |
| 4608 | return 0; |
| 4609 | } |
| 4610 | |
| 4611 | static int i915_displayport_test_type_open(struct inode *inode, |
| 4612 | struct file *file) |
| 4613 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4614 | struct drm_i915_private *dev_priv = inode->i_private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4615 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4616 | return single_open(file, i915_displayport_test_type_show, |
| 4617 | &dev_priv->drm); |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4618 | } |
| 4619 | |
| 4620 | static const struct file_operations i915_displayport_test_type_fops = { |
| 4621 | .owner = THIS_MODULE, |
| 4622 | .open = i915_displayport_test_type_open, |
| 4623 | .read = seq_read, |
| 4624 | .llseek = seq_lseek, |
| 4625 | .release = single_release |
| 4626 | }; |
| 4627 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4628 | 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] | 4629 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4630 | struct drm_i915_private *dev_priv = m->private; |
| 4631 | struct drm_device *dev = &dev_priv->drm; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4632 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4633 | int num_levels; |
| 4634 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4635 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4636 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4637 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4638 | num_levels = 1; |
| 4639 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 4640 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4641 | |
| 4642 | drm_modeset_lock_all(dev); |
| 4643 | |
| 4644 | for (level = 0; level < num_levels; level++) { |
| 4645 | unsigned int latency = wm[level]; |
| 4646 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4647 | /* |
| 4648 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4649 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4650 | */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4651 | if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) || |
| 4652 | IS_CHERRYVIEW(dev_priv)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4653 | latency *= 10; |
| 4654 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4655 | latency *= 5; |
| 4656 | |
| 4657 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4658 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | drm_modeset_unlock_all(dev); |
| 4662 | } |
| 4663 | |
| 4664 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 4665 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4666 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4667 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4668 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4669 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4670 | latencies = dev_priv->wm.skl_latency; |
| 4671 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4672 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4673 | |
| 4674 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4675 | |
| 4676 | return 0; |
| 4677 | } |
| 4678 | |
| 4679 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4680 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4681 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4682 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4683 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4684 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4685 | latencies = dev_priv->wm.skl_latency; |
| 4686 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4687 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4688 | |
| 4689 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4690 | |
| 4691 | return 0; |
| 4692 | } |
| 4693 | |
| 4694 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4695 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4696 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4697 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4698 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4699 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4700 | latencies = dev_priv->wm.skl_latency; |
| 4701 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4702 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4703 | |
| 4704 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4705 | |
| 4706 | return 0; |
| 4707 | } |
| 4708 | |
| 4709 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4710 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4711 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4712 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4713 | if (INTEL_GEN(dev_priv) < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4714 | return -ENODEV; |
| 4715 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4716 | return single_open(file, pri_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4717 | } |
| 4718 | |
| 4719 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4720 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4721 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4722 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4723 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4724 | return -ENODEV; |
| 4725 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4726 | return single_open(file, spr_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4730 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4731 | struct drm_i915_private *dev_priv = inode->i_private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4732 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4733 | if (HAS_GMCH_DISPLAY(dev_priv)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4734 | return -ENODEV; |
| 4735 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4736 | return single_open(file, cur_wm_latency_show, dev_priv); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4737 | } |
| 4738 | |
| 4739 | 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] | 4740 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4741 | { |
| 4742 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4743 | struct drm_i915_private *dev_priv = m->private; |
| 4744 | struct drm_device *dev = &dev_priv->drm; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4745 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4746 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4747 | int level; |
| 4748 | int ret; |
| 4749 | char tmp[32]; |
| 4750 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4751 | if (IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4752 | num_levels = 3; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4753 | else if (IS_VALLEYVIEW(dev_priv)) |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4754 | num_levels = 1; |
| 4755 | else |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 4756 | num_levels = ilk_wm_max_level(dev_priv) + 1; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4757 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4758 | if (len >= sizeof(tmp)) |
| 4759 | return -EINVAL; |
| 4760 | |
| 4761 | if (copy_from_user(tmp, ubuf, len)) |
| 4762 | return -EFAULT; |
| 4763 | |
| 4764 | tmp[len] = '\0'; |
| 4765 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4766 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4767 | &new[0], &new[1], &new[2], &new[3], |
| 4768 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4769 | if (ret != num_levels) |
| 4770 | return -EINVAL; |
| 4771 | |
| 4772 | drm_modeset_lock_all(dev); |
| 4773 | |
| 4774 | for (level = 0; level < num_levels; level++) |
| 4775 | wm[level] = new[level]; |
| 4776 | |
| 4777 | drm_modeset_unlock_all(dev); |
| 4778 | |
| 4779 | return len; |
| 4780 | } |
| 4781 | |
| 4782 | |
| 4783 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4784 | size_t len, loff_t *offp) |
| 4785 | { |
| 4786 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4787 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4788 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4789 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4790 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4791 | latencies = dev_priv->wm.skl_latency; |
| 4792 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4793 | latencies = dev_priv->wm.pri_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4794 | |
| 4795 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4796 | } |
| 4797 | |
| 4798 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4799 | size_t len, loff_t *offp) |
| 4800 | { |
| 4801 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4802 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4803 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4804 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4805 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4806 | latencies = dev_priv->wm.skl_latency; |
| 4807 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4808 | latencies = dev_priv->wm.spr_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4809 | |
| 4810 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4811 | } |
| 4812 | |
| 4813 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4814 | size_t len, loff_t *offp) |
| 4815 | { |
| 4816 | struct seq_file *m = file->private_data; |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4817 | struct drm_i915_private *dev_priv = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4818 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4819 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4820 | if (INTEL_GEN(dev_priv) >= 9) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4821 | latencies = dev_priv->wm.skl_latency; |
| 4822 | else |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4823 | latencies = dev_priv->wm.cur_latency; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4824 | |
| 4825 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4826 | } |
| 4827 | |
| 4828 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4829 | .owner = THIS_MODULE, |
| 4830 | .open = pri_wm_latency_open, |
| 4831 | .read = seq_read, |
| 4832 | .llseek = seq_lseek, |
| 4833 | .release = single_release, |
| 4834 | .write = pri_wm_latency_write |
| 4835 | }; |
| 4836 | |
| 4837 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4838 | .owner = THIS_MODULE, |
| 4839 | .open = spr_wm_latency_open, |
| 4840 | .read = seq_read, |
| 4841 | .llseek = seq_lseek, |
| 4842 | .release = single_release, |
| 4843 | .write = spr_wm_latency_write |
| 4844 | }; |
| 4845 | |
| 4846 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4847 | .owner = THIS_MODULE, |
| 4848 | .open = cur_wm_latency_open, |
| 4849 | .read = seq_read, |
| 4850 | .llseek = seq_lseek, |
| 4851 | .release = single_release, |
| 4852 | .write = cur_wm_latency_write |
| 4853 | }; |
| 4854 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4855 | static int |
| 4856 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4857 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4858 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4859 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4860 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4861 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4862 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4863 | } |
| 4864 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4865 | static int |
| 4866 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4867 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4868 | struct drm_i915_private *dev_priv = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4869 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4870 | /* |
| 4871 | * There is no safeguard against this debugfs entry colliding |
| 4872 | * with the hangcheck calling same i915_handle_error() in |
| 4873 | * parallel, causing an explosion. For now we assume that the |
| 4874 | * test harness is responsible enough not to inject gpu hangs |
| 4875 | * while it is writing to 'i915_wedged' |
| 4876 | */ |
| 4877 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4878 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4879 | return -EAGAIN; |
| 4880 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4881 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4882 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4883 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4884 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4885 | } |
| 4886 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4887 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4888 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4889 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4890 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4891 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4892 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4893 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4894 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4895 | |
| 4896 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4897 | return 0; |
| 4898 | } |
| 4899 | |
| 4900 | static int |
| 4901 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4902 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4903 | struct drm_i915_private *dev_priv = data; |
| 4904 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4905 | int ret; |
| 4906 | |
| 4907 | /* Lock against concurrent debugfs callers */ |
| 4908 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4909 | if (ret) |
| 4910 | return ret; |
| 4911 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4912 | mutex_unlock(&dev->struct_mutex); |
| 4913 | |
| 4914 | return 0; |
| 4915 | } |
| 4916 | |
| 4917 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4918 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4919 | "0x%08llx\n"); |
| 4920 | |
| 4921 | static int |
| 4922 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4923 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4924 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4925 | |
| 4926 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4927 | |
| 4928 | return 0; |
| 4929 | } |
| 4930 | |
| 4931 | static int |
| 4932 | i915_ring_test_irq_set(void *data, u64 val) |
| 4933 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4934 | struct drm_i915_private *dev_priv = data; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4935 | |
Chris Wilson | 3a122c2 | 2016-06-17 14:35:05 +0100 | [diff] [blame] | 4936 | val &= INTEL_INFO(dev_priv)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4937 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4938 | dev_priv->gpu_error.test_irq_rings = val; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4939 | |
| 4940 | return 0; |
| 4941 | } |
| 4942 | |
| 4943 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4944 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4945 | "0x%08llx\n"); |
| 4946 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4947 | #define DROP_UNBOUND 0x1 |
| 4948 | #define DROP_BOUND 0x2 |
| 4949 | #define DROP_RETIRE 0x4 |
| 4950 | #define DROP_ACTIVE 0x8 |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 4951 | #define DROP_FREED 0x10 |
| 4952 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4953 | DROP_BOUND | \ |
| 4954 | DROP_RETIRE | \ |
| 4955 | DROP_ACTIVE | \ |
| 4956 | DROP_FREED) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4957 | static int |
| 4958 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4959 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4960 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4961 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4962 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4963 | } |
| 4964 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4965 | static int |
| 4966 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4967 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 4968 | struct drm_i915_private *dev_priv = data; |
| 4969 | struct drm_device *dev = &dev_priv->drm; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4970 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4971 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4972 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4973 | |
| 4974 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4975 | * on ioctls on -EAGAIN. */ |
| 4976 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4977 | if (ret) |
| 4978 | return ret; |
| 4979 | |
| 4980 | if (val & DROP_ACTIVE) { |
Chris Wilson | 22dd3bb | 2016-09-09 14:11:50 +0100 | [diff] [blame] | 4981 | ret = i915_gem_wait_for_idle(dev_priv, |
| 4982 | I915_WAIT_INTERRUPTIBLE | |
| 4983 | I915_WAIT_LOCKED); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4984 | if (ret) |
| 4985 | goto unlock; |
| 4986 | } |
| 4987 | |
| 4988 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4989 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4990 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4991 | if (val & DROP_BOUND) |
| 4992 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4993 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4994 | if (val & DROP_UNBOUND) |
| 4995 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4996 | |
| 4997 | unlock: |
| 4998 | mutex_unlock(&dev->struct_mutex); |
| 4999 | |
Chris Wilson | fbbd37b | 2016-10-28 13:58:42 +0100 | [diff] [blame] | 5000 | if (val & DROP_FREED) { |
| 5001 | synchronize_rcu(); |
| 5002 | flush_work(&dev_priv->mm.free_work); |
| 5003 | } |
| 5004 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5005 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 5006 | } |
| 5007 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5008 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 5009 | i915_drop_caches_get, i915_drop_caches_set, |
| 5010 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 5011 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5012 | static int |
| 5013 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5014 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5015 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5016 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5017 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5018 | return -ENODEV; |
| 5019 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 5020 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5021 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5022 | } |
| 5023 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5024 | static int |
| 5025 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5026 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5027 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5028 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5029 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5030 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5031 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5032 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5033 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5034 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5035 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5036 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5037 | if (ret) |
| 5038 | return ret; |
| 5039 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5040 | /* |
| 5041 | * Turbo will still be enabled, but won't go above the set value. |
| 5042 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5043 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5044 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5045 | hw_max = dev_priv->rps.max_freq; |
| 5046 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 5047 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5048 | 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] | 5049 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 5050 | return -EINVAL; |
| 5051 | } |
| 5052 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5053 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5054 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 5055 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5056 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5057 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5058 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5059 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5060 | } |
| 5061 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5062 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 5063 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 5064 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5065 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5066 | static int |
| 5067 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5068 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5069 | struct drm_i915_private *dev_priv = data; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5070 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 5071 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5072 | return -ENODEV; |
| 5073 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 5074 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5075 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5076 | } |
| 5077 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5078 | static int |
| 5079 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5080 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5081 | struct drm_i915_private *dev_priv = data; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5082 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5083 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5084 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 5085 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5086 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5087 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5088 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5089 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5090 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5091 | if (ret) |
| 5092 | return ret; |
| 5093 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5094 | /* |
| 5095 | * Turbo will still be enabled, but won't go below the set value. |
| 5096 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5097 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5098 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5099 | hw_max = dev_priv->rps.max_freq; |
| 5100 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5101 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5102 | if (val < hw_min || |
| 5103 | val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5104 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 5105 | return -EINVAL; |
| 5106 | } |
| 5107 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5108 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5109 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 5110 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5111 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5112 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5113 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5114 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5115 | } |
| 5116 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5117 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 5118 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 5119 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5120 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5121 | static int |
| 5122 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5123 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5124 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5125 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5126 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5127 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5128 | return -ENODEV; |
| 5129 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5130 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 5131 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5132 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5133 | |
| 5134 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5135 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5136 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5137 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5138 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5139 | } |
| 5140 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5141 | static int |
| 5142 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5143 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5144 | struct drm_i915_private *dev_priv = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5145 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5146 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5147 | if (!(IS_GEN6(dev_priv) || IS_GEN7(dev_priv))) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5148 | return -ENODEV; |
| 5149 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5150 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5151 | return -EINVAL; |
| 5152 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5153 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5154 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5155 | |
| 5156 | /* Update the cache sharing policy here as well */ |
| 5157 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 5158 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 5159 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 5160 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 5161 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5162 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5163 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5164 | } |
| 5165 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5166 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 5167 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 5168 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5169 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5170 | static void cherryview_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5171 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5172 | { |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 5173 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5174 | int ss; |
| 5175 | u32 sig1[ss_max], sig2[ss_max]; |
| 5176 | |
| 5177 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 5178 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 5179 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 5180 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 5181 | |
| 5182 | for (ss = 0; ss < ss_max; ss++) { |
| 5183 | unsigned int eu_cnt; |
| 5184 | |
| 5185 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 5186 | /* skip disabled subslice */ |
| 5187 | continue; |
| 5188 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5189 | sseu->slice_mask = BIT(0); |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5190 | sseu->subslice_mask |= BIT(ss); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5191 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 5192 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 5193 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 5194 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5195 | sseu->eu_total += eu_cnt; |
| 5196 | sseu->eu_per_subslice = max_t(unsigned int, |
| 5197 | sseu->eu_per_subslice, eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5198 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5199 | } |
| 5200 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5201 | static void gen9_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5202 | struct sseu_dev_info *sseu) |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5203 | { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5204 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5205 | int s, ss; |
| 5206 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 5207 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5208 | /* BXT has a single slice and at most 3 subslices. */ |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5209 | if (IS_BROXTON(dev_priv)) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5210 | s_max = 1; |
| 5211 | ss_max = 3; |
| 5212 | } |
| 5213 | |
| 5214 | for (s = 0; s < s_max; s++) { |
| 5215 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 5216 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 5217 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 5218 | } |
| 5219 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5220 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 5221 | GEN9_PGCTL_SSA_EU19_ACK | |
| 5222 | GEN9_PGCTL_SSA_EU210_ACK | |
| 5223 | GEN9_PGCTL_SSA_EU311_ACK; |
| 5224 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 5225 | GEN9_PGCTL_SSB_EU19_ACK | |
| 5226 | GEN9_PGCTL_SSB_EU210_ACK | |
| 5227 | GEN9_PGCTL_SSB_EU311_ACK; |
| 5228 | |
| 5229 | for (s = 0; s < s_max; s++) { |
| 5230 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 5231 | /* skip disabled slice */ |
| 5232 | continue; |
| 5233 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5234 | sseu->slice_mask |= BIT(s); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5235 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5236 | if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5237 | sseu->subslice_mask = |
| 5238 | INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5239 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5240 | for (ss = 0; ss < ss_max; ss++) { |
| 5241 | unsigned int eu_cnt; |
| 5242 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5243 | if (IS_BROXTON(dev_priv)) { |
| 5244 | if (!(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 5245 | /* skip disabled subslice */ |
| 5246 | continue; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5247 | |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5248 | sseu->subslice_mask |= BIT(ss); |
| 5249 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5250 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5251 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 5252 | eu_mask[ss%2]); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5253 | sseu->eu_total += eu_cnt; |
| 5254 | sseu->eu_per_subslice = max_t(unsigned int, |
| 5255 | sseu->eu_per_subslice, |
| 5256 | eu_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5257 | } |
| 5258 | } |
| 5259 | } |
| 5260 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5261 | static void broadwell_sseu_device_status(struct drm_i915_private *dev_priv, |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5262 | struct sseu_dev_info *sseu) |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5263 | { |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5264 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5265 | int s; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5266 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5267 | sseu->slice_mask = slice_info & GEN8_LSLICESTAT_MASK; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5268 | |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5269 | if (sseu->slice_mask) { |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5270 | sseu->subslice_mask = INTEL_INFO(dev_priv)->sseu.subslice_mask; |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 5271 | sseu->eu_per_subslice = |
| 5272 | INTEL_INFO(dev_priv)->sseu.eu_per_subslice; |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5273 | sseu->eu_total = sseu->eu_per_subslice * |
| 5274 | sseu_subslice_total(sseu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5275 | |
| 5276 | /* subtract fused off EU(s) from enabled slice(s) */ |
Imre Deak | 795b38b | 2016-08-31 19:13:07 +0300 | [diff] [blame] | 5277 | for (s = 0; s < fls(sseu->slice_mask); s++) { |
Imre Deak | 43b6799 | 2016-08-31 19:13:02 +0300 | [diff] [blame] | 5278 | u8 subslice_7eu = |
| 5279 | INTEL_INFO(dev_priv)->sseu.subslice_7eu[s]; |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5280 | |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5281 | sseu->eu_total -= hweight8(subslice_7eu); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5282 | } |
| 5283 | } |
| 5284 | } |
| 5285 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5286 | static void i915_print_sseu_info(struct seq_file *m, bool is_available_info, |
| 5287 | const struct sseu_dev_info *sseu) |
| 5288 | { |
| 5289 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
| 5290 | const char *type = is_available_info ? "Available" : "Enabled"; |
| 5291 | |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 5292 | seq_printf(m, " %s Slice Mask: %04x\n", type, |
| 5293 | sseu->slice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5294 | seq_printf(m, " %s Slice Total: %u\n", type, |
Imre Deak | f08a0c9 | 2016-08-31 19:13:04 +0300 | [diff] [blame] | 5295 | hweight8(sseu->slice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5296 | seq_printf(m, " %s Subslice Total: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5297 | sseu_subslice_total(sseu)); |
Imre Deak | c67ba53 | 2016-08-31 19:13:06 +0300 | [diff] [blame] | 5298 | seq_printf(m, " %s Subslice Mask: %04x\n", type, |
| 5299 | sseu->subslice_mask); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5300 | seq_printf(m, " %s Subslice Per Slice: %u\n", type, |
Imre Deak | 57ec171 | 2016-08-31 19:13:05 +0300 | [diff] [blame] | 5301 | hweight8(sseu->subslice_mask)); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5302 | seq_printf(m, " %s EU Total: %u\n", type, |
| 5303 | sseu->eu_total); |
| 5304 | seq_printf(m, " %s EU Per Subslice: %u\n", type, |
| 5305 | sseu->eu_per_subslice); |
| 5306 | |
| 5307 | if (!is_available_info) |
| 5308 | return; |
| 5309 | |
| 5310 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev_priv))); |
| 5311 | if (HAS_POOLED_EU(dev_priv)) |
| 5312 | seq_printf(m, " Min EU in pool: %u\n", sseu->min_eu_in_pool); |
| 5313 | |
| 5314 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 5315 | yesno(sseu->has_slice_pg)); |
| 5316 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 5317 | yesno(sseu->has_subslice_pg)); |
| 5318 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 5319 | yesno(sseu->has_eu_pg)); |
| 5320 | } |
| 5321 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5322 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 5323 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5324 | struct drm_i915_private *dev_priv = node_to_i915(m->private); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5325 | struct sseu_dev_info sseu; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5326 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5327 | if (INTEL_GEN(dev_priv) < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5328 | return -ENODEV; |
| 5329 | |
| 5330 | seq_puts(m, "SSEU Device Info\n"); |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5331 | i915_print_sseu_info(m, true, &INTEL_INFO(dev_priv)->sseu); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5332 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5333 | seq_puts(m, "SSEU Device Status\n"); |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5334 | memset(&sseu, 0, sizeof(sseu)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5335 | |
| 5336 | intel_runtime_pm_get(dev_priv); |
| 5337 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5338 | if (IS_CHERRYVIEW(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5339 | cherryview_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5340 | } else if (IS_BROADWELL(dev_priv)) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5341 | broadwell_sseu_device_status(dev_priv, &sseu); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5342 | } else if (INTEL_GEN(dev_priv) >= 9) { |
Imre Deak | 915490d | 2016-08-31 19:13:01 +0300 | [diff] [blame] | 5343 | gen9_sseu_device_status(dev_priv, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5344 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5345 | |
| 5346 | intel_runtime_pm_put(dev_priv); |
| 5347 | |
Imre Deak | 615d890 | 2016-08-31 19:13:03 +0300 | [diff] [blame] | 5348 | i915_print_sseu_info(m, false, &sseu); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5349 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5350 | return 0; |
| 5351 | } |
| 5352 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5353 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 5354 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5355 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5356 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5357 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5358 | return 0; |
| 5359 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5360 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5361 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5362 | |
| 5363 | return 0; |
| 5364 | } |
| 5365 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 5366 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5367 | { |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5368 | struct drm_i915_private *dev_priv = inode->i_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5369 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5370 | if (INTEL_GEN(dev_priv) < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5371 | return 0; |
| 5372 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5373 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5374 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5375 | |
| 5376 | return 0; |
| 5377 | } |
| 5378 | |
| 5379 | static const struct file_operations i915_forcewake_fops = { |
| 5380 | .owner = THIS_MODULE, |
| 5381 | .open = i915_forcewake_open, |
| 5382 | .release = i915_forcewake_release, |
| 5383 | }; |
| 5384 | |
| 5385 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 5386 | { |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5387 | struct dentry *ent; |
| 5388 | |
| 5389 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5390 | S_IRUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5391 | root, to_i915(minor->dev), |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5392 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5393 | if (!ent) |
| 5394 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5395 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5396 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5397 | } |
| 5398 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5399 | static int i915_debugfs_create(struct dentry *root, |
| 5400 | struct drm_minor *minor, |
| 5401 | const char *name, |
| 5402 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5403 | { |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5404 | struct dentry *ent; |
| 5405 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5406 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5407 | S_IRUGO | S_IWUSR, |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5408 | root, to_i915(minor->dev), |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5409 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5410 | if (!ent) |
| 5411 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5412 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5413 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5414 | } |
| 5415 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5416 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 5417 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 5418 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 5419 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 6da8482 | 2016-08-15 10:48:44 +0100 | [diff] [blame] | 5420 | {"i915_gem_pin_display", i915_gem_gtt_info, 0, (void *)1}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 5421 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 5422 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5423 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 5424 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 5425 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5426 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 5427 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 5428 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 5429 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 5430 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 5431 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 5432 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 5433 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 5434 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 5435 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 5436 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 5437 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 5438 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 5439 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 5440 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 5441 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 5442 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 5443 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 5444 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 5445 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 5446 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 5447 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 5448 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 5449 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 5450 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 5451 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 5452 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 5453 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 5454 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 5455 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 5456 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 5457 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 5458 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 5459 | {"i915_display_info", i915_display_info, 0}, |
Chris Wilson | 1b36595 | 2016-10-04 21:11:31 +0100 | [diff] [blame] | 5460 | {"i915_engine_info", i915_engine_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 5461 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 5462 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 5463 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 5464 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 5465 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5466 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 5467 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 5468 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5469 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5470 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5471 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5472 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5473 | const char *name; |
| 5474 | const struct file_operations *fops; |
| 5475 | } i915_debugfs_files[] = { |
| 5476 | {"i915_wedged", &i915_wedged_fops}, |
| 5477 | {"i915_max_freq", &i915_max_freq_fops}, |
| 5478 | {"i915_min_freq", &i915_min_freq_fops}, |
| 5479 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 5480 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 5481 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5482 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 5483 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5484 | {"i915_error_state", &i915_error_state_fops}, |
Chris Wilson | 98a2f41 | 2016-10-12 10:05:18 +0100 | [diff] [blame] | 5485 | #endif |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5486 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 5487 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 5488 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 5489 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 5490 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 5491 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 5492 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 5493 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
Sagar Arun Kamble | 685534e | 2016-10-12 21:54:41 +0530 | [diff] [blame] | 5494 | {"i915_dp_test_active", &i915_displayport_test_active_fops}, |
| 5495 | {"i915_guc_log_control", &i915_guc_log_control_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5496 | }; |
| 5497 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5498 | void intel_display_crc_init(struct drm_i915_private *dev_priv) |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5499 | { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5500 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5501 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 5502 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5503 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5504 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 5505 | pipe_crc->opened = false; |
| 5506 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5507 | init_waitqueue_head(&pipe_crc->wq); |
| 5508 | } |
| 5509 | } |
| 5510 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 5511 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5512 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5513 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5514 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 5515 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5516 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 5517 | if (ret) |
| 5518 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5519 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5520 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 5521 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 5522 | if (ret) |
| 5523 | return ret; |
| 5524 | } |
| 5525 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5526 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5527 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 5528 | i915_debugfs_files[i].name, |
| 5529 | i915_debugfs_files[i].fops); |
| 5530 | if (ret) |
| 5531 | return ret; |
| 5532 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 5533 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5534 | return drm_debugfs_create_files(i915_debugfs_list, |
| 5535 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5536 | minor->debugfs_root, minor); |
| 5537 | } |
| 5538 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 5539 | void i915_debugfs_unregister(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5540 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5541 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5542 | int i; |
| 5543 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5544 | drm_debugfs_remove_files(i915_debugfs_list, |
| 5545 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5546 | |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5547 | drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5548 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5549 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 5550 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5551 | struct drm_info_list *info_list = |
| 5552 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 5553 | |
| 5554 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5555 | } |
| 5556 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5557 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5558 | struct drm_info_list *info_list = |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 5559 | (struct drm_info_list *)i915_debugfs_files[i].fops; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5560 | |
| 5561 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5562 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5563 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5564 | |
| 5565 | struct dpcd_block { |
| 5566 | /* DPCD dump start address. */ |
| 5567 | unsigned int offset; |
| 5568 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 5569 | unsigned int end; |
| 5570 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 5571 | size_t size; |
| 5572 | /* Only valid for eDP. */ |
| 5573 | bool edp; |
| 5574 | }; |
| 5575 | |
| 5576 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 5577 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 5578 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 5579 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 5580 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 5581 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 5582 | { .offset = DP_SET_POWER }, |
| 5583 | { .offset = DP_EDP_DPCD_REV }, |
| 5584 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 5585 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 5586 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 5587 | }; |
| 5588 | |
| 5589 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 5590 | { |
| 5591 | struct drm_connector *connector = m->private; |
| 5592 | struct intel_dp *intel_dp = |
| 5593 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5594 | uint8_t buf[16]; |
| 5595 | ssize_t err; |
| 5596 | int i; |
| 5597 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 5598 | if (connector->status != connector_status_connected) |
| 5599 | return -ENODEV; |
| 5600 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5601 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 5602 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 5603 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 5604 | |
| 5605 | if (b->edp && |
| 5606 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 5607 | continue; |
| 5608 | |
| 5609 | /* low tech for now */ |
| 5610 | if (WARN_ON(size > sizeof(buf))) |
| 5611 | continue; |
| 5612 | |
| 5613 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 5614 | if (err <= 0) { |
| 5615 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 5616 | size, b->offset, err); |
| 5617 | continue; |
| 5618 | } |
| 5619 | |
| 5620 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 5621 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5622 | |
| 5623 | return 0; |
| 5624 | } |
| 5625 | |
| 5626 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5627 | { |
| 5628 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5629 | } |
| 5630 | |
| 5631 | static const struct file_operations i915_dpcd_fops = { |
| 5632 | .owner = THIS_MODULE, |
| 5633 | .open = i915_dpcd_open, |
| 5634 | .read = seq_read, |
| 5635 | .llseek = seq_lseek, |
| 5636 | .release = single_release, |
| 5637 | }; |
| 5638 | |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5639 | static int i915_panel_show(struct seq_file *m, void *data) |
| 5640 | { |
| 5641 | struct drm_connector *connector = m->private; |
| 5642 | struct intel_dp *intel_dp = |
| 5643 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5644 | |
| 5645 | if (connector->status != connector_status_connected) |
| 5646 | return -ENODEV; |
| 5647 | |
| 5648 | seq_printf(m, "Panel power up delay: %d\n", |
| 5649 | intel_dp->panel_power_up_delay); |
| 5650 | seq_printf(m, "Panel power down delay: %d\n", |
| 5651 | intel_dp->panel_power_down_delay); |
| 5652 | seq_printf(m, "Backlight on delay: %d\n", |
| 5653 | intel_dp->backlight_on_delay); |
| 5654 | seq_printf(m, "Backlight off delay: %d\n", |
| 5655 | intel_dp->backlight_off_delay); |
| 5656 | |
| 5657 | return 0; |
| 5658 | } |
| 5659 | |
| 5660 | static int i915_panel_open(struct inode *inode, struct file *file) |
| 5661 | { |
| 5662 | return single_open(file, i915_panel_show, inode->i_private); |
| 5663 | } |
| 5664 | |
| 5665 | static const struct file_operations i915_panel_fops = { |
| 5666 | .owner = THIS_MODULE, |
| 5667 | .open = i915_panel_open, |
| 5668 | .read = seq_read, |
| 5669 | .llseek = seq_lseek, |
| 5670 | .release = single_release, |
| 5671 | }; |
| 5672 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5673 | /** |
| 5674 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5675 | * @connector: pointer to a registered drm_connector |
| 5676 | * |
| 5677 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5678 | * drm_debugfs_connector_remove(). |
| 5679 | * |
| 5680 | * Returns 0 on success, negative error codes on error. |
| 5681 | */ |
| 5682 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5683 | { |
| 5684 | struct dentry *root = connector->debugfs_entry; |
| 5685 | |
| 5686 | /* The connector must have been registered beforehands. */ |
| 5687 | if (!root) |
| 5688 | return -ENODEV; |
| 5689 | |
| 5690 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5691 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
David Weinehall | ecbd678 | 2016-08-23 12:23:56 +0300 | [diff] [blame] | 5692 | debugfs_create_file("i915_dpcd", S_IRUGO, root, |
| 5693 | connector, &i915_dpcd_fops); |
| 5694 | |
| 5695 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5696 | debugfs_create_file("i915_panel_timings", S_IRUGO, root, |
| 5697 | connector, &i915_panel_fops); |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5698 | |
| 5699 | return 0; |
| 5700 | } |