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 | |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 43 | enum { |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 44 | ACTIVE_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 45 | INACTIVE_LIST, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 46 | PINNED_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 47 | }; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 48 | |
Damien Lespiau | 497666d | 2013-10-15 18:55:39 +0100 | [diff] [blame] | 49 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 50 | * allocated we need to hook into the minor for release. */ |
| 51 | static int |
| 52 | drm_add_fake_info_node(struct drm_minor *minor, |
| 53 | struct dentry *ent, |
| 54 | const void *key) |
| 55 | { |
| 56 | struct drm_info_node *node; |
| 57 | |
| 58 | node = kmalloc(sizeof(*node), GFP_KERNEL); |
| 59 | if (node == NULL) { |
| 60 | debugfs_remove(ent); |
| 61 | return -ENOMEM; |
| 62 | } |
| 63 | |
| 64 | node->minor = minor; |
| 65 | node->dent = ent; |
| 66 | node->info_ent = (void *) key; |
| 67 | |
| 68 | mutex_lock(&minor->debugfs_lock); |
| 69 | list_add(&node->list, &minor->debugfs_list); |
| 70 | mutex_unlock(&minor->debugfs_lock); |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 75 | static int i915_capabilities(struct seq_file *m, void *data) |
| 76 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 77 | struct drm_info_node *node = m->private; |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 78 | struct drm_device *dev = node->minor->dev; |
| 79 | const struct intel_device_info *info = INTEL_INFO(dev); |
| 80 | |
| 81 | seq_printf(m, "gen: %d\n", info->gen); |
Paulo Zanoni | 03d00ac | 2011-10-14 18:17:41 -0300 | [diff] [blame] | 82 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev)); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 83 | #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
| 84 | #define SEP_SEMICOLON ; |
| 85 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON); |
| 86 | #undef PRINT_FLAG |
| 87 | #undef SEP_SEMICOLON |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 88 | |
| 89 | return 0; |
| 90 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 91 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 92 | static char get_active_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 93 | { |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 94 | return obj->active ? '*' : ' '; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 97 | static char get_pin_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 98 | { |
| 99 | return obj->pin_display ? 'p' : ' '; |
| 100 | } |
| 101 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 102 | static char get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 103 | { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 104 | switch (obj->tiling_mode) { |
| 105 | default: |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 106 | case I915_TILING_NONE: return ' '; |
| 107 | case I915_TILING_X: return 'X'; |
| 108 | case I915_TILING_Y: return 'Y'; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 109 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 112 | static char get_global_flag(struct drm_i915_gem_object *obj) |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 113 | { |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 114 | return i915_gem_obj_to_ggtt(obj) ? 'g' : ' '; |
| 115 | } |
| 116 | |
Imre Deak | a7363de | 2016-05-12 16:18:52 +0300 | [diff] [blame] | 117 | static char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 118 | { |
| 119 | return obj->mapping ? 'M' : ' '; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 122 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 123 | { |
| 124 | u64 size = 0; |
| 125 | struct i915_vma *vma; |
| 126 | |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 127 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame^] | 128 | if (i915_vma_is_ggtt(vma) && drm_mm_node_allocated(&vma->node)) |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 129 | size += vma->node.size; |
| 130 | } |
| 131 | |
| 132 | return size; |
| 133 | } |
| 134 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 135 | static void |
| 136 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 137 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 138 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 139 | struct intel_engine_cs *engine; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 140 | struct i915_vma *vma; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 141 | int pin_count = 0; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 142 | enum intel_engine_id id; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 143 | |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 144 | lockdep_assert_held(&obj->base.dev->struct_mutex); |
| 145 | |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 146 | seq_printf(m, "%pK: %c%c%c%c%c %8zdKiB %02x %02x [ ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 147 | &obj->base, |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 148 | get_active_flag(obj), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 149 | get_pin_flag(obj), |
| 150 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 151 | get_global_flag(obj), |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 152 | get_pin_mapped_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 153 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 154 | obj->base.read_domains, |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 155 | obj->base.write_domain); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 156 | for_each_engine_id(engine, dev_priv, id) |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 157 | seq_printf(m, "%x ", |
Chris Wilson | d72d908 | 2016-08-04 07:52:31 +0100 | [diff] [blame] | 158 | i915_gem_active_get_seqno(&obj->last_read[id], |
| 159 | &obj->base.dev->struct_mutex)); |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 160 | seq_printf(m, "] %x %x%s%s%s", |
Chris Wilson | d72d908 | 2016-08-04 07:52:31 +0100 | [diff] [blame] | 161 | i915_gem_active_get_seqno(&obj->last_write, |
| 162 | &obj->base.dev->struct_mutex), |
| 163 | i915_gem_active_get_seqno(&obj->last_fence, |
| 164 | &obj->base.dev->struct_mutex), |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 165 | i915_cache_level_str(to_i915(obj->base.dev), obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 166 | obj->dirty ? " dirty" : "", |
| 167 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 168 | if (obj->base.name) |
| 169 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 170 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 20dfbde | 2016-08-04 16:32:30 +0100 | [diff] [blame] | 171 | if (i915_vma_is_pinned(vma)) |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 172 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 173 | } |
| 174 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 175 | if (obj->pin_display) |
| 176 | seq_printf(m, " (display)"); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 177 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 178 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 179 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 180 | if (!drm_mm_node_allocated(&vma->node)) |
| 181 | continue; |
| 182 | |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 183 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame^] | 184 | i915_vma_is_ggtt(vma) ? "g" : "pp", |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 185 | vma->node.start, vma->node.size); |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame^] | 186 | if (i915_vma_is_ggtt(vma)) |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 187 | seq_printf(m, ", type: %u", vma->ggtt_view.type); |
| 188 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 189 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 190 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 191 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 192 | if (obj->pin_display || obj->fault_mappable) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 193 | char s[3], *t = s; |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 194 | if (obj->pin_display) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 195 | *t++ = 'p'; |
| 196 | if (obj->fault_mappable) |
| 197 | *t++ = 'f'; |
| 198 | *t = '\0'; |
| 199 | seq_printf(m, " (%s mappable)", s); |
| 200 | } |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 201 | |
Chris Wilson | d72d908 | 2016-08-04 07:52:31 +0100 | [diff] [blame] | 202 | engine = i915_gem_active_get_engine(&obj->last_write, |
| 203 | &obj->base.dev->struct_mutex); |
Chris Wilson | 27c01aa | 2016-08-04 07:52:30 +0100 | [diff] [blame] | 204 | if (engine) |
| 205 | seq_printf(m, " (%s)", engine->name); |
| 206 | |
Daniel Vetter | d5a81ef | 2014-06-18 14:46:49 +0200 | [diff] [blame] | 207 | if (obj->frontbuffer_bits) |
| 208 | seq_printf(m, " (frontbuffer: 0x%03x)", obj->frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 209 | } |
| 210 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 211 | static int i915_gem_object_list_info(struct seq_file *m, void *data) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 212 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 213 | struct drm_info_node *node = m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 214 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 215 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 216 | struct drm_device *dev = node->minor->dev; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 217 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 218 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 219 | struct i915_vma *vma; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 220 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 221 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 222 | |
| 223 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 224 | if (ret) |
| 225 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 226 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 227 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 228 | switch (list) { |
| 229 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 230 | seq_puts(m, "Active:\n"); |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 231 | head = &ggtt->base.active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 232 | break; |
| 233 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 234 | seq_puts(m, "Inactive:\n"); |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 235 | head = &ggtt->base.inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 236 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 237 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 238 | mutex_unlock(&dev->struct_mutex); |
| 239 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 240 | } |
| 241 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 242 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 243 | list_for_each_entry(vma, head, vm_link) { |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 244 | seq_printf(m, " "); |
| 245 | describe_obj(m, vma->obj); |
| 246 | seq_printf(m, "\n"); |
| 247 | total_obj_size += vma->obj->base.size; |
| 248 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 249 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 250 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 251 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 252 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 253 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 254 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 255 | return 0; |
| 256 | } |
| 257 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 258 | static int obj_rank_by_stolen(void *priv, |
| 259 | struct list_head *A, struct list_head *B) |
| 260 | { |
| 261 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 262 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 263 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 264 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 265 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 266 | if (a->stolen->start < b->stolen->start) |
| 267 | return -1; |
| 268 | if (a->stolen->start > b->stolen->start) |
| 269 | return 1; |
| 270 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 274 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 275 | struct drm_info_node *node = m->private; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 276 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 277 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 278 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 279 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | LIST_HEAD(stolen); |
| 281 | int count, ret; |
| 282 | |
| 283 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 284 | if (ret) |
| 285 | return ret; |
| 286 | |
| 287 | total_obj_size = total_gtt_size = count = 0; |
| 288 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 289 | if (obj->stolen == NULL) |
| 290 | continue; |
| 291 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 292 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 293 | |
| 294 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 295 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 296 | count++; |
| 297 | } |
| 298 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 299 | if (obj->stolen == NULL) |
| 300 | continue; |
| 301 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 302 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 303 | |
| 304 | total_obj_size += obj->base.size; |
| 305 | count++; |
| 306 | } |
| 307 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 308 | seq_puts(m, "Stolen:\n"); |
| 309 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 310 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 311 | seq_puts(m, " "); |
| 312 | describe_obj(m, obj); |
| 313 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 314 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 315 | } |
| 316 | mutex_unlock(&dev->struct_mutex); |
| 317 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 318 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 319 | count, total_obj_size, total_gtt_size); |
| 320 | return 0; |
| 321 | } |
| 322 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 323 | #define count_objects(list, member) do { \ |
| 324 | list_for_each_entry(obj, list, member) { \ |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 325 | size += i915_gem_obj_total_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 326 | ++count; \ |
| 327 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 328 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 329 | ++mappable_count; \ |
| 330 | } \ |
| 331 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 332 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 333 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 334 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 335 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 336 | unsigned long count; |
| 337 | u64 total, unbound; |
| 338 | u64 global, shared; |
| 339 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | static int per_file_stats(int id, void *ptr, void *data) |
| 343 | { |
| 344 | struct drm_i915_gem_object *obj = ptr; |
| 345 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 346 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 347 | |
| 348 | stats->count++; |
| 349 | stats->total += obj->base.size; |
Chris Wilson | 15717de | 2016-08-04 07:52:26 +0100 | [diff] [blame] | 350 | if (!obj->bind_count) |
| 351 | stats->unbound += obj->base.size; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 352 | if (obj->base.name || obj->base.dma_buf) |
| 353 | stats->shared += obj->base.size; |
| 354 | |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 355 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
| 356 | if (!drm_mm_node_allocated(&vma->node)) |
| 357 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 358 | |
Chris Wilson | 3272db5 | 2016-08-04 16:32:32 +0100 | [diff] [blame^] | 359 | if (i915_vma_is_ggtt(vma)) { |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 360 | stats->global += vma->node.size; |
| 361 | } else { |
| 362 | struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vma->vm); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 363 | |
Chris Wilson | 2bfa996 | 2016-08-04 07:52:25 +0100 | [diff] [blame] | 364 | if (ppgtt->base.file != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 365 | continue; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 366 | } |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 367 | |
Chris Wilson | b0decaf | 2016-08-04 07:52:44 +0100 | [diff] [blame] | 368 | if (i915_vma_is_active(vma)) |
Chris Wilson | 894eeec | 2016-08-04 07:52:20 +0100 | [diff] [blame] | 369 | stats->active += vma->node.size; |
| 370 | else |
| 371 | stats->inactive += vma->node.size; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | return 0; |
| 375 | } |
| 376 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 377 | #define print_file_stats(m, name, stats) do { \ |
| 378 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 379 | 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] | 380 | name, \ |
| 381 | stats.count, \ |
| 382 | stats.total, \ |
| 383 | stats.active, \ |
| 384 | stats.inactive, \ |
| 385 | stats.global, \ |
| 386 | stats.shared, \ |
| 387 | stats.unbound); \ |
| 388 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 389 | |
| 390 | static void print_batch_pool_stats(struct seq_file *m, |
| 391 | struct drm_i915_private *dev_priv) |
| 392 | { |
| 393 | struct drm_i915_gem_object *obj; |
| 394 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 395 | struct intel_engine_cs *engine; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 396 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 397 | |
| 398 | memset(&stats, 0, sizeof(stats)); |
| 399 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 400 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 401 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 402 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 403 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 404 | batch_pool_link) |
| 405 | per_file_stats(0, obj, &stats); |
| 406 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 407 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 408 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 409 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 412 | static int per_file_ctx_stats(int id, void *ptr, void *data) |
| 413 | { |
| 414 | struct i915_gem_context *ctx = ptr; |
| 415 | int n; |
| 416 | |
| 417 | for (n = 0; n < ARRAY_SIZE(ctx->engine); n++) { |
| 418 | if (ctx->engine[n].state) |
| 419 | per_file_stats(0, ctx->engine[n].state, data); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 420 | if (ctx->engine[n].ring) |
| 421 | per_file_stats(0, ctx->engine[n].ring->obj, data); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | static void print_context_stats(struct seq_file *m, |
| 428 | struct drm_i915_private *dev_priv) |
| 429 | { |
| 430 | struct file_stats stats; |
| 431 | struct drm_file *file; |
| 432 | |
| 433 | memset(&stats, 0, sizeof(stats)); |
| 434 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 435 | mutex_lock(&dev_priv->drm.struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 436 | if (dev_priv->kernel_context) |
| 437 | per_file_ctx_stats(0, dev_priv->kernel_context, &stats); |
| 438 | |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 439 | list_for_each_entry(file, &dev_priv->drm.filelist, lhead) { |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 440 | struct drm_i915_file_private *fpriv = file->driver_priv; |
| 441 | idr_for_each(&fpriv->context_idr, per_file_ctx_stats, &stats); |
| 442 | } |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 443 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 444 | |
| 445 | print_file_stats(m, "[k]contexts", stats); |
| 446 | } |
| 447 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 448 | #define count_vmas(list, member) do { \ |
| 449 | list_for_each_entry(vma, list, member) { \ |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 450 | size += i915_gem_obj_total_ggtt_size(vma->obj); \ |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 451 | ++count; \ |
| 452 | if (vma->obj->map_and_fenceable) { \ |
| 453 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 454 | ++mappable_count; \ |
| 455 | } \ |
| 456 | } \ |
| 457 | } while (0) |
| 458 | |
| 459 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 460 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 461 | struct drm_info_node *node = m->private; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 462 | struct drm_device *dev = node->minor->dev; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 463 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 464 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 465 | u32 count, mappable_count, purgeable_count; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 466 | u64 size, mappable_size, purgeable_size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 467 | unsigned long pin_mapped_count = 0, pin_mapped_purgeable_count = 0; |
| 468 | u64 pin_mapped_size = 0, pin_mapped_purgeable_size = 0; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 469 | struct drm_i915_gem_object *obj; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 470 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 471 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 472 | int ret; |
| 473 | |
| 474 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 475 | if (ret) |
| 476 | return ret; |
| 477 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 478 | seq_printf(m, "%u objects, %zu bytes\n", |
| 479 | dev_priv->mm.object_count, |
| 480 | dev_priv->mm.object_memory); |
| 481 | |
| 482 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 483 | count_objects(&dev_priv->mm.bound_list, global_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 484 | seq_printf(m, "%u [%u] objects, %llu [%llu] bytes in gtt\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 485 | count, mappable_count, size, mappable_size); |
| 486 | |
| 487 | size = count = mappable_size = mappable_count = 0; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 488 | count_vmas(&ggtt->base.active_list, vm_link); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 489 | seq_printf(m, " %u [%u] active objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 490 | count, mappable_count, size, mappable_size); |
| 491 | |
| 492 | size = count = mappable_size = mappable_count = 0; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 493 | count_vmas(&ggtt->base.inactive_list, vm_link); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 494 | seq_printf(m, " %u [%u] inactive objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 495 | count, mappable_count, size, mappable_size); |
| 496 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 497 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 498 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 499 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 500 | if (obj->madv == I915_MADV_DONTNEED) |
| 501 | purgeable_size += obj->base.size, ++purgeable_count; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 502 | if (obj->mapping) { |
| 503 | pin_mapped_count++; |
| 504 | pin_mapped_size += obj->base.size; |
| 505 | if (obj->pages_pin_count == 0) { |
| 506 | pin_mapped_purgeable_count++; |
| 507 | pin_mapped_purgeable_size += obj->base.size; |
| 508 | } |
| 509 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 510 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 511 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 512 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 513 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 514 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 515 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 516 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 517 | ++count; |
| 518 | } |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 519 | if (obj->pin_display) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 520 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 521 | ++mappable_count; |
| 522 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 523 | if (obj->madv == I915_MADV_DONTNEED) { |
| 524 | purgeable_size += obj->base.size; |
| 525 | ++purgeable_count; |
| 526 | } |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 527 | if (obj->mapping) { |
| 528 | pin_mapped_count++; |
| 529 | pin_mapped_size += obj->base.size; |
| 530 | if (obj->pages_pin_count == 0) { |
| 531 | pin_mapped_purgeable_count++; |
| 532 | pin_mapped_purgeable_size += obj->base.size; |
| 533 | } |
| 534 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 535 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 536 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 537 | purgeable_count, purgeable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 538 | seq_printf(m, "%u pinned mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 539 | mappable_count, mappable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 540 | seq_printf(m, "%u fault mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 541 | count, size); |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 542 | seq_printf(m, |
| 543 | "%lu [%lu] pin mapped objects, %llu [%llu] bytes [purgeable]\n", |
| 544 | pin_mapped_count, pin_mapped_purgeable_count, |
| 545 | pin_mapped_size, pin_mapped_purgeable_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 546 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 547 | seq_printf(m, "%llu [%llu] gtt total\n", |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 548 | ggtt->base.total, ggtt->mappable_end - ggtt->base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 549 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 550 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 551 | print_batch_pool_stats(m, dev_priv); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 552 | mutex_unlock(&dev->struct_mutex); |
| 553 | |
| 554 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 15da956 | 2016-05-24 14:53:43 +0100 | [diff] [blame] | 555 | print_context_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 556 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 557 | struct file_stats stats; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 558 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 559 | |
| 560 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 561 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 562 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 563 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 564 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 565 | /* |
| 566 | * Although we have a valid reference on file->pid, that does |
| 567 | * not guarantee that the task_struct who called get_pid() is |
| 568 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 569 | * Therefore, we need to protect this ->comm access using RCU. |
| 570 | */ |
| 571 | rcu_read_lock(); |
| 572 | task = pid_task(file->pid, PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 573 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 574 | rcu_read_unlock(); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 575 | } |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 576 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 577 | |
| 578 | return 0; |
| 579 | } |
| 580 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 581 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 582 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 583 | struct drm_info_node *node = m->private; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 584 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 585 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 586 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 587 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 588 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 589 | int count, ret; |
| 590 | |
| 591 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 592 | if (ret) |
| 593 | return ret; |
| 594 | |
| 595 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 596 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 597 | if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj)) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 598 | continue; |
| 599 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 600 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 601 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 602 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 603 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 604 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 605 | count++; |
| 606 | } |
| 607 | |
| 608 | mutex_unlock(&dev->struct_mutex); |
| 609 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 610 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 611 | count, total_obj_size, total_gtt_size); |
| 612 | |
| 613 | return 0; |
| 614 | } |
| 615 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 616 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 617 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 618 | struct drm_info_node *node = m->private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 619 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 620 | struct drm_i915_private *dev_priv = to_i915(dev); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 621 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 622 | int ret; |
| 623 | |
| 624 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 625 | if (ret) |
| 626 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 627 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 628 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 629 | const char pipe = pipe_name(crtc->pipe); |
| 630 | const char plane = plane_name(crtc->plane); |
Maarten Lankhorst | 51cbaf0 | 2016-05-17 15:07:49 +0200 | [diff] [blame] | 631 | struct intel_flip_work *work; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 632 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 633 | spin_lock_irq(&dev->event_lock); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 634 | work = crtc->flip_work; |
| 635 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 636 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 637 | pipe, plane); |
| 638 | } else { |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 639 | u32 pending; |
| 640 | u32 addr; |
| 641 | |
| 642 | pending = atomic_read(&work->pending); |
| 643 | if (pending) { |
| 644 | seq_printf(m, "Flip ioctl preparing on pipe %c (plane %c)\n", |
| 645 | pipe, plane); |
| 646 | } else { |
| 647 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
| 648 | pipe, plane); |
| 649 | } |
| 650 | if (work->flip_queued_req) { |
| 651 | struct intel_engine_cs *engine = i915_gem_request_get_engine(work->flip_queued_req); |
| 652 | |
| 653 | seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n", |
| 654 | engine->name, |
| 655 | i915_gem_request_get_seqno(work->flip_queued_req), |
| 656 | dev_priv->next_seqno, |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 657 | intel_engine_get_seqno(engine), |
Chris Wilson | f69a02c | 2016-07-01 17:23:16 +0100 | [diff] [blame] | 658 | i915_gem_request_completed(work->flip_queued_req)); |
Daniel Vetter | 5a21b66 | 2016-05-24 17:13:53 +0200 | [diff] [blame] | 659 | } else |
| 660 | seq_printf(m, "Flip not associated with any ring\n"); |
| 661 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 662 | work->flip_queued_vblank, |
| 663 | work->flip_ready_vblank, |
| 664 | intel_crtc_get_vblank_counter(crtc)); |
| 665 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
| 666 | |
| 667 | if (INTEL_INFO(dev)->gen >= 4) |
| 668 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 669 | else |
| 670 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 671 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 672 | |
| 673 | if (work->pending_flip_obj) { |
| 674 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 675 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 676 | } |
| 677 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 678 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 679 | } |
| 680 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 681 | mutex_unlock(&dev->struct_mutex); |
| 682 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 683 | return 0; |
| 684 | } |
| 685 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 686 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 687 | { |
| 688 | struct drm_info_node *node = m->private; |
| 689 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 690 | struct drm_i915_private *dev_priv = to_i915(dev); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 691 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 692 | struct intel_engine_cs *engine; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 693 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 694 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 695 | |
| 696 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 697 | if (ret) |
| 698 | return ret; |
| 699 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 700 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 701 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 702 | int count; |
| 703 | |
| 704 | count = 0; |
| 705 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 706 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 707 | batch_pool_link) |
| 708 | count++; |
| 709 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 710 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 711 | |
| 712 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 713 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 714 | batch_pool_link) { |
| 715 | seq_puts(m, " "); |
| 716 | describe_obj(m, obj); |
| 717 | seq_putc(m, '\n'); |
| 718 | } |
| 719 | |
| 720 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 721 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 722 | } |
| 723 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 724 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 725 | |
| 726 | mutex_unlock(&dev->struct_mutex); |
| 727 | |
| 728 | return 0; |
| 729 | } |
| 730 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 731 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 732 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 733 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 734 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 735 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 736 | struct intel_engine_cs *engine; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 737 | struct drm_i915_gem_request *req; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 738 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 739 | |
| 740 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 741 | if (ret) |
| 742 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 743 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 744 | any = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 745 | for_each_engine(engine, dev_priv) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 746 | int count; |
| 747 | |
| 748 | count = 0; |
Chris Wilson | efdf7c0 | 2016-08-04 07:52:33 +0100 | [diff] [blame] | 749 | list_for_each_entry(req, &engine->request_list, link) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 750 | count++; |
| 751 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 752 | continue; |
| 753 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 754 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
Chris Wilson | efdf7c0 | 2016-08-04 07:52:33 +0100 | [diff] [blame] | 755 | list_for_each_entry(req, &engine->request_list, link) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 756 | struct task_struct *task; |
| 757 | |
| 758 | rcu_read_lock(); |
| 759 | task = NULL; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 760 | if (req->pid) |
| 761 | task = pid_task(req->pid, PIDTYPE_PID); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 762 | seq_printf(m, " %x @ %d: %s [%d]\n", |
Chris Wilson | 0476965 | 2016-07-20 09:21:11 +0100 | [diff] [blame] | 763 | req->fence.seqno, |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 764 | (int) (jiffies - req->emitted_jiffies), |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 765 | task ? task->comm : "<unknown>", |
| 766 | task ? task->pid : -1); |
| 767 | rcu_read_unlock(); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 768 | } |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 769 | |
| 770 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 771 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 772 | mutex_unlock(&dev->struct_mutex); |
| 773 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 774 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 775 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 776 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 777 | return 0; |
| 778 | } |
| 779 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 780 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 781 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 782 | { |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 783 | struct intel_breadcrumbs *b = &engine->breadcrumbs; |
| 784 | struct rb_node *rb; |
| 785 | |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 786 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 787 | engine->name, intel_engine_get_seqno(engine)); |
Chris Wilson | aca34b6 | 2016-07-06 12:39:02 +0100 | [diff] [blame] | 788 | seq_printf(m, "Current user interrupts (%s): %lx\n", |
| 789 | engine->name, READ_ONCE(engine->breadcrumbs.irq_wakeups)); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 790 | |
| 791 | spin_lock(&b->lock); |
| 792 | for (rb = rb_first(&b->waiters); rb; rb = rb_next(rb)) { |
| 793 | struct intel_wait *w = container_of(rb, typeof(*w), node); |
| 794 | |
| 795 | seq_printf(m, "Waiting (%s): %s [%d] on %x\n", |
| 796 | engine->name, w->tsk->comm, w->tsk->pid, w->seqno); |
| 797 | } |
| 798 | spin_unlock(&b->lock); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 799 | } |
| 800 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 801 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 802 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 803 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 804 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 805 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 806 | struct intel_engine_cs *engine; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 807 | int ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 808 | |
| 809 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 810 | if (ret) |
| 811 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 812 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 813 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 814 | for_each_engine(engine, dev_priv) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 815 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 816 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 817 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 818 | mutex_unlock(&dev->struct_mutex); |
| 819 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 820 | return 0; |
| 821 | } |
| 822 | |
| 823 | |
| 824 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 825 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 826 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 827 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 828 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 829 | struct intel_engine_cs *engine; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 830 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 831 | |
| 832 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 833 | if (ret) |
| 834 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 835 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 836 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 837 | if (IS_CHERRYVIEW(dev)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 838 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 839 | I915_READ(GEN8_MASTER_IRQ)); |
| 840 | |
| 841 | seq_printf(m, "Display IER:\t%08x\n", |
| 842 | I915_READ(VLV_IER)); |
| 843 | seq_printf(m, "Display IIR:\t%08x\n", |
| 844 | I915_READ(VLV_IIR)); |
| 845 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 846 | I915_READ(VLV_IIR_RW)); |
| 847 | seq_printf(m, "Display IMR:\t%08x\n", |
| 848 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 849 | for_each_pipe(dev_priv, pipe) |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 850 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 851 | pipe_name(pipe), |
| 852 | I915_READ(PIPESTAT(pipe))); |
| 853 | |
| 854 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 855 | I915_READ(PORT_HOTPLUG_EN)); |
| 856 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 857 | I915_READ(VLV_DPFLIPSTAT)); |
| 858 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 859 | I915_READ(DPINVGTT)); |
| 860 | |
| 861 | for (i = 0; i < 4; i++) { |
| 862 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 863 | i, I915_READ(GEN8_GT_IMR(i))); |
| 864 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 865 | i, I915_READ(GEN8_GT_IIR(i))); |
| 866 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 867 | i, I915_READ(GEN8_GT_IER(i))); |
| 868 | } |
| 869 | |
| 870 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 871 | I915_READ(GEN8_PCU_IMR)); |
| 872 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 873 | I915_READ(GEN8_PCU_IIR)); |
| 874 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 875 | I915_READ(GEN8_PCU_IER)); |
| 876 | } else if (INTEL_INFO(dev)->gen >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 877 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 878 | I915_READ(GEN8_MASTER_IRQ)); |
| 879 | |
| 880 | for (i = 0; i < 4; i++) { |
| 881 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 882 | i, I915_READ(GEN8_GT_IMR(i))); |
| 883 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 884 | i, I915_READ(GEN8_GT_IIR(i))); |
| 885 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 886 | i, I915_READ(GEN8_GT_IER(i))); |
| 887 | } |
| 888 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 889 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 890 | enum intel_display_power_domain power_domain; |
| 891 | |
| 892 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 893 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 894 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 895 | seq_printf(m, "Pipe %c power disabled\n", |
| 896 | pipe_name(pipe)); |
| 897 | continue; |
| 898 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 899 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 900 | pipe_name(pipe), |
| 901 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 902 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 903 | pipe_name(pipe), |
| 904 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 905 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 906 | pipe_name(pipe), |
| 907 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 908 | |
| 909 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 913 | I915_READ(GEN8_DE_PORT_IMR)); |
| 914 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 915 | I915_READ(GEN8_DE_PORT_IIR)); |
| 916 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 917 | I915_READ(GEN8_DE_PORT_IER)); |
| 918 | |
| 919 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 920 | I915_READ(GEN8_DE_MISC_IMR)); |
| 921 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 922 | I915_READ(GEN8_DE_MISC_IIR)); |
| 923 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 924 | I915_READ(GEN8_DE_MISC_IER)); |
| 925 | |
| 926 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 927 | I915_READ(GEN8_PCU_IMR)); |
| 928 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 929 | I915_READ(GEN8_PCU_IIR)); |
| 930 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 931 | I915_READ(GEN8_PCU_IER)); |
| 932 | } else if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 933 | seq_printf(m, "Display IER:\t%08x\n", |
| 934 | I915_READ(VLV_IER)); |
| 935 | seq_printf(m, "Display IIR:\t%08x\n", |
| 936 | I915_READ(VLV_IIR)); |
| 937 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 938 | I915_READ(VLV_IIR_RW)); |
| 939 | seq_printf(m, "Display IMR:\t%08x\n", |
| 940 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 941 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 942 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 943 | pipe_name(pipe), |
| 944 | I915_READ(PIPESTAT(pipe))); |
| 945 | |
| 946 | seq_printf(m, "Master IER:\t%08x\n", |
| 947 | I915_READ(VLV_MASTER_IER)); |
| 948 | |
| 949 | seq_printf(m, "Render IER:\t%08x\n", |
| 950 | I915_READ(GTIER)); |
| 951 | seq_printf(m, "Render IIR:\t%08x\n", |
| 952 | I915_READ(GTIIR)); |
| 953 | seq_printf(m, "Render IMR:\t%08x\n", |
| 954 | I915_READ(GTIMR)); |
| 955 | |
| 956 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 957 | I915_READ(GEN6_PMIER)); |
| 958 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 959 | I915_READ(GEN6_PMIIR)); |
| 960 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 961 | I915_READ(GEN6_PMIMR)); |
| 962 | |
| 963 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 964 | I915_READ(PORT_HOTPLUG_EN)); |
| 965 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 966 | I915_READ(VLV_DPFLIPSTAT)); |
| 967 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 968 | I915_READ(DPINVGTT)); |
| 969 | |
| 970 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 971 | seq_printf(m, "Interrupt enable: %08x\n", |
| 972 | I915_READ(IER)); |
| 973 | seq_printf(m, "Interrupt identity: %08x\n", |
| 974 | I915_READ(IIR)); |
| 975 | seq_printf(m, "Interrupt mask: %08x\n", |
| 976 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 977 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 978 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 979 | pipe_name(pipe), |
| 980 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 981 | } else { |
| 982 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 983 | I915_READ(DEIER)); |
| 984 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 985 | I915_READ(DEIIR)); |
| 986 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 987 | I915_READ(DEIMR)); |
| 988 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 989 | I915_READ(SDEIER)); |
| 990 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 991 | I915_READ(SDEIIR)); |
| 992 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 993 | I915_READ(SDEIMR)); |
| 994 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 995 | I915_READ(GTIER)); |
| 996 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 997 | I915_READ(GTIIR)); |
| 998 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 999 | I915_READ(GTIMR)); |
| 1000 | } |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 1001 | for_each_engine(engine, dev_priv) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 1002 | if (INTEL_INFO(dev)->gen >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 1003 | seq_printf(m, |
| 1004 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1005 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 1006 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1007 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 1008 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1009 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1010 | mutex_unlock(&dev->struct_mutex); |
| 1011 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1012 | return 0; |
| 1013 | } |
| 1014 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1015 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 1016 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1017 | struct drm_info_node *node = m->private; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1018 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1019 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1020 | int i, ret; |
| 1021 | |
| 1022 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1023 | if (ret) |
| 1024 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1025 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1026 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 1027 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1028 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1029 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 1030 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 1031 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 1032 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1033 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 1034 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1035 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1036 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1039 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1040 | return 0; |
| 1041 | } |
| 1042 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1043 | static int i915_hws_info(struct seq_file *m, void *data) |
| 1044 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1045 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1046 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1047 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1048 | struct intel_engine_cs *engine; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 1049 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 1050 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1051 | |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1052 | engine = &dev_priv->engine[(uintptr_t)node->info_ent->data]; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1053 | hws = engine->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1054 | if (hws == NULL) |
| 1055 | return 0; |
| 1056 | |
| 1057 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 1058 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1059 | i * 4, |
| 1060 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 1061 | } |
| 1062 | return 0; |
| 1063 | } |
| 1064 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1065 | static ssize_t |
| 1066 | i915_error_state_write(struct file *filp, |
| 1067 | const char __user *ubuf, |
| 1068 | size_t cnt, |
| 1069 | loff_t *ppos) |
| 1070 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1071 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1072 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1073 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1074 | |
| 1075 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 1076 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1077 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1078 | if (ret) |
| 1079 | return ret; |
| 1080 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1081 | i915_destroy_error_state(dev); |
| 1082 | mutex_unlock(&dev->struct_mutex); |
| 1083 | |
| 1084 | return cnt; |
| 1085 | } |
| 1086 | |
| 1087 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1088 | { |
| 1089 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1090 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1091 | |
| 1092 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 1093 | if (!error_priv) |
| 1094 | return -ENOMEM; |
| 1095 | |
| 1096 | error_priv->dev = dev; |
| 1097 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1098 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1099 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1100 | file->private_data = error_priv; |
| 1101 | |
| 1102 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 1106 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1107 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1108 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1109 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1110 | kfree(error_priv); |
| 1111 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1112 | return 0; |
| 1113 | } |
| 1114 | |
| 1115 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1116 | size_t count, loff_t *pos) |
| 1117 | { |
| 1118 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1119 | struct drm_i915_error_state_buf error_str; |
| 1120 | loff_t tmp_pos = 0; |
| 1121 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1122 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1123 | |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 1124 | ret = i915_error_state_buf_init(&error_str, to_i915(error_priv->dev), count, *pos); |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1125 | if (ret) |
| 1126 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1127 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1128 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1129 | if (ret) |
| 1130 | goto out; |
| 1131 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1132 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1133 | error_str.buf, |
| 1134 | error_str.bytes); |
| 1135 | |
| 1136 | if (ret_count < 0) |
| 1137 | ret = ret_count; |
| 1138 | else |
| 1139 | *pos = error_str.start + ret_count; |
| 1140 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1141 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1142 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | static const struct file_operations i915_error_state_fops = { |
| 1146 | .owner = THIS_MODULE, |
| 1147 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1148 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1149 | .write = i915_error_state_write, |
| 1150 | .llseek = default_llseek, |
| 1151 | .release = i915_error_state_release, |
| 1152 | }; |
| 1153 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1154 | static int |
| 1155 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1156 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1157 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1158 | struct drm_i915_private *dev_priv = to_i915(dev); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1159 | int ret; |
| 1160 | |
| 1161 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1162 | if (ret) |
| 1163 | return ret; |
| 1164 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1165 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1166 | mutex_unlock(&dev->struct_mutex); |
| 1167 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1168 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1169 | } |
| 1170 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1171 | static int |
| 1172 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1173 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1174 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1175 | int ret; |
| 1176 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1177 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1178 | if (ret) |
| 1179 | return ret; |
| 1180 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 1181 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1182 | mutex_unlock(&dev->struct_mutex); |
| 1183 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1184 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1185 | } |
| 1186 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1187 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1188 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1189 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1190 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1191 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1192 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1193 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1194 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1195 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1196 | int ret = 0; |
| 1197 | |
| 1198 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1199 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1200 | if (IS_GEN5(dev)) { |
| 1201 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1202 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1203 | |
| 1204 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1205 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1206 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1207 | MEMSTAT_VID_SHIFT); |
| 1208 | seq_printf(m, "Current P-state: %d\n", |
| 1209 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1210 | } else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) { |
| 1211 | u32 freq_sts; |
| 1212 | |
| 1213 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1214 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1215 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1216 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1217 | |
| 1218 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1219 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1220 | |
| 1221 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1222 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1223 | |
| 1224 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1225 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1226 | |
| 1227 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1228 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1229 | |
| 1230 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1231 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1232 | |
| 1233 | seq_printf(m, |
| 1234 | "efficient (RPe) frequency: %d MHz\n", |
| 1235 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1236 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 1237 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1238 | u32 rp_state_limits; |
| 1239 | u32 gt_perf_status; |
| 1240 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1241 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1242 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1243 | u32 rpupei, rpcurup, rpprevup; |
| 1244 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1245 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1246 | int max_freq; |
| 1247 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1248 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 1249 | if (IS_BROXTON(dev)) { |
| 1250 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1251 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1252 | } else { |
| 1253 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1254 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1255 | } |
| 1256 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1257 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1258 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1259 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1260 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1261 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1262 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1263 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1264 | reqf = I915_READ(GEN6_RPNSWREQ); |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1265 | if (IS_GEN9(dev)) |
| 1266 | reqf >>= 23; |
| 1267 | else { |
| 1268 | reqf &= ~GEN6_TURBO_DISABLE; |
| 1269 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
| 1270 | reqf >>= 24; |
| 1271 | else |
| 1272 | reqf >>= 25; |
| 1273 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1274 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1275 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1276 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1277 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1278 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1279 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1280 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1281 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1282 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1283 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1284 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1285 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1286 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1287 | if (IS_GEN9(dev)) |
| 1288 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
| 1289 | else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1290 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1291 | else |
| 1292 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1293 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1294 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1295 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1296 | mutex_unlock(&dev->struct_mutex); |
| 1297 | |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1298 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1299 | pm_ier = I915_READ(GEN6_PMIER); |
| 1300 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1301 | pm_isr = I915_READ(GEN6_PMISR); |
| 1302 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1303 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1304 | } else { |
| 1305 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1306 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1307 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1308 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1309 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1310 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1311 | 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] | 1312 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 1313 | 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] | 1314 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1315 | seq_printf(m, "Render p-state ratio: %d\n", |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1316 | (gt_perf_status & (IS_GEN9(dev) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1317 | seq_printf(m, "Render p-state VID: %d\n", |
| 1318 | gt_perf_status & 0xff); |
| 1319 | seq_printf(m, "Render p-state limit: %d\n", |
| 1320 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1321 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1322 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1323 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1324 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1325 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1326 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1327 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1328 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1329 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1330 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1331 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1332 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1333 | seq_printf(m, "Up threshold: %d%%\n", |
| 1334 | dev_priv->rps.up_threshold); |
| 1335 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1336 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1337 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1338 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1339 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1340 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1341 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1342 | seq_printf(m, "Down threshold: %d%%\n", |
| 1343 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1344 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1345 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 0 : |
| 1346 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1347 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1348 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1349 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1350 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1351 | |
| 1352 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1353 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1354 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1355 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1356 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1357 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1358 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 16 : |
| 1359 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1360 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1361 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1362 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1363 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1364 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1365 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1366 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1367 | seq_printf(m, "Current freq: %d MHz\n", |
| 1368 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1369 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1370 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1371 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1372 | seq_printf(m, "Min freq: %d MHz\n", |
| 1373 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Chris Wilson | 29ecd78d | 2016-07-13 09:10:35 +0100 | [diff] [blame] | 1374 | seq_printf(m, "Boost freq: %d MHz\n", |
| 1375 | intel_gpu_freq(dev_priv, dev_priv->rps.boost_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1376 | seq_printf(m, "Max freq: %d MHz\n", |
| 1377 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1378 | seq_printf(m, |
| 1379 | "efficient (RPe) frequency: %d MHz\n", |
| 1380 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1381 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1382 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1383 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1384 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1385 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1386 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1387 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1388 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1389 | out: |
| 1390 | intel_runtime_pm_put(dev_priv); |
| 1391 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1392 | } |
| 1393 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1394 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1395 | { |
| 1396 | struct drm_info_node *node = m->private; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1397 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1398 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1399 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1400 | u64 acthd[I915_NUM_ENGINES]; |
| 1401 | u32 seqno[I915_NUM_ENGINES]; |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1402 | u32 instdone[I915_NUM_INSTDONE_REG]; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1403 | enum intel_engine_id id; |
| 1404 | int j; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1405 | |
| 1406 | if (!i915.enable_hangcheck) { |
| 1407 | seq_printf(m, "Hangcheck disabled\n"); |
| 1408 | return 0; |
| 1409 | } |
| 1410 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1411 | intel_runtime_pm_get(dev_priv); |
| 1412 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1413 | for_each_engine_id(engine, dev_priv, id) { |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 1414 | acthd[id] = intel_engine_get_active_head(engine); |
Chris Wilson | 1b7744e | 2016-07-01 17:23:17 +0100 | [diff] [blame] | 1415 | seqno[id] = intel_engine_get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1416 | } |
| 1417 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1418 | i915_get_extra_instdone(dev_priv, instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1419 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1420 | intel_runtime_pm_put(dev_priv); |
| 1421 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1422 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1423 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1424 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1425 | jiffies)); |
| 1426 | } else |
| 1427 | seq_printf(m, "Hangcheck inactive\n"); |
| 1428 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1429 | for_each_engine_id(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1430 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 14fd0d6 | 2016-04-07 07:29:10 +0100 | [diff] [blame] | 1431 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
| 1432 | engine->hangcheck.seqno, |
| 1433 | seqno[id], |
| 1434 | engine->last_submitted_seqno); |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 1435 | seq_printf(m, "\twaiters? %d\n", |
| 1436 | intel_engine_has_waiter(engine)); |
Chris Wilson | aca34b6 | 2016-07-06 12:39:02 +0100 | [diff] [blame] | 1437 | seq_printf(m, "\tuser interrupts = %lx [current %lx]\n", |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 1438 | engine->hangcheck.user_interrupts, |
Chris Wilson | aca34b6 | 2016-07-06 12:39:02 +0100 | [diff] [blame] | 1439 | READ_ONCE(engine->breadcrumbs.irq_wakeups)); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1440 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1441 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1442 | (long long)acthd[id]); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1443 | seq_printf(m, "\tscore = %d\n", engine->hangcheck.score); |
| 1444 | seq_printf(m, "\taction = %d\n", engine->hangcheck.action); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1445 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1446 | if (engine->id == RCS) { |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1447 | seq_puts(m, "\tinstdone read ="); |
| 1448 | |
| 1449 | for (j = 0; j < I915_NUM_INSTDONE_REG; j++) |
| 1450 | seq_printf(m, " 0x%08x", instdone[j]); |
| 1451 | |
| 1452 | seq_puts(m, "\n\tinstdone accu ="); |
| 1453 | |
| 1454 | for (j = 0; j < I915_NUM_INSTDONE_REG; j++) |
| 1455 | seq_printf(m, " 0x%08x", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1456 | engine->hangcheck.instdone[j]); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1457 | |
| 1458 | seq_puts(m, "\n"); |
| 1459 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | return 0; |
| 1463 | } |
| 1464 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1465 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1466 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1467 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1468 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1469 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1470 | u32 rgvmodectl, rstdbyctl; |
| 1471 | u16 crstandvid; |
| 1472 | int ret; |
| 1473 | |
| 1474 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1475 | if (ret) |
| 1476 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1477 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1478 | |
| 1479 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1480 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1481 | crstandvid = I915_READ16(CRSTANDVID); |
| 1482 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1483 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1484 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1485 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1486 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1487 | seq_printf(m, "Boost freq: %d\n", |
| 1488 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1489 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1490 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1491 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1492 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1493 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1494 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1495 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1496 | seq_printf(m, "Starting frequency: P%d\n", |
| 1497 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1498 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1499 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1500 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1501 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1502 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1503 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1504 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1505 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1506 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1507 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1508 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1509 | break; |
| 1510 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1511 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1512 | break; |
| 1513 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1514 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1515 | break; |
| 1516 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1517 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1518 | break; |
| 1519 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1520 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1521 | break; |
| 1522 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1523 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1524 | break; |
| 1525 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1526 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1527 | break; |
| 1528 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1529 | |
| 1530 | return 0; |
| 1531 | } |
| 1532 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1533 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1534 | { |
| 1535 | struct drm_info_node *node = m->private; |
| 1536 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1537 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1538 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1539 | |
| 1540 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1541 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1542 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1543 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1544 | fw_domain->wake_count); |
| 1545 | } |
| 1546 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1547 | |
| 1548 | return 0; |
| 1549 | } |
| 1550 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1551 | static int vlv_drpc_info(struct seq_file *m) |
| 1552 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1553 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1554 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1555 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1556 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1557 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1558 | intel_runtime_pm_get(dev_priv); |
| 1559 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1560 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1561 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1562 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1563 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1564 | intel_runtime_pm_put(dev_priv); |
| 1565 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1566 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1567 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1568 | seq_printf(m, "Turbo enabled: %s\n", |
| 1569 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1570 | seq_printf(m, "HW control enabled: %s\n", |
| 1571 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1572 | seq_printf(m, "SW control enabled: %s\n", |
| 1573 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1574 | GEN6_RP_MEDIA_SW_MODE)); |
| 1575 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1576 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1577 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1578 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1579 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1580 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1581 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1582 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1583 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1584 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1585 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1586 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1587 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1588 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1589 | } |
| 1590 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1591 | static int gen6_drpc_info(struct seq_file *m) |
| 1592 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1593 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1594 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1595 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1596 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1597 | u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1598 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1599 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1600 | |
| 1601 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1602 | if (ret) |
| 1603 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1604 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1605 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1606 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1607 | 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] | 1608 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1609 | |
| 1610 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1611 | seq_puts(m, "RC information inaccurate because somebody " |
| 1612 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1613 | } else { |
| 1614 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1615 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1616 | udelay(10); |
| 1617 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1618 | } |
| 1619 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1620 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1621 | 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] | 1622 | |
| 1623 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1624 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1625 | if (INTEL_INFO(dev)->gen >= 9) { |
| 1626 | gen9_powergate_enable = I915_READ(GEN9_PG_ENABLE); |
| 1627 | gen9_powergate_status = I915_READ(GEN9_PWRGT_DOMAIN_STATUS); |
| 1628 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1629 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1630 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1631 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1632 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1633 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1634 | intel_runtime_pm_put(dev_priv); |
| 1635 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1636 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1637 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1638 | seq_printf(m, "HW control enabled: %s\n", |
| 1639 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1640 | seq_printf(m, "SW control enabled: %s\n", |
| 1641 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1642 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1643 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1644 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1645 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1646 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1647 | if (INTEL_INFO(dev)->gen >= 9) { |
| 1648 | seq_printf(m, "Render Well Gating Enabled: %s\n", |
| 1649 | yesno(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); |
| 1650 | seq_printf(m, "Media Well Gating Enabled: %s\n", |
| 1651 | yesno(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); |
| 1652 | } |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1653 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1654 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1655 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1656 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1657 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1658 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1659 | case GEN6_RC0: |
| 1660 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1661 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1662 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1663 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1664 | break; |
| 1665 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1666 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1667 | break; |
| 1668 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1669 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1670 | break; |
| 1671 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1672 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1673 | break; |
| 1674 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1675 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1676 | break; |
| 1677 | } |
| 1678 | |
| 1679 | seq_printf(m, "Core Power Down: %s\n", |
| 1680 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1681 | if (INTEL_INFO(dev)->gen >= 9) { |
| 1682 | seq_printf(m, "Render Power Well: %s\n", |
| 1683 | (gen9_powergate_status & |
| 1684 | GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1685 | seq_printf(m, "Media Power Well: %s\n", |
| 1686 | (gen9_powergate_status & |
| 1687 | GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1688 | } |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1689 | |
| 1690 | /* Not exactly sure what this is */ |
| 1691 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1692 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1693 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1694 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1695 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1696 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1697 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1698 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1699 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1700 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1701 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1702 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1703 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1704 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1705 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Akash Goel | f2dd757 | 2016-06-27 20:10:01 +0530 | [diff] [blame] | 1706 | return i915_forcewake_domains(m, NULL); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1707 | } |
| 1708 | |
| 1709 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1710 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1711 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1712 | struct drm_device *dev = node->minor->dev; |
| 1713 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1714 | if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1715 | return vlv_drpc_info(m); |
Vedang Patel | ac66cf4 | 2014-08-26 10:42:51 -0700 | [diff] [blame] | 1716 | else if (INTEL_INFO(dev)->gen >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1717 | return gen6_drpc_info(m); |
| 1718 | else |
| 1719 | return ironlake_drpc_info(m); |
| 1720 | } |
| 1721 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1722 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1723 | { |
| 1724 | struct drm_info_node *node = m->private; |
| 1725 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1726 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1727 | |
| 1728 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1729 | dev_priv->fb_tracking.busy_bits); |
| 1730 | |
| 1731 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1732 | dev_priv->fb_tracking.flip_bits); |
| 1733 | |
| 1734 | return 0; |
| 1735 | } |
| 1736 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1737 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1738 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1739 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1740 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1741 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1742 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1743 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1744 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1745 | return 0; |
| 1746 | } |
| 1747 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1748 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1749 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1750 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1751 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1752 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1753 | else |
| 1754 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1755 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1756 | |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1757 | if (INTEL_INFO(dev_priv)->gen >= 7) |
| 1758 | seq_printf(m, "Compressing: %s\n", |
| 1759 | yesno(I915_READ(FBC_STATUS2) & |
| 1760 | FBC_COMPRESSION_MASK)); |
| 1761 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1762 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1763 | intel_runtime_pm_put(dev_priv); |
| 1764 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1765 | return 0; |
| 1766 | } |
| 1767 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1768 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1769 | { |
| 1770 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1771 | struct drm_i915_private *dev_priv = to_i915(dev); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1772 | |
| 1773 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1774 | return -ENODEV; |
| 1775 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1776 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1777 | |
| 1778 | return 0; |
| 1779 | } |
| 1780 | |
| 1781 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1782 | { |
| 1783 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1784 | struct drm_i915_private *dev_priv = to_i915(dev); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1785 | u32 reg; |
| 1786 | |
| 1787 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1788 | return -ENODEV; |
| 1789 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1790 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1791 | |
| 1792 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1793 | dev_priv->fbc.false_color = val; |
| 1794 | |
| 1795 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1796 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1797 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1798 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1799 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1800 | return 0; |
| 1801 | } |
| 1802 | |
| 1803 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1804 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1805 | "%llu\n"); |
| 1806 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1807 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1808 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1809 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1810 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1811 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1812 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1813 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1814 | seq_puts(m, "not supported\n"); |
| 1815 | return 0; |
| 1816 | } |
| 1817 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1818 | intel_runtime_pm_get(dev_priv); |
| 1819 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1820 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1821 | yesno(i915.enable_ips)); |
| 1822 | |
| 1823 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1824 | seq_puts(m, "Currently: unknown\n"); |
| 1825 | } else { |
| 1826 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1827 | seq_puts(m, "Currently: enabled\n"); |
| 1828 | else |
| 1829 | seq_puts(m, "Currently: disabled\n"); |
| 1830 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1831 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1832 | intel_runtime_pm_put(dev_priv); |
| 1833 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1834 | return 0; |
| 1835 | } |
| 1836 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1837 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1838 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1839 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1840 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1841 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1842 | bool sr_enabled = false; |
| 1843 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1844 | intel_runtime_pm_get(dev_priv); |
| 1845 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1846 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1847 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1848 | else if (IS_CRESTLINE(dev) || IS_G4X(dev) || |
| 1849 | IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1850 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1851 | else if (IS_I915GM(dev)) |
| 1852 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1853 | else if (IS_PINEVIEW(dev)) |
| 1854 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1855 | else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1856 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1857 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1858 | intel_runtime_pm_put(dev_priv); |
| 1859 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1860 | seq_printf(m, "self-refresh: %s\n", |
| 1861 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1862 | |
| 1863 | return 0; |
| 1864 | } |
| 1865 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1866 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1867 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1868 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1869 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1870 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1871 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1872 | int ret; |
| 1873 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1874 | if (!IS_GEN5(dev)) |
| 1875 | return -ENODEV; |
| 1876 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1877 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1878 | if (ret) |
| 1879 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1880 | |
| 1881 | temp = i915_mch_val(dev_priv); |
| 1882 | chipset = i915_chipset_val(dev_priv); |
| 1883 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1884 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1885 | |
| 1886 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1887 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1888 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1889 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1890 | |
| 1891 | return 0; |
| 1892 | } |
| 1893 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1894 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1895 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1896 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1897 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1898 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1899 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1900 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1901 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1902 | |
Akash Goel | 97d3308 | 2015-06-29 14:50:23 +0530 | [diff] [blame] | 1903 | if (!HAS_CORE_RING_FREQ(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1904 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1905 | return 0; |
| 1906 | } |
| 1907 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1908 | intel_runtime_pm_get(dev_priv); |
| 1909 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1910 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1911 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1912 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1913 | |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1914 | if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1915 | /* Convert GT frequency to 50 HZ units */ |
| 1916 | min_gpu_freq = |
| 1917 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1918 | max_gpu_freq = |
| 1919 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1920 | } else { |
| 1921 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1922 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1923 | } |
| 1924 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1925 | 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] | 1926 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1927 | 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] | 1928 | ia_freq = gpu_freq; |
| 1929 | sandybridge_pcode_read(dev_priv, |
| 1930 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1931 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1932 | 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] | 1933 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1934 | (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1935 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1936 | ((ia_freq >> 0) & 0xff) * 100, |
| 1937 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1938 | } |
| 1939 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1940 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1941 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1942 | out: |
| 1943 | intel_runtime_pm_put(dev_priv); |
| 1944 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1945 | } |
| 1946 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1947 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1948 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1949 | struct drm_info_node *node = m->private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1950 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1951 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1952 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1953 | int ret; |
| 1954 | |
| 1955 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1956 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1957 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1958 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1959 | if (opregion->header) |
| 1960 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1961 | |
| 1962 | mutex_unlock(&dev->struct_mutex); |
| 1963 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1964 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1965 | return 0; |
| 1966 | } |
| 1967 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1968 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1969 | { |
| 1970 | struct drm_info_node *node = m->private; |
| 1971 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1972 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1973 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1974 | |
| 1975 | if (opregion->vbt) |
| 1976 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1977 | |
| 1978 | return 0; |
| 1979 | } |
| 1980 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1981 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1982 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1983 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1984 | struct drm_device *dev = node->minor->dev; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1985 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1986 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1987 | int ret; |
| 1988 | |
| 1989 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1990 | if (ret) |
| 1991 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1992 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1993 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1994 | if (to_i915(dev)->fbdev) { |
| 1995 | fbdev_fb = to_intel_framebuffer(to_i915(dev)->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1996 | |
Chris Wilson | 25bcce9 | 2016-07-02 15:36:00 +0100 | [diff] [blame] | 1997 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1998 | fbdev_fb->base.width, |
| 1999 | fbdev_fb->base.height, |
| 2000 | fbdev_fb->base.depth, |
| 2001 | fbdev_fb->base.bits_per_pixel, |
| 2002 | fbdev_fb->base.modifier[0], |
| 2003 | drm_framebuffer_read_refcount(&fbdev_fb->base)); |
| 2004 | describe_obj(m, fbdev_fb->obj); |
| 2005 | seq_putc(m, '\n'); |
| 2006 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 2007 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 2008 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 2009 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 2010 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 2011 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 2012 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 2013 | continue; |
| 2014 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 2015 | 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] | 2016 | fb->base.width, |
| 2017 | fb->base.height, |
| 2018 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 2019 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 2020 | fb->base.modifier[0], |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 2021 | drm_framebuffer_read_refcount(&fb->base)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 2022 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2023 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 2024 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 2025 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 2026 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 2027 | |
| 2028 | return 0; |
| 2029 | } |
| 2030 | |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 2031 | 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] | 2032 | { |
| 2033 | 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] | 2034 | ring->space, ring->head, ring->tail, |
| 2035 | ring->last_retired_head); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2036 | } |
| 2037 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2038 | static int i915_context_status(struct seq_file *m, void *unused) |
| 2039 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2040 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2041 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2042 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2043 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2044 | struct i915_gem_context *ctx; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 2045 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2046 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 2047 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2048 | if (ret) |
| 2049 | return ret; |
| 2050 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2051 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 2052 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Chris Wilson | d28b99a | 2016-05-24 14:53:39 +0100 | [diff] [blame] | 2053 | if (IS_ERR(ctx->file_priv)) { |
| 2054 | seq_puts(m, "(deleted) "); |
| 2055 | } else if (ctx->file_priv) { |
| 2056 | struct pid *pid = ctx->file_priv->file->pid; |
| 2057 | struct task_struct *task; |
| 2058 | |
| 2059 | task = get_pid_task(pid, PIDTYPE_PID); |
| 2060 | if (task) { |
| 2061 | seq_printf(m, "(%s [%d]) ", |
| 2062 | task->comm, task->pid); |
| 2063 | put_task_struct(task); |
| 2064 | } |
| 2065 | } else { |
| 2066 | seq_puts(m, "(kernel) "); |
| 2067 | } |
| 2068 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 2069 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 2070 | seq_putc(m, '\n'); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2071 | |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 2072 | for_each_engine(engine, dev_priv) { |
| 2073 | struct intel_context *ce = &ctx->engine[engine->id]; |
| 2074 | |
| 2075 | seq_printf(m, "%s: ", engine->name); |
| 2076 | seq_putc(m, ce->initialised ? 'I' : 'i'); |
| 2077 | if (ce->state) |
| 2078 | describe_obj(m, ce->state); |
Chris Wilson | dca33ec | 2016-08-02 22:50:20 +0100 | [diff] [blame] | 2079 | if (ce->ring) |
Chris Wilson | 7e37f88 | 2016-08-02 22:50:21 +0100 | [diff] [blame] | 2080 | describe_ctx_ring(m, ce->ring); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2081 | seq_putc(m, '\n'); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2082 | } |
| 2083 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2084 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 2085 | } |
| 2086 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 2087 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2088 | |
| 2089 | return 0; |
| 2090 | } |
| 2091 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2092 | static void i915_dump_lrc_obj(struct seq_file *m, |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2093 | struct i915_gem_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2094 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2095 | { |
Chris Wilson | bca44d8 | 2016-05-24 14:53:41 +0100 | [diff] [blame] | 2096 | struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2097 | struct page *page; |
| 2098 | uint32_t *reg_state; |
| 2099 | int j; |
| 2100 | unsigned long ggtt_offset = 0; |
| 2101 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2102 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2103 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2104 | if (ctx_obj == NULL) { |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2105 | seq_puts(m, "\tNot allocated\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2106 | return; |
| 2107 | } |
| 2108 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2109 | if (!i915_gem_obj_ggtt_bound(ctx_obj)) |
| 2110 | seq_puts(m, "\tNot bound in GGTT\n"); |
| 2111 | else |
| 2112 | ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj); |
| 2113 | |
| 2114 | if (i915_gem_object_get_pages(ctx_obj)) { |
| 2115 | seq_puts(m, "\tFailed to get pages for context object\n"); |
| 2116 | return; |
| 2117 | } |
| 2118 | |
Alex Dai | d167519 | 2015-08-12 15:43:43 +0100 | [diff] [blame] | 2119 | page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2120 | if (!WARN_ON(page == NULL)) { |
| 2121 | reg_state = kmap_atomic(page); |
| 2122 | |
| 2123 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 2124 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2125 | ggtt_offset + 4096 + (j * 4), |
| 2126 | reg_state[j], reg_state[j + 1], |
| 2127 | reg_state[j + 2], reg_state[j + 3]); |
| 2128 | } |
| 2129 | kunmap_atomic(reg_state); |
| 2130 | } |
| 2131 | |
| 2132 | seq_putc(m, '\n'); |
| 2133 | } |
| 2134 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2135 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2136 | { |
| 2137 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2138 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2139 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2140 | struct intel_engine_cs *engine; |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2141 | struct i915_gem_context *ctx; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2142 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2143 | |
| 2144 | if (!i915.enable_execlists) { |
| 2145 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2146 | return 0; |
| 2147 | } |
| 2148 | |
| 2149 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2150 | if (ret) |
| 2151 | return ret; |
| 2152 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2153 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2154 | for_each_engine(engine, dev_priv) |
| 2155 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2156 | |
| 2157 | mutex_unlock(&dev->struct_mutex); |
| 2158 | |
| 2159 | return 0; |
| 2160 | } |
| 2161 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2162 | static int i915_execlists(struct seq_file *m, void *data) |
| 2163 | { |
| 2164 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 2165 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2166 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2167 | struct intel_engine_cs *engine; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2168 | u32 status_pointer; |
| 2169 | u8 read_pointer; |
| 2170 | u8 write_pointer; |
| 2171 | u32 status; |
| 2172 | u32 ctx_id; |
| 2173 | struct list_head *cursor; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2174 | int i, ret; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2175 | |
| 2176 | if (!i915.enable_execlists) { |
| 2177 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 2178 | return 0; |
| 2179 | } |
| 2180 | |
| 2181 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2182 | if (ret) |
| 2183 | return ret; |
| 2184 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2185 | intel_runtime_pm_get(dev_priv); |
| 2186 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2187 | for_each_engine(engine, dev_priv) { |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2188 | struct drm_i915_gem_request *head_req = NULL; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2189 | int count = 0; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2190 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2191 | seq_printf(m, "%s\n", engine->name); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2192 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2193 | status = I915_READ(RING_EXECLIST_STATUS_LO(engine)); |
| 2194 | ctx_id = I915_READ(RING_EXECLIST_STATUS_HI(engine)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2195 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 2196 | status, ctx_id); |
| 2197 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2198 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2199 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 2200 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2201 | read_pointer = engine->next_context_status_buffer; |
Ben Widawsky | 5590a5f | 2016-01-05 10:30:05 -0800 | [diff] [blame] | 2202 | write_pointer = GEN8_CSB_WRITE_PTR(status_pointer); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2203 | if (read_pointer > write_pointer) |
Ben Widawsky | 5590a5f | 2016-01-05 10:30:05 -0800 | [diff] [blame] | 2204 | write_pointer += GEN8_CSB_ENTRIES; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2205 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 2206 | read_pointer, write_pointer); |
| 2207 | |
Ben Widawsky | 5590a5f | 2016-01-05 10:30:05 -0800 | [diff] [blame] | 2208 | for (i = 0; i < GEN8_CSB_ENTRIES; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2209 | status = I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, i)); |
| 2210 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, i)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2211 | |
| 2212 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 2213 | i, status, ctx_id); |
| 2214 | } |
| 2215 | |
Tvrtko Ursulin | 27af5ee | 2016-04-04 12:11:56 +0100 | [diff] [blame] | 2216 | spin_lock_bh(&engine->execlist_lock); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2217 | list_for_each(cursor, &engine->execlist_queue) |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2218 | count++; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2219 | head_req = list_first_entry_or_null(&engine->execlist_queue, |
| 2220 | struct drm_i915_gem_request, |
| 2221 | execlist_link); |
Tvrtko Ursulin | 27af5ee | 2016-04-04 12:11:56 +0100 | [diff] [blame] | 2222 | spin_unlock_bh(&engine->execlist_lock); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2223 | |
| 2224 | seq_printf(m, "\t%d requests in queue\n", count); |
| 2225 | if (head_req) { |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2226 | seq_printf(m, "\tHead request context: %u\n", |
| 2227 | head_req->ctx->hw_id); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2228 | seq_printf(m, "\tHead request tail: %u\n", |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2229 | head_req->tail); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2230 | } |
| 2231 | |
| 2232 | seq_putc(m, '\n'); |
| 2233 | } |
| 2234 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2235 | intel_runtime_pm_put(dev_priv); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2236 | mutex_unlock(&dev->struct_mutex); |
| 2237 | |
| 2238 | return 0; |
| 2239 | } |
| 2240 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2241 | static const char *swizzle_string(unsigned swizzle) |
| 2242 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2243 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2244 | case I915_BIT_6_SWIZZLE_NONE: |
| 2245 | return "none"; |
| 2246 | case I915_BIT_6_SWIZZLE_9: |
| 2247 | return "bit9"; |
| 2248 | case I915_BIT_6_SWIZZLE_9_10: |
| 2249 | return "bit9/bit10"; |
| 2250 | case I915_BIT_6_SWIZZLE_9_11: |
| 2251 | return "bit9/bit11"; |
| 2252 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2253 | return "bit9/bit10/bit11"; |
| 2254 | case I915_BIT_6_SWIZZLE_9_17: |
| 2255 | return "bit9/bit17"; |
| 2256 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2257 | return "bit9/bit10/bit17"; |
| 2258 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2259 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2260 | } |
| 2261 | |
| 2262 | return "bug"; |
| 2263 | } |
| 2264 | |
| 2265 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2266 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2267 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2268 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2269 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2270 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2271 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2272 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2273 | if (ret) |
| 2274 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2275 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2276 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2277 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2278 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2279 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2280 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2281 | |
| 2282 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 2283 | seq_printf(m, "DDC = 0x%08x\n", |
| 2284 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2285 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2286 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2287 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2288 | I915_READ16(C0DRB3)); |
| 2289 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2290 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2291 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2292 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2293 | I915_READ(MAD_DIMM_C0)); |
| 2294 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2295 | I915_READ(MAD_DIMM_C1)); |
| 2296 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2297 | I915_READ(MAD_DIMM_C2)); |
| 2298 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2299 | I915_READ(TILECTL)); |
Robert Beckett | 5907f5f | 2014-01-23 14:23:14 +0000 | [diff] [blame] | 2300 | if (INTEL_INFO(dev)->gen >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2301 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2302 | I915_READ(GAMTARBMODE)); |
| 2303 | else |
| 2304 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2305 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2306 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2307 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2308 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2309 | |
| 2310 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2311 | seq_puts(m, "L-shaped memory detected\n"); |
| 2312 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2313 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2314 | mutex_unlock(&dev->struct_mutex); |
| 2315 | |
| 2316 | return 0; |
| 2317 | } |
| 2318 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2319 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2320 | { |
Chris Wilson | e2efd13 | 2016-05-24 14:53:34 +0100 | [diff] [blame] | 2321 | struct i915_gem_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2322 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2323 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2324 | |
| 2325 | if (!ppgtt) { |
| 2326 | seq_printf(m, " no ppgtt for context %d\n", |
| 2327 | ctx->user_handle); |
| 2328 | return 0; |
| 2329 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2330 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2331 | if (i915_gem_context_is_default(ctx)) |
| 2332 | seq_puts(m, " default context:\n"); |
| 2333 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2334 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2335 | ppgtt->debug_dump(ppgtt, m); |
| 2336 | |
| 2337 | return 0; |
| 2338 | } |
| 2339 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2340 | static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2341 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2342 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2343 | struct intel_engine_cs *engine; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2344 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2345 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2346 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2347 | if (!ppgtt) |
| 2348 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2349 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2350 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2351 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2352 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2353 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2354 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2355 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2356 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2357 | } |
| 2358 | } |
| 2359 | } |
| 2360 | |
| 2361 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2362 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2363 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2364 | struct intel_engine_cs *engine; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2365 | |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2366 | if (IS_GEN6(dev_priv)) |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2367 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2368 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2369 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2370 | seq_printf(m, "%s\n", engine->name); |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2371 | if (IS_GEN7(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2372 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2373 | I915_READ(RING_MODE_GEN7(engine))); |
| 2374 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2375 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2376 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2377 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2378 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2379 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2380 | } |
| 2381 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2382 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2383 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2384 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2385 | 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] | 2386 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2387 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2388 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2389 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2390 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2394 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2395 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2396 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2397 | struct drm_i915_private *dev_priv = to_i915(dev); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2398 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2399 | |
| 2400 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2401 | if (ret) |
| 2402 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2403 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2404 | |
| 2405 | if (INTEL_INFO(dev)->gen >= 8) |
| 2406 | gen8_ppgtt_info(m, dev); |
| 2407 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2408 | gen6_ppgtt_info(m, dev); |
| 2409 | |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2410 | mutex_lock(&dev->filelist_mutex); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2411 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2412 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2413 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2414 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2415 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2416 | if (!task) { |
| 2417 | ret = -ESRCH; |
Wei Yongjun | b021248 | 2016-06-13 23:42:00 +0000 | [diff] [blame] | 2418 | goto out_unlock; |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2419 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2420 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2421 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2422 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2423 | (void *)(unsigned long)m); |
| 2424 | } |
Wei Yongjun | b021248 | 2016-06-13 23:42:00 +0000 | [diff] [blame] | 2425 | out_unlock: |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2426 | mutex_unlock(&dev->filelist_mutex); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2427 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2428 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2429 | mutex_unlock(&dev->struct_mutex); |
| 2430 | |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2431 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2432 | } |
| 2433 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2434 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2435 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2436 | struct intel_engine_cs *engine; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2437 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2438 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2439 | for_each_engine(engine, i915) |
Chris Wilson | 688e6c7 | 2016-07-01 17:23:15 +0100 | [diff] [blame] | 2440 | count += intel_engine_has_waiter(engine); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2441 | |
| 2442 | return count; |
| 2443 | } |
| 2444 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2445 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2446 | { |
| 2447 | struct drm_info_node *node = m->private; |
| 2448 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2449 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2450 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2451 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2452 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2453 | seq_printf(m, "GPU busy? %s [%x]\n", |
| 2454 | yesno(dev_priv->gt.awake), dev_priv->gt.active_engines); |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2455 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
| 2456 | seq_printf(m, "Frequency requested %d; min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
| 2457 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq), |
| 2458 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2459 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2460 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2461 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2462 | |
| 2463 | mutex_lock(&dev->filelist_mutex); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2464 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2465 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2466 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2467 | struct task_struct *task; |
| 2468 | |
| 2469 | rcu_read_lock(); |
| 2470 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2471 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2472 | task ? task->comm : "<unknown>", |
| 2473 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2474 | file_priv->rps.boosts, |
| 2475 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2476 | rcu_read_unlock(); |
| 2477 | } |
Chris Wilson | 197be2a | 2016-07-20 09:21:13 +0100 | [diff] [blame] | 2478 | seq_printf(m, "Kernel (anonymous) boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2479 | spin_unlock(&dev_priv->rps.client_lock); |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 2480 | mutex_unlock(&dev->filelist_mutex); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2481 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2482 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2483 | } |
| 2484 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2485 | static int i915_llc(struct seq_file *m, void *data) |
| 2486 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2487 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2488 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2489 | struct drm_i915_private *dev_priv = to_i915(dev); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2490 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2491 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2492 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2493 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2494 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2495 | |
| 2496 | return 0; |
| 2497 | } |
| 2498 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2499 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2500 | { |
| 2501 | struct drm_info_node *node = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2502 | struct drm_i915_private *dev_priv = to_i915(node->minor->dev); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2503 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
| 2504 | u32 tmp, i; |
| 2505 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2506 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2507 | return 0; |
| 2508 | |
| 2509 | seq_printf(m, "GuC firmware status:\n"); |
| 2510 | seq_printf(m, "\tpath: %s\n", |
| 2511 | guc_fw->guc_fw_path); |
| 2512 | seq_printf(m, "\tfetch: %s\n", |
| 2513 | intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status)); |
| 2514 | seq_printf(m, "\tload: %s\n", |
| 2515 | intel_guc_fw_status_repr(guc_fw->guc_fw_load_status)); |
| 2516 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2517 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
| 2518 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2519 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2520 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2521 | guc_fw->header_offset, guc_fw->header_size); |
| 2522 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2523 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2524 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2525 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2526 | |
| 2527 | tmp = I915_READ(GUC_STATUS); |
| 2528 | |
| 2529 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2530 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2531 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2532 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2533 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2534 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2535 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2536 | seq_puts(m, "\nScratch registers:\n"); |
| 2537 | for (i = 0; i < 16; i++) |
| 2538 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2539 | |
| 2540 | return 0; |
| 2541 | } |
| 2542 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2543 | static void i915_guc_client_info(struct seq_file *m, |
| 2544 | struct drm_i915_private *dev_priv, |
| 2545 | struct i915_guc_client *client) |
| 2546 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2547 | struct intel_engine_cs *engine; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2548 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2549 | |
| 2550 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2551 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2552 | seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", |
| 2553 | client->doorbell_id, client->doorbell_offset, client->cookie); |
| 2554 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2555 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2556 | |
Dave Gordon | 551aaec | 2016-05-13 15:36:33 +0100 | [diff] [blame] | 2557 | seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2558 | seq_printf(m, "\tFailed to queue: %u\n", client->q_fail); |
| 2559 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2560 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2561 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2562 | for_each_engine(engine, dev_priv) { |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2563 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Dave Gordon | 0b63bb1 | 2016-06-20 15:18:07 +0100 | [diff] [blame] | 2564 | client->submissions[engine->id], |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2565 | engine->name); |
Dave Gordon | 0b63bb1 | 2016-06-20 15:18:07 +0100 | [diff] [blame] | 2566 | tot += client->submissions[engine->id]; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2567 | } |
| 2568 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2569 | } |
| 2570 | |
| 2571 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2572 | { |
| 2573 | struct drm_info_node *node = m->private; |
| 2574 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2575 | struct drm_i915_private *dev_priv = to_i915(dev); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2576 | struct intel_guc guc; |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 2577 | struct i915_guc_client client = {}; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2578 | struct intel_engine_cs *engine; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2579 | u64 total = 0; |
| 2580 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2581 | if (!HAS_GUC_SCHED(dev_priv)) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2582 | return 0; |
| 2583 | |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2584 | if (mutex_lock_interruptible(&dev->struct_mutex)) |
| 2585 | return 0; |
| 2586 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2587 | /* 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] | 2588 | guc = dev_priv->guc; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2589 | if (guc.execbuf_client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2590 | client = *guc.execbuf_client; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2591 | |
| 2592 | mutex_unlock(&dev->struct_mutex); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2593 | |
Dave Gordon | 9636f6d | 2016-06-13 17:57:28 +0100 | [diff] [blame] | 2594 | seq_printf(m, "Doorbell map:\n"); |
| 2595 | seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc.doorbell_bitmap); |
| 2596 | seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc.db_cacheline); |
| 2597 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2598 | seq_printf(m, "GuC total action count: %llu\n", guc.action_count); |
| 2599 | seq_printf(m, "GuC action failure count: %u\n", guc.action_fail); |
| 2600 | seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd); |
| 2601 | seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status); |
| 2602 | seq_printf(m, "GuC last action error code: %d\n", guc.action_err); |
| 2603 | |
| 2604 | seq_printf(m, "\nGuC submissions:\n"); |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2605 | for_each_engine(engine, dev_priv) { |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2606 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Dave Gordon | 0b63bb1 | 2016-06-20 15:18:07 +0100 | [diff] [blame] | 2607 | engine->name, guc.submissions[engine->id], |
| 2608 | guc.last_seqno[engine->id]); |
| 2609 | total += guc.submissions[engine->id]; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2610 | } |
| 2611 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2612 | |
| 2613 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client); |
| 2614 | i915_guc_client_info(m, dev_priv, &client); |
| 2615 | |
| 2616 | /* Add more as required ... */ |
| 2617 | |
| 2618 | return 0; |
| 2619 | } |
| 2620 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2621 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2622 | { |
| 2623 | struct drm_info_node *node = m->private; |
| 2624 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2625 | struct drm_i915_private *dev_priv = to_i915(dev); |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2626 | struct drm_i915_gem_object *log_obj = dev_priv->guc.log_obj; |
| 2627 | u32 *log; |
| 2628 | int i = 0, pg; |
| 2629 | |
| 2630 | if (!log_obj) |
| 2631 | return 0; |
| 2632 | |
| 2633 | for (pg = 0; pg < log_obj->base.size / PAGE_SIZE; pg++) { |
| 2634 | log = kmap_atomic(i915_gem_object_get_page(log_obj, pg)); |
| 2635 | |
| 2636 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2637 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2638 | *(log + i), *(log + i + 1), |
| 2639 | *(log + i + 2), *(log + i + 3)); |
| 2640 | |
| 2641 | kunmap_atomic(log); |
| 2642 | } |
| 2643 | |
| 2644 | seq_putc(m, '\n'); |
| 2645 | |
| 2646 | return 0; |
| 2647 | } |
| 2648 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2649 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2650 | { |
| 2651 | struct drm_info_node *node = m->private; |
| 2652 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2653 | struct drm_i915_private *dev_priv = to_i915(dev); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2654 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2655 | u32 stat[3]; |
| 2656 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2657 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2658 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2659 | if (!HAS_PSR(dev)) { |
| 2660 | seq_puts(m, "PSR not supported\n"); |
| 2661 | return 0; |
| 2662 | } |
| 2663 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2664 | intel_runtime_pm_get(dev_priv); |
| 2665 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2666 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2667 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2668 | 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] | 2669 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2670 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2671 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2672 | dev_priv->psr.busy_frontbuffer_bits); |
| 2673 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2674 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2675 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2676 | if (HAS_DDI(dev)) |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2677 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2678 | else { |
| 2679 | for_each_pipe(dev_priv, pipe) { |
| 2680 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2681 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2682 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2683 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2684 | enabled = true; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2685 | } |
| 2686 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2687 | |
| 2688 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2689 | yesno(dev_priv->psr.link_standby)); |
| 2690 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2691 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2692 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2693 | if (!HAS_DDI(dev)) |
| 2694 | for_each_pipe(dev_priv, pipe) { |
| 2695 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2696 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2697 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2698 | } |
| 2699 | seq_puts(m, "\n"); |
| 2700 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2701 | /* |
| 2702 | * VLV/CHV PSR has no kind of performance counter |
| 2703 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2704 | */ |
| 2705 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2706 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2707 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2708 | |
| 2709 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2710 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2711 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2712 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2713 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2714 | return 0; |
| 2715 | } |
| 2716 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2717 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2718 | { |
| 2719 | struct drm_info_node *node = m->private; |
| 2720 | struct drm_device *dev = node->minor->dev; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2721 | struct intel_connector *connector; |
| 2722 | struct intel_dp *intel_dp = NULL; |
| 2723 | int ret; |
| 2724 | u8 crc[6]; |
| 2725 | |
| 2726 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2727 | for_each_intel_connector(dev, connector) { |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2728 | struct drm_crtc *crtc; |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2729 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2730 | if (!connector->base.state->best_encoder) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2731 | continue; |
| 2732 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2733 | crtc = connector->base.state->crtc; |
| 2734 | if (!crtc->state->active) |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2735 | continue; |
| 2736 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2737 | if (connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2738 | continue; |
| 2739 | |
Maarten Lankhorst | 26c17cf | 2016-06-20 15:57:38 +0200 | [diff] [blame] | 2740 | intel_dp = enc_to_intel_dp(connector->base.state->best_encoder); |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2741 | |
| 2742 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2743 | if (ret) |
| 2744 | goto out; |
| 2745 | |
| 2746 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2747 | crc[0], crc[1], crc[2], |
| 2748 | crc[3], crc[4], crc[5]); |
| 2749 | goto out; |
| 2750 | } |
| 2751 | ret = -ENODEV; |
| 2752 | out: |
| 2753 | drm_modeset_unlock_all(dev); |
| 2754 | return ret; |
| 2755 | } |
| 2756 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2757 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2758 | { |
| 2759 | struct drm_info_node *node = m->private; |
| 2760 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2761 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2762 | u64 power; |
| 2763 | u32 units; |
| 2764 | |
| 2765 | if (INTEL_INFO(dev)->gen < 6) |
| 2766 | return -ENODEV; |
| 2767 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2768 | intel_runtime_pm_get(dev_priv); |
| 2769 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2770 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2771 | power = (power & 0x1f00) >> 8; |
| 2772 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2773 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2774 | power *= units; |
| 2775 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2776 | intel_runtime_pm_put(dev_priv); |
| 2777 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2778 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2779 | |
| 2780 | return 0; |
| 2781 | } |
| 2782 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2783 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2784 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2785 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2786 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2787 | struct drm_i915_private *dev_priv = to_i915(dev); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2788 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2789 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2790 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2791 | |
Chris Wilson | 67d97da | 2016-07-04 08:08:31 +0100 | [diff] [blame] | 2792 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->gt.awake)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2793 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2794 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2795 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2796 | seq_printf(m, "Usage count: %d\n", |
| 2797 | atomic_read(&dev->dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2798 | #else |
| 2799 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2800 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2801 | seq_printf(m, "PCI device power state: %s [%d]\n", |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 2802 | pci_power_name(dev_priv->drm.pdev->current_state), |
| 2803 | dev_priv->drm.pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2804 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2805 | return 0; |
| 2806 | } |
| 2807 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2808 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2809 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2810 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2811 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2812 | struct drm_i915_private *dev_priv = to_i915(dev); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2813 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2814 | int i; |
| 2815 | |
| 2816 | mutex_lock(&power_domains->lock); |
| 2817 | |
| 2818 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2819 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2820 | struct i915_power_well *power_well; |
| 2821 | enum intel_display_power_domain power_domain; |
| 2822 | |
| 2823 | power_well = &power_domains->power_wells[i]; |
| 2824 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2825 | power_well->count); |
| 2826 | |
| 2827 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2828 | power_domain++) { |
| 2829 | if (!(BIT(power_domain) & power_well->domains)) |
| 2830 | continue; |
| 2831 | |
| 2832 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2833 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2834 | power_domains->domain_use_count[power_domain]); |
| 2835 | } |
| 2836 | } |
| 2837 | |
| 2838 | mutex_unlock(&power_domains->lock); |
| 2839 | |
| 2840 | return 0; |
| 2841 | } |
| 2842 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2843 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2844 | { |
| 2845 | struct drm_info_node *node = m->private; |
| 2846 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 2847 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2848 | struct intel_csr *csr; |
| 2849 | |
| 2850 | if (!HAS_CSR(dev)) { |
| 2851 | seq_puts(m, "not supported\n"); |
| 2852 | return 0; |
| 2853 | } |
| 2854 | |
| 2855 | csr = &dev_priv->csr; |
| 2856 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2857 | intel_runtime_pm_get(dev_priv); |
| 2858 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2859 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2860 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2861 | |
| 2862 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2863 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2864 | |
| 2865 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2866 | CSR_VERSION_MINOR(csr->version)); |
| 2867 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2868 | if (IS_SKYLAKE(dev) && csr->version >= CSR_VERSION(1, 6)) { |
| 2869 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2870 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2871 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2872 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2873 | } else if (IS_BROXTON(dev) && csr->version >= CSR_VERSION(1, 4)) { |
| 2874 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2875 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2876 | } |
| 2877 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2878 | out: |
| 2879 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2880 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2881 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2882 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2883 | intel_runtime_pm_put(dev_priv); |
| 2884 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2885 | return 0; |
| 2886 | } |
| 2887 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2888 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2889 | struct drm_display_mode *mode) |
| 2890 | { |
| 2891 | int i; |
| 2892 | |
| 2893 | for (i = 0; i < tabs; i++) |
| 2894 | seq_putc(m, '\t'); |
| 2895 | |
| 2896 | 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", |
| 2897 | mode->base.id, mode->name, |
| 2898 | mode->vrefresh, mode->clock, |
| 2899 | mode->hdisplay, mode->hsync_start, |
| 2900 | mode->hsync_end, mode->htotal, |
| 2901 | mode->vdisplay, mode->vsync_start, |
| 2902 | mode->vsync_end, mode->vtotal, |
| 2903 | mode->type, mode->flags); |
| 2904 | } |
| 2905 | |
| 2906 | static void intel_encoder_info(struct seq_file *m, |
| 2907 | struct intel_crtc *intel_crtc, |
| 2908 | struct intel_encoder *intel_encoder) |
| 2909 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2910 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2911 | struct drm_device *dev = node->minor->dev; |
| 2912 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2913 | struct intel_connector *intel_connector; |
| 2914 | struct drm_encoder *encoder; |
| 2915 | |
| 2916 | encoder = &intel_encoder->base; |
| 2917 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2918 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2919 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2920 | struct drm_connector *connector = &intel_connector->base; |
| 2921 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2922 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2923 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2924 | drm_get_connector_status_name(connector->status)); |
| 2925 | if (connector->status == connector_status_connected) { |
| 2926 | struct drm_display_mode *mode = &crtc->mode; |
| 2927 | seq_printf(m, ", mode:\n"); |
| 2928 | intel_seq_print_mode(m, 2, mode); |
| 2929 | } else { |
| 2930 | seq_putc(m, '\n'); |
| 2931 | } |
| 2932 | } |
| 2933 | } |
| 2934 | |
| 2935 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2936 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2937 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2938 | struct drm_device *dev = node->minor->dev; |
| 2939 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2940 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2941 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2942 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2943 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2944 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2945 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2946 | fb->base.id, plane_state->src_x >> 16, |
| 2947 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2948 | else |
| 2949 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2950 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2951 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2952 | } |
| 2953 | |
| 2954 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2955 | { |
| 2956 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2957 | |
| 2958 | seq_printf(m, "\tfixed mode:\n"); |
| 2959 | intel_seq_print_mode(m, 2, mode); |
| 2960 | } |
| 2961 | |
| 2962 | static void intel_dp_info(struct seq_file *m, |
| 2963 | struct intel_connector *intel_connector) |
| 2964 | { |
| 2965 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2966 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2967 | |
| 2968 | 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] | 2969 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 2970 | if (intel_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2971 | intel_panel_info(m, &intel_connector->panel); |
| 2972 | } |
| 2973 | |
| 2974 | static void intel_hdmi_info(struct seq_file *m, |
| 2975 | struct intel_connector *intel_connector) |
| 2976 | { |
| 2977 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2978 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2979 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2980 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2981 | } |
| 2982 | |
| 2983 | static void intel_lvds_info(struct seq_file *m, |
| 2984 | struct intel_connector *intel_connector) |
| 2985 | { |
| 2986 | intel_panel_info(m, &intel_connector->panel); |
| 2987 | } |
| 2988 | |
| 2989 | static void intel_connector_info(struct seq_file *m, |
| 2990 | struct drm_connector *connector) |
| 2991 | { |
| 2992 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2993 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2994 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2995 | |
| 2996 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2997 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2998 | drm_get_connector_status_name(connector->status)); |
| 2999 | if (connector->status == connector_status_connected) { |
| 3000 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 3001 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 3002 | connector->display_info.width_mm, |
| 3003 | connector->display_info.height_mm); |
| 3004 | seq_printf(m, "\tsubpixel order: %s\n", |
| 3005 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 3006 | seq_printf(m, "\tCEA rev: %d\n", |
| 3007 | connector->display_info.cea_rev); |
| 3008 | } |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3009 | |
| 3010 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3011 | return; |
| 3012 | |
| 3013 | switch (connector->connector_type) { |
| 3014 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 3015 | case DRM_MODE_CONNECTOR_eDP: |
| 3016 | intel_dp_info(m, intel_connector); |
| 3017 | break; |
| 3018 | case DRM_MODE_CONNECTOR_LVDS: |
| 3019 | if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3020 | intel_lvds_info(m, intel_connector); |
Maarten Lankhorst | ee648a7 | 2016-06-21 12:00:38 +0200 | [diff] [blame] | 3021 | break; |
| 3022 | case DRM_MODE_CONNECTOR_HDMIA: |
| 3023 | if (intel_encoder->type == INTEL_OUTPUT_HDMI || |
| 3024 | intel_encoder->type == INTEL_OUTPUT_UNKNOWN) |
| 3025 | intel_hdmi_info(m, intel_connector); |
| 3026 | break; |
| 3027 | default: |
| 3028 | break; |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 3029 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3030 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 3031 | seq_printf(m, "\tmodes:\n"); |
| 3032 | list_for_each_entry(mode, &connector->modes, head) |
| 3033 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3034 | } |
| 3035 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3036 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 3037 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3038 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3039 | u32 state; |
| 3040 | |
| 3041 | if (IS_845G(dev) || IS_I865G(dev)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 3042 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3043 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 3044 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3045 | |
| 3046 | return state; |
| 3047 | } |
| 3048 | |
| 3049 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 3050 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3051 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3052 | u32 pos; |
| 3053 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 3054 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3055 | |
| 3056 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 3057 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 3058 | *x = -*x; |
| 3059 | |
| 3060 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 3061 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 3062 | *y = -*y; |
| 3063 | |
| 3064 | return cursor_active(dev, pipe); |
| 3065 | } |
| 3066 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3067 | static const char *plane_type(enum drm_plane_type type) |
| 3068 | { |
| 3069 | switch (type) { |
| 3070 | case DRM_PLANE_TYPE_OVERLAY: |
| 3071 | return "OVL"; |
| 3072 | case DRM_PLANE_TYPE_PRIMARY: |
| 3073 | return "PRI"; |
| 3074 | case DRM_PLANE_TYPE_CURSOR: |
| 3075 | return "CUR"; |
| 3076 | /* |
| 3077 | * Deliberately omitting default: to generate compiler warnings |
| 3078 | * when a new drm_plane_type gets added. |
| 3079 | */ |
| 3080 | } |
| 3081 | |
| 3082 | return "unknown"; |
| 3083 | } |
| 3084 | |
| 3085 | static const char *plane_rotation(unsigned int rotation) |
| 3086 | { |
| 3087 | static char buf[48]; |
| 3088 | /* |
| 3089 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3090 | * will print them all to visualize if the values are misused |
| 3091 | */ |
| 3092 | snprintf(buf, sizeof(buf), |
| 3093 | "%s%s%s%s%s%s(0x%08x)", |
| 3094 | (rotation & BIT(DRM_ROTATE_0)) ? "0 " : "", |
| 3095 | (rotation & BIT(DRM_ROTATE_90)) ? "90 " : "", |
| 3096 | (rotation & BIT(DRM_ROTATE_180)) ? "180 " : "", |
| 3097 | (rotation & BIT(DRM_ROTATE_270)) ? "270 " : "", |
| 3098 | (rotation & BIT(DRM_REFLECT_X)) ? "FLIPX " : "", |
| 3099 | (rotation & BIT(DRM_REFLECT_Y)) ? "FLIPY " : "", |
| 3100 | rotation); |
| 3101 | |
| 3102 | return buf; |
| 3103 | } |
| 3104 | |
| 3105 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3106 | { |
| 3107 | struct drm_info_node *node = m->private; |
| 3108 | struct drm_device *dev = node->minor->dev; |
| 3109 | struct intel_plane *intel_plane; |
| 3110 | |
| 3111 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3112 | struct drm_plane_state *state; |
| 3113 | struct drm_plane *plane = &intel_plane->base; |
| 3114 | |
| 3115 | if (!plane->state) { |
| 3116 | seq_puts(m, "plane->state is NULL!\n"); |
| 3117 | continue; |
| 3118 | } |
| 3119 | |
| 3120 | state = plane->state; |
| 3121 | |
| 3122 | 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", |
| 3123 | plane->base.id, |
| 3124 | plane_type(intel_plane->base.type), |
| 3125 | state->crtc_x, state->crtc_y, |
| 3126 | state->crtc_w, state->crtc_h, |
| 3127 | (state->src_x >> 16), |
| 3128 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3129 | (state->src_y >> 16), |
| 3130 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3131 | (state->src_w >> 16), |
| 3132 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3133 | (state->src_h >> 16), |
| 3134 | ((state->src_h & 0xffff) * 15625) >> 10, |
| 3135 | state->fb ? drm_get_format_name(state->fb->pixel_format) : "N/A", |
| 3136 | plane_rotation(state->rotation)); |
| 3137 | } |
| 3138 | } |
| 3139 | |
| 3140 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3141 | { |
| 3142 | struct intel_crtc_state *pipe_config; |
| 3143 | int num_scalers = intel_crtc->num_scalers; |
| 3144 | int i; |
| 3145 | |
| 3146 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3147 | |
| 3148 | /* Not all platformas have a scaler */ |
| 3149 | if (num_scalers) { |
| 3150 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3151 | num_scalers, |
| 3152 | pipe_config->scaler_state.scaler_users, |
| 3153 | pipe_config->scaler_state.scaler_id); |
| 3154 | |
| 3155 | for (i = 0; i < SKL_NUM_SCALERS; i++) { |
| 3156 | struct intel_scaler *sc = |
| 3157 | &pipe_config->scaler_state.scalers[i]; |
| 3158 | |
| 3159 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3160 | i, yesno(sc->in_use), sc->mode); |
| 3161 | } |
| 3162 | seq_puts(m, "\n"); |
| 3163 | } else { |
| 3164 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3165 | } |
| 3166 | } |
| 3167 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3168 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3169 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 3170 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3171 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3172 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3173 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3174 | struct drm_connector *connector; |
| 3175 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3176 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3177 | drm_modeset_lock_all(dev); |
| 3178 | seq_printf(m, "CRTC info\n"); |
| 3179 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3180 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3181 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3182 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3183 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3184 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3185 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3186 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3187 | seq_printf(m, "CRTC %d: pipe: %c, active=%s, (size=%dx%d), dither=%s, bpp=%d\n", |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3188 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3189 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3190 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3191 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3192 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3193 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3194 | intel_crtc_info(m, crtc); |
| 3195 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3196 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3197 | 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] | 3198 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3199 | x, y, crtc->base.cursor->state->crtc_w, |
| 3200 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3201 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3202 | intel_scaler_info(m, crtc); |
| 3203 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3204 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3205 | |
| 3206 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3207 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3208 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3209 | } |
| 3210 | |
| 3211 | seq_printf(m, "\n"); |
| 3212 | seq_printf(m, "Connector info\n"); |
| 3213 | seq_printf(m, "--------------\n"); |
| 3214 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3215 | intel_connector_info(m, connector); |
| 3216 | } |
| 3217 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3218 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3219 | |
| 3220 | return 0; |
| 3221 | } |
| 3222 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3223 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3224 | { |
| 3225 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3226 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3227 | struct drm_i915_private *dev_priv = to_i915(dev); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3228 | struct intel_engine_cs *engine; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3229 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3230 | enum intel_engine_id id; |
| 3231 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3232 | |
Chris Wilson | 39df919 | 2016-07-20 13:31:57 +0100 | [diff] [blame] | 3233 | if (!i915.semaphores) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3234 | seq_puts(m, "Semaphores are disabled\n"); |
| 3235 | return 0; |
| 3236 | } |
| 3237 | |
| 3238 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3239 | if (ret) |
| 3240 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3241 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3242 | |
| 3243 | if (IS_BROADWELL(dev)) { |
| 3244 | struct page *page; |
| 3245 | uint64_t *seqno; |
| 3246 | |
| 3247 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 3248 | |
| 3249 | seqno = (uint64_t *)kmap_atomic(page); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3250 | for_each_engine_id(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3251 | uint64_t offset; |
| 3252 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3253 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3254 | |
| 3255 | seq_puts(m, " Last signal:"); |
| 3256 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3257 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3258 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3259 | seqno[offset], offset * 8); |
| 3260 | } |
| 3261 | seq_putc(m, '\n'); |
| 3262 | |
| 3263 | seq_puts(m, " Last wait: "); |
| 3264 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3265 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3266 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3267 | seqno[offset], offset * 8); |
| 3268 | } |
| 3269 | seq_putc(m, '\n'); |
| 3270 | |
| 3271 | } |
| 3272 | kunmap_atomic(seqno); |
| 3273 | } else { |
| 3274 | seq_puts(m, " Last signal:"); |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 3275 | for_each_engine(engine, dev_priv) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3276 | for (j = 0; j < num_rings; j++) |
| 3277 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3278 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3279 | seq_putc(m, '\n'); |
| 3280 | } |
| 3281 | |
| 3282 | seq_puts(m, "\nSync seqno:\n"); |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 3283 | for_each_engine(engine, dev_priv) { |
| 3284 | for (j = 0; j < num_rings; j++) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3285 | seq_printf(m, " 0x%08x ", |
| 3286 | engine->semaphore.sync_seqno[j]); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3287 | seq_putc(m, '\n'); |
| 3288 | } |
| 3289 | seq_putc(m, '\n'); |
| 3290 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3291 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3292 | mutex_unlock(&dev->struct_mutex); |
| 3293 | return 0; |
| 3294 | } |
| 3295 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3296 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3297 | { |
| 3298 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3299 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3300 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3301 | int i; |
| 3302 | |
| 3303 | drm_modeset_lock_all(dev); |
| 3304 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3305 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3306 | |
| 3307 | 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] | 3308 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
| 3309 | pll->config.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3310 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3311 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 3312 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 3313 | pll->config.hw_state.dpll_md); |
| 3314 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 3315 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 3316 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3317 | } |
| 3318 | drm_modeset_unlock_all(dev); |
| 3319 | |
| 3320 | return 0; |
| 3321 | } |
| 3322 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3323 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3324 | { |
| 3325 | int i; |
| 3326 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3327 | struct intel_engine_cs *engine; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3328 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3329 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3330 | struct drm_i915_private *dev_priv = to_i915(dev); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3331 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3332 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3333 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3334 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3335 | if (ret) |
| 3336 | return ret; |
| 3337 | |
| 3338 | intel_runtime_pm_get(dev_priv); |
| 3339 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3340 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3341 | for_each_engine_id(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3342 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3343 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3344 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3345 | i915_reg_t addr; |
| 3346 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3347 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3348 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3349 | addr = workarounds->reg[i].addr; |
| 3350 | mask = workarounds->reg[i].mask; |
| 3351 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3352 | read = I915_READ(addr); |
| 3353 | ok = (value & mask) == (read & mask); |
| 3354 | 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] | 3355 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3356 | } |
| 3357 | |
| 3358 | intel_runtime_pm_put(dev_priv); |
| 3359 | mutex_unlock(&dev->struct_mutex); |
| 3360 | |
| 3361 | return 0; |
| 3362 | } |
| 3363 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3364 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3365 | { |
| 3366 | struct drm_info_node *node = m->private; |
| 3367 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3368 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3369 | struct skl_ddb_allocation *ddb; |
| 3370 | struct skl_ddb_entry *entry; |
| 3371 | enum pipe pipe; |
| 3372 | int plane; |
| 3373 | |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3374 | if (INTEL_INFO(dev)->gen < 9) |
| 3375 | return 0; |
| 3376 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3377 | drm_modeset_lock_all(dev); |
| 3378 | |
| 3379 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3380 | |
| 3381 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3382 | |
| 3383 | for_each_pipe(dev_priv, pipe) { |
| 3384 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3385 | |
Damien Lespiau | dd74078 | 2015-02-28 14:54:08 +0000 | [diff] [blame] | 3386 | for_each_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3387 | entry = &ddb->plane[pipe][plane]; |
| 3388 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3389 | entry->start, entry->end, |
| 3390 | skl_ddb_entry_size(entry)); |
| 3391 | } |
| 3392 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3393 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3394 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3395 | entry->end, skl_ddb_entry_size(entry)); |
| 3396 | } |
| 3397 | |
| 3398 | drm_modeset_unlock_all(dev); |
| 3399 | |
| 3400 | return 0; |
| 3401 | } |
| 3402 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3403 | static void drrs_status_per_crtc(struct seq_file *m, |
| 3404 | struct drm_device *dev, struct intel_crtc *intel_crtc) |
| 3405 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3406 | struct drm_i915_private *dev_priv = to_i915(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3407 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3408 | int vrefresh = 0; |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3409 | struct drm_connector *connector; |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3410 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3411 | drm_for_each_connector(connector, dev) { |
| 3412 | if (connector->state->crtc != &intel_crtc->base) |
| 3413 | continue; |
| 3414 | |
| 3415 | seq_printf(m, "%s:\n", connector->name); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3416 | } |
| 3417 | |
| 3418 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3419 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3420 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3421 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3422 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3423 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3424 | else |
| 3425 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3426 | |
| 3427 | seq_puts(m, "\n\n"); |
| 3428 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3429 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3430 | struct intel_panel *panel; |
| 3431 | |
| 3432 | mutex_lock(&drrs->mutex); |
| 3433 | /* DRRS Supported */ |
| 3434 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3435 | |
| 3436 | /* disable_drrs() will make drrs->dp NULL */ |
| 3437 | if (!drrs->dp) { |
| 3438 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3439 | mutex_unlock(&drrs->mutex); |
| 3440 | return; |
| 3441 | } |
| 3442 | |
| 3443 | panel = &drrs->dp->attached_connector->panel; |
| 3444 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3445 | drrs->busy_frontbuffer_bits); |
| 3446 | |
| 3447 | seq_puts(m, "\n\t\t"); |
| 3448 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3449 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3450 | vrefresh = panel->fixed_mode->vrefresh; |
| 3451 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3452 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3453 | vrefresh = panel->downclock_mode->vrefresh; |
| 3454 | } else { |
| 3455 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3456 | drrs->refresh_rate_type); |
| 3457 | mutex_unlock(&drrs->mutex); |
| 3458 | return; |
| 3459 | } |
| 3460 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3461 | |
| 3462 | seq_puts(m, "\n\t\t"); |
| 3463 | mutex_unlock(&drrs->mutex); |
| 3464 | } else { |
| 3465 | /* DRRS not supported. Print the VBT parameter*/ |
| 3466 | seq_puts(m, "\tDRRS Supported : No"); |
| 3467 | } |
| 3468 | seq_puts(m, "\n"); |
| 3469 | } |
| 3470 | |
| 3471 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3472 | { |
| 3473 | struct drm_info_node *node = m->private; |
| 3474 | struct drm_device *dev = node->minor->dev; |
| 3475 | struct intel_crtc *intel_crtc; |
| 3476 | int active_crtc_cnt = 0; |
| 3477 | |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3478 | drm_modeset_lock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3479 | for_each_intel_crtc(dev, intel_crtc) { |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3480 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3481 | active_crtc_cnt++; |
| 3482 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3483 | |
| 3484 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3485 | } |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3486 | } |
Maarten Lankhorst | 26875fe | 2016-06-20 15:57:36 +0200 | [diff] [blame] | 3487 | drm_modeset_unlock_all(dev); |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3488 | |
| 3489 | if (!active_crtc_cnt) |
| 3490 | seq_puts(m, "No active crtc found\n"); |
| 3491 | |
| 3492 | return 0; |
| 3493 | } |
| 3494 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3495 | struct pipe_crc_info { |
| 3496 | const char *name; |
| 3497 | struct drm_device *dev; |
| 3498 | enum pipe pipe; |
| 3499 | }; |
| 3500 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3501 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3502 | { |
| 3503 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3504 | struct drm_device *dev = node->minor->dev; |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3505 | struct intel_encoder *intel_encoder; |
| 3506 | struct intel_digital_port *intel_dig_port; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3507 | struct drm_connector *connector; |
| 3508 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3509 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3510 | drm_for_each_connector(connector, dev) { |
| 3511 | if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3512 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3513 | |
| 3514 | intel_encoder = intel_attached_encoder(connector); |
| 3515 | if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) |
| 3516 | continue; |
| 3517 | |
| 3518 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3519 | if (!intel_dig_port->dp.can_mst) |
| 3520 | continue; |
Maarten Lankhorst | b6dabe3 | 2016-06-20 15:57:37 +0200 | [diff] [blame] | 3521 | |
Jim Bride | 40ae80c | 2016-04-14 10:18:37 -0700 | [diff] [blame] | 3522 | seq_printf(m, "MST Source Port %c\n", |
| 3523 | port_name(intel_dig_port->port)); |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3524 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3525 | } |
| 3526 | drm_modeset_unlock_all(dev); |
| 3527 | return 0; |
| 3528 | } |
| 3529 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3530 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3531 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3532 | struct pipe_crc_info *info = inode->i_private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3533 | struct drm_i915_private *dev_priv = to_i915(info->dev); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3534 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3535 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 3536 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 3537 | return -ENODEV; |
| 3538 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3539 | spin_lock_irq(&pipe_crc->lock); |
| 3540 | |
| 3541 | if (pipe_crc->opened) { |
| 3542 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3543 | return -EBUSY; /* already open */ |
| 3544 | } |
| 3545 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3546 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3547 | filep->private_data = inode->i_private; |
| 3548 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3549 | spin_unlock_irq(&pipe_crc->lock); |
| 3550 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3551 | return 0; |
| 3552 | } |
| 3553 | |
| 3554 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 3555 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3556 | struct pipe_crc_info *info = inode->i_private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3557 | struct drm_i915_private *dev_priv = to_i915(info->dev); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3558 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3559 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3560 | spin_lock_irq(&pipe_crc->lock); |
| 3561 | pipe_crc->opened = false; |
| 3562 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3563 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3564 | return 0; |
| 3565 | } |
| 3566 | |
| 3567 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 3568 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 3569 | /* account for \'0' */ |
| 3570 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 3571 | |
| 3572 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 3573 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3574 | assert_spin_locked(&pipe_crc->lock); |
| 3575 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3576 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3577 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3578 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3579 | static ssize_t |
| 3580 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 3581 | loff_t *pos) |
| 3582 | { |
| 3583 | struct pipe_crc_info *info = filep->private_data; |
| 3584 | struct drm_device *dev = info->dev; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3585 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3586 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3587 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3588 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3589 | ssize_t bytes_read; |
| 3590 | |
| 3591 | /* |
| 3592 | * Don't allow user space to provide buffers not big enough to hold |
| 3593 | * a line of data. |
| 3594 | */ |
| 3595 | if (count < PIPE_CRC_LINE_LEN) |
| 3596 | return -EINVAL; |
| 3597 | |
| 3598 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 3599 | return 0; |
| 3600 | |
| 3601 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3602 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3603 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3604 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3605 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3606 | if (filep->f_flags & O_NONBLOCK) { |
| 3607 | spin_unlock_irq(&pipe_crc->lock); |
| 3608 | return -EAGAIN; |
| 3609 | } |
| 3610 | |
| 3611 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 3612 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 3613 | if (ret) { |
| 3614 | spin_unlock_irq(&pipe_crc->lock); |
| 3615 | return ret; |
| 3616 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3617 | } |
| 3618 | |
| 3619 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3620 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3621 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3622 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3623 | while (n_entries > 0) { |
| 3624 | struct intel_pipe_crc_entry *entry = |
| 3625 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3626 | int ret; |
| 3627 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3628 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3629 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3630 | break; |
| 3631 | |
| 3632 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3633 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3634 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3635 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3636 | "%8u %8x %8x %8x %8x %8x\n", |
| 3637 | entry->frame, entry->crc[0], |
| 3638 | entry->crc[1], entry->crc[2], |
| 3639 | entry->crc[3], entry->crc[4]); |
| 3640 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3641 | spin_unlock_irq(&pipe_crc->lock); |
| 3642 | |
| 3643 | ret = copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3644 | if (ret == PIPE_CRC_LINE_LEN) |
| 3645 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3646 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3647 | user_buf += PIPE_CRC_LINE_LEN; |
| 3648 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3649 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3650 | spin_lock_irq(&pipe_crc->lock); |
| 3651 | } |
| 3652 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3653 | spin_unlock_irq(&pipe_crc->lock); |
| 3654 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3655 | return bytes_read; |
| 3656 | } |
| 3657 | |
| 3658 | static const struct file_operations i915_pipe_crc_fops = { |
| 3659 | .owner = THIS_MODULE, |
| 3660 | .open = i915_pipe_crc_open, |
| 3661 | .read = i915_pipe_crc_read, |
| 3662 | .release = i915_pipe_crc_release, |
| 3663 | }; |
| 3664 | |
| 3665 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3666 | { |
| 3667 | .name = "i915_pipe_A_crc", |
| 3668 | .pipe = PIPE_A, |
| 3669 | }, |
| 3670 | { |
| 3671 | .name = "i915_pipe_B_crc", |
| 3672 | .pipe = PIPE_B, |
| 3673 | }, |
| 3674 | { |
| 3675 | .name = "i915_pipe_C_crc", |
| 3676 | .pipe = PIPE_C, |
| 3677 | }, |
| 3678 | }; |
| 3679 | |
| 3680 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3681 | enum pipe pipe) |
| 3682 | { |
| 3683 | struct drm_device *dev = minor->dev; |
| 3684 | struct dentry *ent; |
| 3685 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3686 | |
| 3687 | info->dev = dev; |
| 3688 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3689 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3690 | if (!ent) |
| 3691 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3692 | |
| 3693 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3694 | } |
| 3695 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3696 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3697 | "none", |
| 3698 | "plane1", |
| 3699 | "plane2", |
| 3700 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3701 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3702 | "TV", |
| 3703 | "DP-B", |
| 3704 | "DP-C", |
| 3705 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3706 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3707 | }; |
| 3708 | |
| 3709 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3710 | { |
| 3711 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3712 | return pipe_crc_sources[source]; |
| 3713 | } |
| 3714 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3715 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3716 | { |
| 3717 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3718 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3719 | int i; |
| 3720 | |
| 3721 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3722 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3723 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3724 | |
| 3725 | return 0; |
| 3726 | } |
| 3727 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3728 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3729 | { |
| 3730 | struct drm_device *dev = inode->i_private; |
| 3731 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3732 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3733 | } |
| 3734 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3735 | 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] | 3736 | uint32_t *val) |
| 3737 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3738 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3739 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3740 | |
| 3741 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3742 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3743 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3744 | break; |
| 3745 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3746 | *val = 0; |
| 3747 | break; |
| 3748 | default: |
| 3749 | return -EINVAL; |
| 3750 | } |
| 3751 | |
| 3752 | return 0; |
| 3753 | } |
| 3754 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3755 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 3756 | enum intel_pipe_crc_source *source) |
| 3757 | { |
| 3758 | struct intel_encoder *encoder; |
| 3759 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3760 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3761 | int ret = 0; |
| 3762 | |
| 3763 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3764 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3765 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3766 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3767 | if (!encoder->base.crtc) |
| 3768 | continue; |
| 3769 | |
| 3770 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3771 | |
| 3772 | if (crtc->pipe != pipe) |
| 3773 | continue; |
| 3774 | |
| 3775 | switch (encoder->type) { |
| 3776 | case INTEL_OUTPUT_TVOUT: |
| 3777 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3778 | break; |
Ville Syrjälä | cca0502 | 2016-06-22 21:57:06 +0300 | [diff] [blame] | 3779 | case INTEL_OUTPUT_DP: |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3780 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3781 | dig_port = enc_to_dig_port(&encoder->base); |
| 3782 | switch (dig_port->port) { |
| 3783 | case PORT_B: |
| 3784 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3785 | break; |
| 3786 | case PORT_C: |
| 3787 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3788 | break; |
| 3789 | case PORT_D: |
| 3790 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3791 | break; |
| 3792 | default: |
| 3793 | WARN(1, "nonexisting DP port %c\n", |
| 3794 | port_name(dig_port->port)); |
| 3795 | break; |
| 3796 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3797 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3798 | default: |
| 3799 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3800 | } |
| 3801 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3802 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3803 | |
| 3804 | return ret; |
| 3805 | } |
| 3806 | |
| 3807 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3808 | enum pipe pipe, |
| 3809 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3810 | uint32_t *val) |
| 3811 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3812 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3813 | bool need_stable_symbols = false; |
| 3814 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3815 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3816 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3817 | if (ret) |
| 3818 | return ret; |
| 3819 | } |
| 3820 | |
| 3821 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3822 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3823 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3824 | break; |
| 3825 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3826 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3827 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3828 | break; |
| 3829 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3830 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3831 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3832 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3833 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3834 | if (!IS_CHERRYVIEW(dev)) |
| 3835 | return -EINVAL; |
| 3836 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3837 | need_stable_symbols = true; |
| 3838 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3839 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3840 | *val = 0; |
| 3841 | break; |
| 3842 | default: |
| 3843 | return -EINVAL; |
| 3844 | } |
| 3845 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3846 | /* |
| 3847 | * When the pipe CRC tap point is after the transcoders we need |
| 3848 | * to tweak symbol-level features to produce a deterministic series of |
| 3849 | * symbols for a given frame. We need to reset those features only once |
| 3850 | * a frame (instead of every nth symbol): |
| 3851 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3852 | * link (SDVO) |
| 3853 | * - DisplayPort scrambling: used for EMI reduction |
| 3854 | */ |
| 3855 | if (need_stable_symbols) { |
| 3856 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3857 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3858 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3859 | switch (pipe) { |
| 3860 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3861 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3862 | break; |
| 3863 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3864 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3865 | break; |
| 3866 | case PIPE_C: |
| 3867 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3868 | break; |
| 3869 | default: |
| 3870 | return -EINVAL; |
| 3871 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3872 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3873 | } |
| 3874 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3875 | return 0; |
| 3876 | } |
| 3877 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3878 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3879 | enum pipe pipe, |
| 3880 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3881 | uint32_t *val) |
| 3882 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3883 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3884 | bool need_stable_symbols = false; |
| 3885 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3886 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3887 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3888 | if (ret) |
| 3889 | return ret; |
| 3890 | } |
| 3891 | |
| 3892 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3893 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3894 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3895 | break; |
| 3896 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 3897 | if (!SUPPORTS_TV(dev)) |
| 3898 | return -EINVAL; |
| 3899 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3900 | break; |
| 3901 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3902 | if (!IS_G4X(dev)) |
| 3903 | return -EINVAL; |
| 3904 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3905 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3906 | break; |
| 3907 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3908 | if (!IS_G4X(dev)) |
| 3909 | return -EINVAL; |
| 3910 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3911 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3912 | break; |
| 3913 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3914 | if (!IS_G4X(dev)) |
| 3915 | return -EINVAL; |
| 3916 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3917 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3918 | break; |
| 3919 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3920 | *val = 0; |
| 3921 | break; |
| 3922 | default: |
| 3923 | return -EINVAL; |
| 3924 | } |
| 3925 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3926 | /* |
| 3927 | * When the pipe CRC tap point is after the transcoders we need |
| 3928 | * to tweak symbol-level features to produce a deterministic series of |
| 3929 | * symbols for a given frame. We need to reset those features only once |
| 3930 | * a frame (instead of every nth symbol): |
| 3931 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3932 | * link (SDVO) |
| 3933 | * - DisplayPort scrambling: used for EMI reduction |
| 3934 | */ |
| 3935 | if (need_stable_symbols) { |
| 3936 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3937 | |
| 3938 | WARN_ON(!IS_G4X(dev)); |
| 3939 | |
| 3940 | I915_WRITE(PORT_DFT_I9XX, |
| 3941 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3942 | |
| 3943 | if (pipe == PIPE_A) |
| 3944 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3945 | else |
| 3946 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3947 | |
| 3948 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3949 | } |
| 3950 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3951 | return 0; |
| 3952 | } |
| 3953 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3954 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3955 | enum pipe pipe) |
| 3956 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3957 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3958 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3959 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3960 | switch (pipe) { |
| 3961 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3962 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3963 | break; |
| 3964 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3965 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3966 | break; |
| 3967 | case PIPE_C: |
| 3968 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 3969 | break; |
| 3970 | default: |
| 3971 | return; |
| 3972 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3973 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3974 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3975 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3976 | |
| 3977 | } |
| 3978 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3979 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3980 | enum pipe pipe) |
| 3981 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 3982 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3983 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3984 | |
| 3985 | if (pipe == PIPE_A) |
| 3986 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3987 | else |
| 3988 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3989 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3990 | |
| 3991 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3992 | I915_WRITE(PORT_DFT_I9XX, |
| 3993 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3994 | } |
| 3995 | } |
| 3996 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3997 | 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] | 3998 | uint32_t *val) |
| 3999 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4000 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4001 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 4002 | |
| 4003 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4004 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4005 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 4006 | break; |
| 4007 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4008 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 4009 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4010 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 4011 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 4012 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4013 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4014 | *val = 0; |
| 4015 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4016 | default: |
| 4017 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4018 | } |
| 4019 | |
| 4020 | return 0; |
| 4021 | } |
| 4022 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4023 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_device *dev, bool enable) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4024 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4025 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4026 | struct intel_crtc *crtc = |
| 4027 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4028 | struct intel_crtc_state *pipe_config; |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4029 | struct drm_atomic_state *state; |
| 4030 | int ret = 0; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4031 | |
| 4032 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4033 | state = drm_atomic_state_alloc(dev); |
| 4034 | if (!state) { |
| 4035 | ret = -ENOMEM; |
| 4036 | goto out; |
| 4037 | } |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4038 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4039 | state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base); |
| 4040 | pipe_config = intel_atomic_get_crtc_state(state, crtc); |
| 4041 | if (IS_ERR(pipe_config)) { |
| 4042 | ret = PTR_ERR(pipe_config); |
| 4043 | goto out; |
| 4044 | } |
| 4045 | |
| 4046 | pipe_config->pch_pfit.force_thru = enable; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4047 | if (pipe_config->cpu_transcoder == TRANSCODER_EDP && |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4048 | pipe_config->pch_pfit.enabled != enable) |
| 4049 | pipe_config->base.connectors_changed = true; |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 4050 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4051 | ret = drm_atomic_commit(state); |
| 4052 | out: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4053 | drm_modeset_unlock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4054 | WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret); |
| 4055 | if (ret) |
| 4056 | drm_atomic_state_free(state); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4057 | } |
| 4058 | |
| 4059 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 4060 | enum pipe pipe, |
| 4061 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4062 | uint32_t *val) |
| 4063 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4064 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4065 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 4066 | |
| 4067 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4068 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4069 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 4070 | break; |
| 4071 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4072 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 4073 | break; |
| 4074 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4075 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4076 | hsw_trans_edp_pipe_A_crc_wa(dev, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4077 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4078 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 4079 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4080 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4081 | *val = 0; |
| 4082 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4083 | default: |
| 4084 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | return 0; |
| 4088 | } |
| 4089 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4090 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 4091 | enum intel_pipe_crc_source source) |
| 4092 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4093 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4094 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4095 | struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, |
| 4096 | pipe)); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4097 | enum intel_display_power_domain power_domain; |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 4098 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4099 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4100 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4101 | if (pipe_crc->source == source) |
| 4102 | return 0; |
| 4103 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 4104 | /* forbid changing the source without going back to 'none' */ |
| 4105 | if (pipe_crc->source && source) |
| 4106 | return -EINVAL; |
| 4107 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4108 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 4109 | if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) { |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 4110 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 4111 | return -EIO; |
| 4112 | } |
| 4113 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 4114 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4115 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 4116 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4117 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4118 | else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4119 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 4120 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4121 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4122 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4123 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4124 | |
| 4125 | if (ret != 0) |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4126 | goto out; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4127 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4128 | /* none -> real source transition */ |
| 4129 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4130 | struct intel_pipe_crc_entry *entries; |
| 4131 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4132 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 4133 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 4134 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 4135 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 4136 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4137 | GFP_KERNEL); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4138 | if (!entries) { |
| 4139 | ret = -ENOMEM; |
| 4140 | goto out; |
| 4141 | } |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4142 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4143 | /* |
| 4144 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 4145 | * enabled and disabled dynamically based on package C states, |
| 4146 | * user space can't make reliable use of the CRCs, so let's just |
| 4147 | * completely disable it. |
| 4148 | */ |
| 4149 | hsw_disable_ips(crtc); |
| 4150 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4151 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 4152 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4153 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4154 | pipe_crc->head = 0; |
| 4155 | pipe_crc->tail = 0; |
| 4156 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4157 | } |
| 4158 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4159 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4160 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4161 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 4162 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 4163 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4164 | /* real source -> none transition */ |
| 4165 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4166 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4167 | struct intel_crtc *crtc = |
| 4168 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4169 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4170 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 4171 | pipe_name(pipe)); |
| 4172 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4173 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4174 | if (crtc->base.state->active) |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4175 | intel_wait_for_vblank(dev, pipe); |
| 4176 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 4177 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4178 | spin_lock_irq(&pipe_crc->lock); |
| 4179 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4180 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 4181 | pipe_crc->head = 0; |
| 4182 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4183 | spin_unlock_irq(&pipe_crc->lock); |
| 4184 | |
| 4185 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4186 | |
| 4187 | if (IS_G4X(dev)) |
| 4188 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4189 | else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4190 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4191 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4192 | hsw_trans_edp_pipe_A_crc_wa(dev, false); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4193 | |
| 4194 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4195 | } |
| 4196 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4197 | ret = 0; |
| 4198 | |
| 4199 | out: |
| 4200 | intel_display_power_put(dev_priv, power_domain); |
| 4201 | |
| 4202 | return ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4203 | } |
| 4204 | |
| 4205 | /* |
| 4206 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4207 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 4208 | * object: 'pipe' |
| 4209 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4210 | * source: (none | plane1 | plane2 | pf) |
| 4211 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 4212 | * |
| 4213 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4214 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 4215 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4216 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4217 | 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] | 4218 | { |
| 4219 | int n_words = 0; |
| 4220 | |
| 4221 | while (*buf) { |
| 4222 | char *end; |
| 4223 | |
| 4224 | /* skip leading white space */ |
| 4225 | buf = skip_spaces(buf); |
| 4226 | if (!*buf) |
| 4227 | break; /* end of buffer */ |
| 4228 | |
| 4229 | /* find end of word */ |
| 4230 | for (end = buf; *end && !isspace(*end); end++) |
| 4231 | ; |
| 4232 | |
| 4233 | if (n_words == max_words) { |
| 4234 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 4235 | max_words); |
| 4236 | return -EINVAL; /* ran out of words[] before bytes */ |
| 4237 | } |
| 4238 | |
| 4239 | if (*end) |
| 4240 | *end++ = '\0'; |
| 4241 | words[n_words++] = buf; |
| 4242 | buf = end; |
| 4243 | } |
| 4244 | |
| 4245 | return n_words; |
| 4246 | } |
| 4247 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4248 | enum intel_pipe_crc_object { |
| 4249 | PIPE_CRC_OBJECT_PIPE, |
| 4250 | }; |
| 4251 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 4252 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4253 | "pipe", |
| 4254 | }; |
| 4255 | |
| 4256 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4257 | 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] | 4258 | { |
| 4259 | int i; |
| 4260 | |
| 4261 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 4262 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4263 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4264 | return 0; |
| 4265 | } |
| 4266 | |
| 4267 | return -EINVAL; |
| 4268 | } |
| 4269 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4270 | 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] | 4271 | { |
| 4272 | const char name = buf[0]; |
| 4273 | |
| 4274 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 4275 | return -EINVAL; |
| 4276 | |
| 4277 | *pipe = name - 'A'; |
| 4278 | |
| 4279 | return 0; |
| 4280 | } |
| 4281 | |
| 4282 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4283 | 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] | 4284 | { |
| 4285 | int i; |
| 4286 | |
| 4287 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 4288 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4289 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4290 | return 0; |
| 4291 | } |
| 4292 | |
| 4293 | return -EINVAL; |
| 4294 | } |
| 4295 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4296 | static int display_crc_ctl_parse(struct drm_device *dev, char *buf, size_t len) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4297 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4298 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4299 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4300 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4301 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4302 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4303 | enum intel_pipe_crc_source source; |
| 4304 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4305 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4306 | if (n_words != N_WORDS) { |
| 4307 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 4308 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4309 | return -EINVAL; |
| 4310 | } |
| 4311 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4312 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4313 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4314 | return -EINVAL; |
| 4315 | } |
| 4316 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4317 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4318 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 4319 | return -EINVAL; |
| 4320 | } |
| 4321 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4322 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4323 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4324 | return -EINVAL; |
| 4325 | } |
| 4326 | |
| 4327 | return pipe_crc_set_source(dev, pipe, source); |
| 4328 | } |
| 4329 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4330 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 4331 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4332 | { |
| 4333 | struct seq_file *m = file->private_data; |
| 4334 | struct drm_device *dev = m->private; |
| 4335 | char *tmpbuf; |
| 4336 | int ret; |
| 4337 | |
| 4338 | if (len == 0) |
| 4339 | return 0; |
| 4340 | |
| 4341 | if (len > PAGE_SIZE - 1) { |
| 4342 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 4343 | PAGE_SIZE); |
| 4344 | return -E2BIG; |
| 4345 | } |
| 4346 | |
| 4347 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 4348 | if (!tmpbuf) |
| 4349 | return -ENOMEM; |
| 4350 | |
| 4351 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 4352 | ret = -EFAULT; |
| 4353 | goto out; |
| 4354 | } |
| 4355 | tmpbuf[len] = '\0'; |
| 4356 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4357 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4358 | |
| 4359 | out: |
| 4360 | kfree(tmpbuf); |
| 4361 | if (ret < 0) |
| 4362 | return ret; |
| 4363 | |
| 4364 | *offp += len; |
| 4365 | return len; |
| 4366 | } |
| 4367 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4368 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4369 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4370 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4371 | .read = seq_read, |
| 4372 | .llseek = seq_lseek, |
| 4373 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4374 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4375 | }; |
| 4376 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4377 | static ssize_t i915_displayport_test_active_write(struct file *file, |
| 4378 | const char __user *ubuf, |
| 4379 | size_t len, loff_t *offp) |
| 4380 | { |
| 4381 | char *input_buffer; |
| 4382 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4383 | struct drm_device *dev; |
| 4384 | struct drm_connector *connector; |
| 4385 | struct list_head *connector_list; |
| 4386 | struct intel_dp *intel_dp; |
| 4387 | int val = 0; |
| 4388 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 4389 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4390 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4391 | connector_list = &dev->mode_config.connector_list; |
| 4392 | |
| 4393 | if (len == 0) |
| 4394 | return 0; |
| 4395 | |
| 4396 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 4397 | if (!input_buffer) |
| 4398 | return -ENOMEM; |
| 4399 | |
| 4400 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 4401 | status = -EFAULT; |
| 4402 | goto out; |
| 4403 | } |
| 4404 | |
| 4405 | input_buffer[len] = '\0'; |
| 4406 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 4407 | |
| 4408 | list_for_each_entry(connector, connector_list, head) { |
| 4409 | |
| 4410 | if (connector->connector_type != |
| 4411 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4412 | continue; |
| 4413 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 4414 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4415 | connector->encoder != NULL) { |
| 4416 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4417 | status = kstrtoint(input_buffer, 10, &val); |
| 4418 | if (status < 0) |
| 4419 | goto out; |
| 4420 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 4421 | /* To prevent erroneous activation of the compliance |
| 4422 | * testing code, only accept an actual value of 1 here |
| 4423 | */ |
| 4424 | if (val == 1) |
| 4425 | intel_dp->compliance_test_active = 1; |
| 4426 | else |
| 4427 | intel_dp->compliance_test_active = 0; |
| 4428 | } |
| 4429 | } |
| 4430 | out: |
| 4431 | kfree(input_buffer); |
| 4432 | if (status < 0) |
| 4433 | return status; |
| 4434 | |
| 4435 | *offp += len; |
| 4436 | return len; |
| 4437 | } |
| 4438 | |
| 4439 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 4440 | { |
| 4441 | struct drm_device *dev = m->private; |
| 4442 | struct drm_connector *connector; |
| 4443 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4444 | struct intel_dp *intel_dp; |
| 4445 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4446 | list_for_each_entry(connector, connector_list, head) { |
| 4447 | |
| 4448 | if (connector->connector_type != |
| 4449 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4450 | continue; |
| 4451 | |
| 4452 | if (connector->status == connector_status_connected && |
| 4453 | connector->encoder != NULL) { |
| 4454 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4455 | if (intel_dp->compliance_test_active) |
| 4456 | seq_puts(m, "1"); |
| 4457 | else |
| 4458 | seq_puts(m, "0"); |
| 4459 | } else |
| 4460 | seq_puts(m, "0"); |
| 4461 | } |
| 4462 | |
| 4463 | return 0; |
| 4464 | } |
| 4465 | |
| 4466 | static int i915_displayport_test_active_open(struct inode *inode, |
| 4467 | struct file *file) |
| 4468 | { |
| 4469 | struct drm_device *dev = inode->i_private; |
| 4470 | |
| 4471 | return single_open(file, i915_displayport_test_active_show, dev); |
| 4472 | } |
| 4473 | |
| 4474 | static const struct file_operations i915_displayport_test_active_fops = { |
| 4475 | .owner = THIS_MODULE, |
| 4476 | .open = i915_displayport_test_active_open, |
| 4477 | .read = seq_read, |
| 4478 | .llseek = seq_lseek, |
| 4479 | .release = single_release, |
| 4480 | .write = i915_displayport_test_active_write |
| 4481 | }; |
| 4482 | |
| 4483 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 4484 | { |
| 4485 | struct drm_device *dev = m->private; |
| 4486 | struct drm_connector *connector; |
| 4487 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4488 | struct intel_dp *intel_dp; |
| 4489 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4490 | list_for_each_entry(connector, connector_list, head) { |
| 4491 | |
| 4492 | if (connector->connector_type != |
| 4493 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4494 | continue; |
| 4495 | |
| 4496 | if (connector->status == connector_status_connected && |
| 4497 | connector->encoder != NULL) { |
| 4498 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4499 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 4500 | } else |
| 4501 | seq_puts(m, "0"); |
| 4502 | } |
| 4503 | |
| 4504 | return 0; |
| 4505 | } |
| 4506 | static int i915_displayport_test_data_open(struct inode *inode, |
| 4507 | struct file *file) |
| 4508 | { |
| 4509 | struct drm_device *dev = inode->i_private; |
| 4510 | |
| 4511 | return single_open(file, i915_displayport_test_data_show, dev); |
| 4512 | } |
| 4513 | |
| 4514 | static const struct file_operations i915_displayport_test_data_fops = { |
| 4515 | .owner = THIS_MODULE, |
| 4516 | .open = i915_displayport_test_data_open, |
| 4517 | .read = seq_read, |
| 4518 | .llseek = seq_lseek, |
| 4519 | .release = single_release |
| 4520 | }; |
| 4521 | |
| 4522 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 4523 | { |
| 4524 | struct drm_device *dev = m->private; |
| 4525 | struct drm_connector *connector; |
| 4526 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4527 | struct intel_dp *intel_dp; |
| 4528 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4529 | list_for_each_entry(connector, connector_list, head) { |
| 4530 | |
| 4531 | if (connector->connector_type != |
| 4532 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4533 | continue; |
| 4534 | |
| 4535 | if (connector->status == connector_status_connected && |
| 4536 | connector->encoder != NULL) { |
| 4537 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4538 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 4539 | } else |
| 4540 | seq_puts(m, "0"); |
| 4541 | } |
| 4542 | |
| 4543 | return 0; |
| 4544 | } |
| 4545 | |
| 4546 | static int i915_displayport_test_type_open(struct inode *inode, |
| 4547 | struct file *file) |
| 4548 | { |
| 4549 | struct drm_device *dev = inode->i_private; |
| 4550 | |
| 4551 | return single_open(file, i915_displayport_test_type_show, dev); |
| 4552 | } |
| 4553 | |
| 4554 | static const struct file_operations i915_displayport_test_type_fops = { |
| 4555 | .owner = THIS_MODULE, |
| 4556 | .open = i915_displayport_test_type_open, |
| 4557 | .read = seq_read, |
| 4558 | .llseek = seq_lseek, |
| 4559 | .release = single_release |
| 4560 | }; |
| 4561 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4562 | 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] | 4563 | { |
| 4564 | struct drm_device *dev = m->private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4565 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4566 | int num_levels; |
| 4567 | |
| 4568 | if (IS_CHERRYVIEW(dev)) |
| 4569 | num_levels = 3; |
| 4570 | else if (IS_VALLEYVIEW(dev)) |
| 4571 | num_levels = 1; |
| 4572 | else |
| 4573 | num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4574 | |
| 4575 | drm_modeset_lock_all(dev); |
| 4576 | |
| 4577 | for (level = 0; level < num_levels; level++) { |
| 4578 | unsigned int latency = wm[level]; |
| 4579 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4580 | /* |
| 4581 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4582 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4583 | */ |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4584 | if (INTEL_INFO(dev)->gen >= 9 || IS_VALLEYVIEW(dev) || |
| 4585 | IS_CHERRYVIEW(dev)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4586 | latency *= 10; |
| 4587 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4588 | latency *= 5; |
| 4589 | |
| 4590 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4591 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4592 | } |
| 4593 | |
| 4594 | drm_modeset_unlock_all(dev); |
| 4595 | } |
| 4596 | |
| 4597 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 4598 | { |
| 4599 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4600 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4601 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4602 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4603 | if (INTEL_INFO(dev)->gen >= 9) |
| 4604 | latencies = dev_priv->wm.skl_latency; |
| 4605 | else |
| 4606 | latencies = to_i915(dev)->wm.pri_latency; |
| 4607 | |
| 4608 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4609 | |
| 4610 | return 0; |
| 4611 | } |
| 4612 | |
| 4613 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4614 | { |
| 4615 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4616 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4617 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4618 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4619 | if (INTEL_INFO(dev)->gen >= 9) |
| 4620 | latencies = dev_priv->wm.skl_latency; |
| 4621 | else |
| 4622 | latencies = to_i915(dev)->wm.spr_latency; |
| 4623 | |
| 4624 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4625 | |
| 4626 | return 0; |
| 4627 | } |
| 4628 | |
| 4629 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4630 | { |
| 4631 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4632 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4633 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4634 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4635 | if (INTEL_INFO(dev)->gen >= 9) |
| 4636 | latencies = dev_priv->wm.skl_latency; |
| 4637 | else |
| 4638 | latencies = to_i915(dev)->wm.cur_latency; |
| 4639 | |
| 4640 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4641 | |
| 4642 | return 0; |
| 4643 | } |
| 4644 | |
| 4645 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4646 | { |
| 4647 | struct drm_device *dev = inode->i_private; |
| 4648 | |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4649 | if (INTEL_INFO(dev)->gen < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4650 | return -ENODEV; |
| 4651 | |
| 4652 | return single_open(file, pri_wm_latency_show, dev); |
| 4653 | } |
| 4654 | |
| 4655 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4656 | { |
| 4657 | struct drm_device *dev = inode->i_private; |
| 4658 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4659 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4660 | return -ENODEV; |
| 4661 | |
| 4662 | return single_open(file, spr_wm_latency_show, dev); |
| 4663 | } |
| 4664 | |
| 4665 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4666 | { |
| 4667 | struct drm_device *dev = inode->i_private; |
| 4668 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4669 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4670 | return -ENODEV; |
| 4671 | |
| 4672 | return single_open(file, cur_wm_latency_show, dev); |
| 4673 | } |
| 4674 | |
| 4675 | 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] | 4676 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4677 | { |
| 4678 | struct seq_file *m = file->private_data; |
| 4679 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4680 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4681 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4682 | int level; |
| 4683 | int ret; |
| 4684 | char tmp[32]; |
| 4685 | |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4686 | if (IS_CHERRYVIEW(dev)) |
| 4687 | num_levels = 3; |
| 4688 | else if (IS_VALLEYVIEW(dev)) |
| 4689 | num_levels = 1; |
| 4690 | else |
| 4691 | num_levels = ilk_wm_max_level(dev) + 1; |
| 4692 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4693 | if (len >= sizeof(tmp)) |
| 4694 | return -EINVAL; |
| 4695 | |
| 4696 | if (copy_from_user(tmp, ubuf, len)) |
| 4697 | return -EFAULT; |
| 4698 | |
| 4699 | tmp[len] = '\0'; |
| 4700 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4701 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4702 | &new[0], &new[1], &new[2], &new[3], |
| 4703 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4704 | if (ret != num_levels) |
| 4705 | return -EINVAL; |
| 4706 | |
| 4707 | drm_modeset_lock_all(dev); |
| 4708 | |
| 4709 | for (level = 0; level < num_levels; level++) |
| 4710 | wm[level] = new[level]; |
| 4711 | |
| 4712 | drm_modeset_unlock_all(dev); |
| 4713 | |
| 4714 | return len; |
| 4715 | } |
| 4716 | |
| 4717 | |
| 4718 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4719 | size_t len, loff_t *offp) |
| 4720 | { |
| 4721 | struct seq_file *m = file->private_data; |
| 4722 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4723 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4724 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4725 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4726 | if (INTEL_INFO(dev)->gen >= 9) |
| 4727 | latencies = dev_priv->wm.skl_latency; |
| 4728 | else |
| 4729 | latencies = to_i915(dev)->wm.pri_latency; |
| 4730 | |
| 4731 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4732 | } |
| 4733 | |
| 4734 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4735 | size_t len, loff_t *offp) |
| 4736 | { |
| 4737 | struct seq_file *m = file->private_data; |
| 4738 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4739 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4740 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4741 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4742 | if (INTEL_INFO(dev)->gen >= 9) |
| 4743 | latencies = dev_priv->wm.skl_latency; |
| 4744 | else |
| 4745 | latencies = to_i915(dev)->wm.spr_latency; |
| 4746 | |
| 4747 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4748 | } |
| 4749 | |
| 4750 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4751 | size_t len, loff_t *offp) |
| 4752 | { |
| 4753 | struct seq_file *m = file->private_data; |
| 4754 | struct drm_device *dev = m->private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4755 | struct drm_i915_private *dev_priv = to_i915(dev); |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4756 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4757 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4758 | if (INTEL_INFO(dev)->gen >= 9) |
| 4759 | latencies = dev_priv->wm.skl_latency; |
| 4760 | else |
| 4761 | latencies = to_i915(dev)->wm.cur_latency; |
| 4762 | |
| 4763 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4764 | } |
| 4765 | |
| 4766 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4767 | .owner = THIS_MODULE, |
| 4768 | .open = pri_wm_latency_open, |
| 4769 | .read = seq_read, |
| 4770 | .llseek = seq_lseek, |
| 4771 | .release = single_release, |
| 4772 | .write = pri_wm_latency_write |
| 4773 | }; |
| 4774 | |
| 4775 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4776 | .owner = THIS_MODULE, |
| 4777 | .open = spr_wm_latency_open, |
| 4778 | .read = seq_read, |
| 4779 | .llseek = seq_lseek, |
| 4780 | .release = single_release, |
| 4781 | .write = spr_wm_latency_write |
| 4782 | }; |
| 4783 | |
| 4784 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4785 | .owner = THIS_MODULE, |
| 4786 | .open = cur_wm_latency_open, |
| 4787 | .read = seq_read, |
| 4788 | .llseek = seq_lseek, |
| 4789 | .release = single_release, |
| 4790 | .write = cur_wm_latency_write |
| 4791 | }; |
| 4792 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4793 | static int |
| 4794 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4795 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4796 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4797 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4798 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4799 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4800 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4801 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4802 | } |
| 4803 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4804 | static int |
| 4805 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4806 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4807 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4808 | struct drm_i915_private *dev_priv = to_i915(dev); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4809 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4810 | /* |
| 4811 | * There is no safeguard against this debugfs entry colliding |
| 4812 | * with the hangcheck calling same i915_handle_error() in |
| 4813 | * parallel, causing an explosion. For now we assume that the |
| 4814 | * test harness is responsible enough not to inject gpu hangs |
| 4815 | * while it is writing to 'i915_wedged' |
| 4816 | */ |
| 4817 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4818 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4819 | return -EAGAIN; |
| 4820 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4821 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4822 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4823 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4824 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4825 | |
| 4826 | intel_runtime_pm_put(dev_priv); |
| 4827 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4828 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4829 | } |
| 4830 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4831 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4832 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4833 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4834 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4835 | static int |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4836 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4837 | { |
| 4838 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4839 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4840 | |
| 4841 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4842 | return 0; |
| 4843 | } |
| 4844 | |
| 4845 | static int |
| 4846 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4847 | { |
| 4848 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4849 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4850 | int ret; |
| 4851 | |
| 4852 | /* Lock against concurrent debugfs callers */ |
| 4853 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4854 | if (ret) |
| 4855 | return ret; |
| 4856 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4857 | mutex_unlock(&dev->struct_mutex); |
| 4858 | |
| 4859 | return 0; |
| 4860 | } |
| 4861 | |
| 4862 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4863 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4864 | "0x%08llx\n"); |
| 4865 | |
| 4866 | static int |
| 4867 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4868 | { |
| 4869 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4870 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4871 | |
| 4872 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4873 | |
| 4874 | return 0; |
| 4875 | } |
| 4876 | |
| 4877 | static int |
| 4878 | i915_ring_test_irq_set(void *data, u64 val) |
| 4879 | { |
| 4880 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4881 | struct drm_i915_private *dev_priv = to_i915(dev); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4882 | |
Chris Wilson | 3a122c2 | 2016-06-17 14:35:05 +0100 | [diff] [blame] | 4883 | val &= INTEL_INFO(dev_priv)->ring_mask; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4884 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4885 | dev_priv->gpu_error.test_irq_rings = val; |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4886 | |
| 4887 | return 0; |
| 4888 | } |
| 4889 | |
| 4890 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4891 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4892 | "0x%08llx\n"); |
| 4893 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4894 | #define DROP_UNBOUND 0x1 |
| 4895 | #define DROP_BOUND 0x2 |
| 4896 | #define DROP_RETIRE 0x4 |
| 4897 | #define DROP_ACTIVE 0x8 |
| 4898 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4899 | DROP_BOUND | \ |
| 4900 | DROP_RETIRE | \ |
| 4901 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4902 | static int |
| 4903 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4904 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4905 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4906 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4907 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4908 | } |
| 4909 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4910 | static int |
| 4911 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4912 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4913 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4914 | struct drm_i915_private *dev_priv = to_i915(dev); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4915 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4916 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4917 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4918 | |
| 4919 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4920 | * on ioctls on -EAGAIN. */ |
| 4921 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4922 | if (ret) |
| 4923 | return ret; |
| 4924 | |
| 4925 | if (val & DROP_ACTIVE) { |
Chris Wilson | 6e5a5be | 2016-06-24 14:55:57 +0100 | [diff] [blame] | 4926 | ret = i915_gem_wait_for_idle(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4927 | if (ret) |
| 4928 | goto unlock; |
| 4929 | } |
| 4930 | |
| 4931 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 4932 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4933 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4934 | if (val & DROP_BOUND) |
| 4935 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4936 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4937 | if (val & DROP_UNBOUND) |
| 4938 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4939 | |
| 4940 | unlock: |
| 4941 | mutex_unlock(&dev->struct_mutex); |
| 4942 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4943 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4944 | } |
| 4945 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4946 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4947 | i915_drop_caches_get, i915_drop_caches_set, |
| 4948 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4949 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4950 | static int |
| 4951 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4952 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4953 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4954 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4955 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4956 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4957 | return -ENODEV; |
| 4958 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4959 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4960 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4961 | } |
| 4962 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4963 | static int |
| 4964 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4965 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4966 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 4967 | struct drm_i915_private *dev_priv = to_i915(dev); |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4968 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4969 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4970 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4971 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4972 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4973 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4974 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4975 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4976 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4977 | if (ret) |
| 4978 | return ret; |
| 4979 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4980 | /* |
| 4981 | * Turbo will still be enabled, but won't go above the set value. |
| 4982 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4983 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4984 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4985 | hw_max = dev_priv->rps.max_freq; |
| 4986 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4987 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4988 | 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] | 4989 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4990 | return -EINVAL; |
| 4991 | } |
| 4992 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4993 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4994 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 4995 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4996 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4997 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4998 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4999 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5000 | } |
| 5001 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5002 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 5003 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 5004 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5005 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5006 | static int |
| 5007 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5008 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5009 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5010 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5011 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 5012 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5013 | return -ENODEV; |
| 5014 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 5015 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5016 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5017 | } |
| 5018 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5019 | static int |
| 5020 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5021 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5022 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5023 | struct drm_i915_private *dev_priv = to_i915(dev); |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5024 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5025 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5026 | |
Chris Wilson | 62e1baa | 2016-07-13 09:10:36 +0100 | [diff] [blame] | 5027 | if (INTEL_GEN(dev_priv) < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5028 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5029 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5030 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5031 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5032 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5033 | if (ret) |
| 5034 | return ret; |
| 5035 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5036 | /* |
| 5037 | * Turbo will still be enabled, but won't go below the set value. |
| 5038 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5039 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5040 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5041 | hw_max = dev_priv->rps.max_freq; |
| 5042 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5043 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5044 | if (val < hw_min || val > hw_max || val > dev_priv->rps.max_freq_softlimit) { |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5045 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 5046 | return -EINVAL; |
| 5047 | } |
| 5048 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 5049 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5050 | |
Chris Wilson | dc97997 | 2016-05-10 14:10:04 +0100 | [diff] [blame] | 5051 | intel_set_rps(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 5052 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5053 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5054 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5055 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5056 | } |
| 5057 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5058 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 5059 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 5060 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5061 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5062 | static int |
| 5063 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5064 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5065 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5066 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5067 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5068 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5069 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5070 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 5071 | return -ENODEV; |
| 5072 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 5073 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 5074 | if (ret) |
| 5075 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5076 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 5077 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5078 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5079 | |
| 5080 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5081 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5082 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5083 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5084 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5085 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5086 | } |
| 5087 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5088 | static int |
| 5089 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5090 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5091 | struct drm_device *dev = data; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5092 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5093 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5094 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5095 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 5096 | return -ENODEV; |
| 5097 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5098 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5099 | return -EINVAL; |
| 5100 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5101 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5102 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5103 | |
| 5104 | /* Update the cache sharing policy here as well */ |
| 5105 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 5106 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 5107 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 5108 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 5109 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5110 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5111 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5112 | } |
| 5113 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5114 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 5115 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 5116 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5117 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5118 | struct sseu_dev_status { |
| 5119 | unsigned int slice_total; |
| 5120 | unsigned int subslice_total; |
| 5121 | unsigned int subslice_per_slice; |
| 5122 | unsigned int eu_total; |
| 5123 | unsigned int eu_per_subslice; |
| 5124 | }; |
| 5125 | |
| 5126 | static void cherryview_sseu_device_status(struct drm_device *dev, |
| 5127 | struct sseu_dev_status *stat) |
| 5128 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5129 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 5130 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5131 | int ss; |
| 5132 | u32 sig1[ss_max], sig2[ss_max]; |
| 5133 | |
| 5134 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 5135 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 5136 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 5137 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 5138 | |
| 5139 | for (ss = 0; ss < ss_max; ss++) { |
| 5140 | unsigned int eu_cnt; |
| 5141 | |
| 5142 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 5143 | /* skip disabled subslice */ |
| 5144 | continue; |
| 5145 | |
| 5146 | stat->slice_total = 1; |
| 5147 | stat->subslice_per_slice++; |
| 5148 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 5149 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 5150 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 5151 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
| 5152 | stat->eu_total += eu_cnt; |
| 5153 | stat->eu_per_subslice = max(stat->eu_per_subslice, eu_cnt); |
| 5154 | } |
| 5155 | stat->subslice_total = stat->subslice_per_slice; |
| 5156 | } |
| 5157 | |
| 5158 | static void gen9_sseu_device_status(struct drm_device *dev, |
| 5159 | struct sseu_dev_status *stat) |
| 5160 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5161 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5162 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5163 | int s, ss; |
| 5164 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 5165 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5166 | /* BXT has a single slice and at most 3 subslices. */ |
| 5167 | if (IS_BROXTON(dev)) { |
| 5168 | s_max = 1; |
| 5169 | ss_max = 3; |
| 5170 | } |
| 5171 | |
| 5172 | for (s = 0; s < s_max; s++) { |
| 5173 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 5174 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 5175 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 5176 | } |
| 5177 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5178 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 5179 | GEN9_PGCTL_SSA_EU19_ACK | |
| 5180 | GEN9_PGCTL_SSA_EU210_ACK | |
| 5181 | GEN9_PGCTL_SSA_EU311_ACK; |
| 5182 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 5183 | GEN9_PGCTL_SSB_EU19_ACK | |
| 5184 | GEN9_PGCTL_SSB_EU210_ACK | |
| 5185 | GEN9_PGCTL_SSB_EU311_ACK; |
| 5186 | |
| 5187 | for (s = 0; s < s_max; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5188 | unsigned int ss_cnt = 0; |
| 5189 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5190 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 5191 | /* skip disabled slice */ |
| 5192 | continue; |
| 5193 | |
| 5194 | stat->slice_total++; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5195 | |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 5196 | if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5197 | ss_cnt = INTEL_INFO(dev)->subslice_per_slice; |
| 5198 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5199 | for (ss = 0; ss < ss_max; ss++) { |
| 5200 | unsigned int eu_cnt; |
| 5201 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5202 | if (IS_BROXTON(dev) && |
| 5203 | !(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 5204 | /* skip disabled subslice */ |
| 5205 | continue; |
| 5206 | |
| 5207 | if (IS_BROXTON(dev)) |
| 5208 | ss_cnt++; |
| 5209 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5210 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 5211 | eu_mask[ss%2]); |
| 5212 | stat->eu_total += eu_cnt; |
| 5213 | stat->eu_per_subslice = max(stat->eu_per_subslice, |
| 5214 | eu_cnt); |
| 5215 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5216 | |
| 5217 | stat->subslice_total += ss_cnt; |
| 5218 | stat->subslice_per_slice = max(stat->subslice_per_slice, |
| 5219 | ss_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5220 | } |
| 5221 | } |
| 5222 | |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5223 | static void broadwell_sseu_device_status(struct drm_device *dev, |
| 5224 | struct sseu_dev_status *stat) |
| 5225 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5226 | struct drm_i915_private *dev_priv = to_i915(dev); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5227 | int s; |
| 5228 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
| 5229 | |
| 5230 | stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK); |
| 5231 | |
| 5232 | if (stat->slice_total) { |
| 5233 | stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice; |
| 5234 | stat->subslice_total = stat->slice_total * |
| 5235 | stat->subslice_per_slice; |
| 5236 | stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice; |
| 5237 | stat->eu_total = stat->eu_per_subslice * stat->subslice_total; |
| 5238 | |
| 5239 | /* subtract fused off EU(s) from enabled slice(s) */ |
| 5240 | for (s = 0; s < stat->slice_total; s++) { |
| 5241 | u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s]; |
| 5242 | |
| 5243 | stat->eu_total -= hweight8(subslice_7eu); |
| 5244 | } |
| 5245 | } |
| 5246 | } |
| 5247 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5248 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 5249 | { |
| 5250 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5251 | struct drm_i915_private *dev_priv = to_i915(node->minor->dev); |
| 5252 | struct drm_device *dev = &dev_priv->drm; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5253 | struct sseu_dev_status stat; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5254 | |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5255 | if (INTEL_INFO(dev)->gen < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5256 | return -ENODEV; |
| 5257 | |
| 5258 | seq_puts(m, "SSEU Device Info\n"); |
| 5259 | seq_printf(m, " Available Slice Total: %u\n", |
| 5260 | INTEL_INFO(dev)->slice_total); |
| 5261 | seq_printf(m, " Available Subslice Total: %u\n", |
| 5262 | INTEL_INFO(dev)->subslice_total); |
| 5263 | seq_printf(m, " Available Subslice Per Slice: %u\n", |
| 5264 | INTEL_INFO(dev)->subslice_per_slice); |
| 5265 | seq_printf(m, " Available EU Total: %u\n", |
| 5266 | INTEL_INFO(dev)->eu_total); |
| 5267 | seq_printf(m, " Available EU Per Subslice: %u\n", |
| 5268 | INTEL_INFO(dev)->eu_per_subslice); |
arun.siluvery@linux.intel.com | 33e141e | 2016-06-03 06:34:33 +0100 | [diff] [blame] | 5269 | seq_printf(m, " Has Pooled EU: %s\n", yesno(HAS_POOLED_EU(dev))); |
| 5270 | if (HAS_POOLED_EU(dev)) |
| 5271 | seq_printf(m, " Min EU in pool: %u\n", |
| 5272 | INTEL_INFO(dev)->min_eu_in_pool); |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5273 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 5274 | yesno(INTEL_INFO(dev)->has_slice_pg)); |
| 5275 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 5276 | yesno(INTEL_INFO(dev)->has_subslice_pg)); |
| 5277 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 5278 | yesno(INTEL_INFO(dev)->has_eu_pg)); |
| 5279 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5280 | seq_puts(m, "SSEU Device Status\n"); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5281 | memset(&stat, 0, sizeof(stat)); |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5282 | |
| 5283 | intel_runtime_pm_get(dev_priv); |
| 5284 | |
Jeff McGee | 5575f03 | 2015-02-27 10:22:32 -0800 | [diff] [blame] | 5285 | if (IS_CHERRYVIEW(dev)) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5286 | cherryview_sseu_device_status(dev, &stat); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5287 | } else if (IS_BROADWELL(dev)) { |
| 5288 | broadwell_sseu_device_status(dev, &stat); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5289 | } else if (INTEL_INFO(dev)->gen >= 9) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5290 | gen9_sseu_device_status(dev, &stat); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5291 | } |
David Weinehall | 238010e | 2016-08-01 17:33:27 +0300 | [diff] [blame] | 5292 | |
| 5293 | intel_runtime_pm_put(dev_priv); |
| 5294 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5295 | seq_printf(m, " Enabled Slice Total: %u\n", |
| 5296 | stat.slice_total); |
| 5297 | seq_printf(m, " Enabled Subslice Total: %u\n", |
| 5298 | stat.subslice_total); |
| 5299 | seq_printf(m, " Enabled Subslice Per Slice: %u\n", |
| 5300 | stat.subslice_per_slice); |
| 5301 | seq_printf(m, " Enabled EU Total: %u\n", |
| 5302 | stat.eu_total); |
| 5303 | seq_printf(m, " Enabled EU Per Subslice: %u\n", |
| 5304 | stat.eu_per_subslice); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5305 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5306 | return 0; |
| 5307 | } |
| 5308 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5309 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 5310 | { |
| 5311 | struct drm_device *dev = inode->i_private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5312 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5313 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 5314 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5315 | return 0; |
| 5316 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5317 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5318 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5319 | |
| 5320 | return 0; |
| 5321 | } |
| 5322 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 5323 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5324 | { |
| 5325 | struct drm_device *dev = inode->i_private; |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5326 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5327 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 5328 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5329 | return 0; |
| 5330 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5331 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5332 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5333 | |
| 5334 | return 0; |
| 5335 | } |
| 5336 | |
| 5337 | static const struct file_operations i915_forcewake_fops = { |
| 5338 | .owner = THIS_MODULE, |
| 5339 | .open = i915_forcewake_open, |
| 5340 | .release = i915_forcewake_release, |
| 5341 | }; |
| 5342 | |
| 5343 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 5344 | { |
| 5345 | struct drm_device *dev = minor->dev; |
| 5346 | struct dentry *ent; |
| 5347 | |
| 5348 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5349 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5350 | root, dev, |
| 5351 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5352 | if (!ent) |
| 5353 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5354 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5355 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5356 | } |
| 5357 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5358 | static int i915_debugfs_create(struct dentry *root, |
| 5359 | struct drm_minor *minor, |
| 5360 | const char *name, |
| 5361 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5362 | { |
| 5363 | struct drm_device *dev = minor->dev; |
| 5364 | struct dentry *ent; |
| 5365 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5366 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5367 | S_IRUGO | S_IWUSR, |
| 5368 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5369 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5370 | if (!ent) |
| 5371 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5372 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5373 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5374 | } |
| 5375 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5376 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 5377 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 5378 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 5379 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 5380 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5381 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5382 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 5383 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 5384 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5385 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 5386 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 5387 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5388 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 5389 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 5390 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 5391 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 5392 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 5393 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 5394 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 5395 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 5396 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 5397 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 5398 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 5399 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 5400 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 5401 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 5402 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 5403 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 5404 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 5405 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 5406 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 5407 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 5408 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 5409 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 5410 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 5411 | {"i915_execlists", i915_execlists, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 5412 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 5413 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 5414 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 5415 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 5416 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 5417 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 5418 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 5419 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 5420 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 5421 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 5422 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 5423 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 5424 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 5425 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 5426 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 5427 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5428 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 5429 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 5430 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5431 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5432 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5433 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5434 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5435 | const char *name; |
| 5436 | const struct file_operations *fops; |
| 5437 | } i915_debugfs_files[] = { |
| 5438 | {"i915_wedged", &i915_wedged_fops}, |
| 5439 | {"i915_max_freq", &i915_max_freq_fops}, |
| 5440 | {"i915_min_freq", &i915_min_freq_fops}, |
| 5441 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 5442 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 5443 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5444 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 5445 | {"i915_error_state", &i915_error_state_fops}, |
| 5446 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 5447 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 5448 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 5449 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 5450 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 5451 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 5452 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 5453 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
| 5454 | {"i915_dp_test_active", &i915_displayport_test_active_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5455 | }; |
| 5456 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5457 | void intel_display_crc_init(struct drm_device *dev) |
| 5458 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 5459 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5460 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5461 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 5462 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5463 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5464 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 5465 | pipe_crc->opened = false; |
| 5466 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5467 | init_waitqueue_head(&pipe_crc->wq); |
| 5468 | } |
| 5469 | } |
| 5470 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 5471 | int i915_debugfs_register(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5472 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5473 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5474 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 5475 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5476 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 5477 | if (ret) |
| 5478 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5479 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5480 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 5481 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 5482 | if (ret) |
| 5483 | return ret; |
| 5484 | } |
| 5485 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5486 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5487 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 5488 | i915_debugfs_files[i].name, |
| 5489 | i915_debugfs_files[i].fops); |
| 5490 | if (ret) |
| 5491 | return ret; |
| 5492 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 5493 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5494 | return drm_debugfs_create_files(i915_debugfs_list, |
| 5495 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5496 | minor->debugfs_root, minor); |
| 5497 | } |
| 5498 | |
Chris Wilson | 1dac891 | 2016-06-24 14:00:17 +0100 | [diff] [blame] | 5499 | void i915_debugfs_unregister(struct drm_i915_private *dev_priv) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5500 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 5501 | struct drm_minor *minor = dev_priv->drm.primary; |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5502 | int i; |
| 5503 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5504 | drm_debugfs_remove_files(i915_debugfs_list, |
| 5505 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5506 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5507 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 5508 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5509 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 5510 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5511 | struct drm_info_list *info_list = |
| 5512 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 5513 | |
| 5514 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5515 | } |
| 5516 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5517 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5518 | struct drm_info_list *info_list = |
| 5519 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 5520 | |
| 5521 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5522 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5523 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5524 | |
| 5525 | struct dpcd_block { |
| 5526 | /* DPCD dump start address. */ |
| 5527 | unsigned int offset; |
| 5528 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 5529 | unsigned int end; |
| 5530 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 5531 | size_t size; |
| 5532 | /* Only valid for eDP. */ |
| 5533 | bool edp; |
| 5534 | }; |
| 5535 | |
| 5536 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 5537 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 5538 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 5539 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 5540 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 5541 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 5542 | { .offset = DP_SET_POWER }, |
| 5543 | { .offset = DP_EDP_DPCD_REV }, |
| 5544 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 5545 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 5546 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 5547 | }; |
| 5548 | |
| 5549 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 5550 | { |
| 5551 | struct drm_connector *connector = m->private; |
| 5552 | struct intel_dp *intel_dp = |
| 5553 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5554 | uint8_t buf[16]; |
| 5555 | ssize_t err; |
| 5556 | int i; |
| 5557 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 5558 | if (connector->status != connector_status_connected) |
| 5559 | return -ENODEV; |
| 5560 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5561 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 5562 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 5563 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 5564 | |
| 5565 | if (b->edp && |
| 5566 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 5567 | continue; |
| 5568 | |
| 5569 | /* low tech for now */ |
| 5570 | if (WARN_ON(size > sizeof(buf))) |
| 5571 | continue; |
| 5572 | |
| 5573 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 5574 | if (err <= 0) { |
| 5575 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 5576 | size, b->offset, err); |
| 5577 | continue; |
| 5578 | } |
| 5579 | |
| 5580 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 5581 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5582 | |
| 5583 | return 0; |
| 5584 | } |
| 5585 | |
| 5586 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5587 | { |
| 5588 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5589 | } |
| 5590 | |
| 5591 | static const struct file_operations i915_dpcd_fops = { |
| 5592 | .owner = THIS_MODULE, |
| 5593 | .open = i915_dpcd_open, |
| 5594 | .read = seq_read, |
| 5595 | .llseek = seq_lseek, |
| 5596 | .release = single_release, |
| 5597 | }; |
| 5598 | |
| 5599 | /** |
| 5600 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5601 | * @connector: pointer to a registered drm_connector |
| 5602 | * |
| 5603 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5604 | * drm_debugfs_connector_remove(). |
| 5605 | * |
| 5606 | * Returns 0 on success, negative error codes on error. |
| 5607 | */ |
| 5608 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5609 | { |
| 5610 | struct dentry *root = connector->debugfs_entry; |
| 5611 | |
| 5612 | /* The connector must have been registered beforehands. */ |
| 5613 | if (!root) |
| 5614 | return -ENODEV; |
| 5615 | |
| 5616 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5617 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5618 | debugfs_create_file("i915_dpcd", S_IRUGO, root, connector, |
| 5619 | &i915_dpcd_fops); |
| 5620 | |
| 5621 | return 0; |
| 5622 | } |