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 | |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 92 | static const 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 | |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 97 | static const char get_pin_flag(struct drm_i915_gem_object *obj) |
| 98 | { |
| 99 | return obj->pin_display ? 'p' : ' '; |
| 100 | } |
| 101 | |
| 102 | static const 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 | |
Tvrtko Ursulin | be12a86 | 2016-04-15 11:34:52 +0100 | [diff] [blame] | 112 | static inline const 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 | |
| 117 | static inline const char get_pin_mapped_flag(struct drm_i915_gem_object *obj) |
| 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 | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 128 | if (vma->is_ggtt && 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 ", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 158 | i915_gem_request_get_seqno(obj->last_read_req[id])); |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 159 | seq_printf(m, "] %x %x%s%s%s", |
John Harrison | 97b2a6a | 2014-11-24 18:49:26 +0000 | [diff] [blame] | 160 | i915_gem_request_get_seqno(obj->last_write_req), |
| 161 | i915_gem_request_get_seqno(obj->last_fenced_req), |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 162 | i915_cache_level_str(to_i915(obj->base.dev), obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 163 | obj->dirty ? " dirty" : "", |
| 164 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 165 | if (obj->base.name) |
| 166 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 167 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 168 | if (vma->pin_count > 0) |
| 169 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 170 | } |
| 171 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 172 | if (obj->pin_display) |
| 173 | seq_printf(m, " (display)"); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 174 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 175 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 176 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 177 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 178 | vma->is_ggtt ? "g" : "pp", |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 179 | vma->node.start, vma->node.size); |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 180 | if (vma->is_ggtt) |
| 181 | seq_printf(m, ", type: %u", vma->ggtt_view.type); |
| 182 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 183 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 184 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 185 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 186 | if (obj->pin_display || obj->fault_mappable) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 187 | char s[3], *t = s; |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 188 | if (obj->pin_display) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 189 | *t++ = 'p'; |
| 190 | if (obj->fault_mappable) |
| 191 | *t++ = 'f'; |
| 192 | *t = '\0'; |
| 193 | seq_printf(m, " (%s mappable)", s); |
| 194 | } |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 195 | if (obj->last_write_req != NULL) |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 196 | seq_printf(m, " (%s)", |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 197 | i915_gem_request_get_engine(obj->last_write_req)->name); |
Daniel Vetter | d5a81ef | 2014-06-18 14:46:49 +0200 | [diff] [blame] | 198 | if (obj->frontbuffer_bits) |
| 199 | seq_printf(m, " (frontbuffer: 0x%03x)", obj->frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 200 | } |
| 201 | |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 202 | static void describe_ctx(struct seq_file *m, struct intel_context *ctx) |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 203 | { |
Oscar Mateo | ea0c76f | 2014-07-03 16:27:59 +0100 | [diff] [blame] | 204 | seq_putc(m, ctx->legacy_hw_ctx.initialized ? 'I' : 'i'); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 205 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 206 | seq_putc(m, ' '); |
| 207 | } |
| 208 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 209 | 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] | 210 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 211 | struct drm_info_node *node = m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 212 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 213 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 214 | struct drm_device *dev = node->minor->dev; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 215 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 216 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 217 | struct i915_vma *vma; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 218 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 219 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 220 | |
| 221 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 222 | if (ret) |
| 223 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 224 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 225 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 226 | switch (list) { |
| 227 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 228 | seq_puts(m, "Active:\n"); |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 229 | head = &ggtt->base.active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 230 | break; |
| 231 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 232 | seq_puts(m, "Inactive:\n"); |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 233 | head = &ggtt->base.inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 234 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 235 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 236 | mutex_unlock(&dev->struct_mutex); |
| 237 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 238 | } |
| 239 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 240 | total_obj_size = total_gtt_size = count = 0; |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 241 | list_for_each_entry(vma, head, vm_link) { |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 242 | seq_printf(m, " "); |
| 243 | describe_obj(m, vma->obj); |
| 244 | seq_printf(m, "\n"); |
| 245 | total_obj_size += vma->obj->base.size; |
| 246 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 247 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 248 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 249 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 250 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 251 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 252 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 253 | return 0; |
| 254 | } |
| 255 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 256 | static int obj_rank_by_stolen(void *priv, |
| 257 | struct list_head *A, struct list_head *B) |
| 258 | { |
| 259 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 260 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 261 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 262 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 263 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 264 | if (a->stolen->start < b->stolen->start) |
| 265 | return -1; |
| 266 | if (a->stolen->start > b->stolen->start) |
| 267 | return 1; |
| 268 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 272 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 273 | struct drm_info_node *node = m->private; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 274 | struct drm_device *dev = node->minor->dev; |
| 275 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 276 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 277 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 278 | LIST_HEAD(stolen); |
| 279 | int count, ret; |
| 280 | |
| 281 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 282 | if (ret) |
| 283 | return ret; |
| 284 | |
| 285 | total_obj_size = total_gtt_size = count = 0; |
| 286 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 287 | if (obj->stolen == NULL) |
| 288 | continue; |
| 289 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 290 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 291 | |
| 292 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 293 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 294 | count++; |
| 295 | } |
| 296 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 297 | if (obj->stolen == NULL) |
| 298 | continue; |
| 299 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 300 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 301 | |
| 302 | total_obj_size += obj->base.size; |
| 303 | count++; |
| 304 | } |
| 305 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 306 | seq_puts(m, "Stolen:\n"); |
| 307 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 308 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 309 | seq_puts(m, " "); |
| 310 | describe_obj(m, obj); |
| 311 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 312 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 313 | } |
| 314 | mutex_unlock(&dev->struct_mutex); |
| 315 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 316 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 317 | count, total_obj_size, total_gtt_size); |
| 318 | return 0; |
| 319 | } |
| 320 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 321 | #define count_objects(list, member) do { \ |
| 322 | list_for_each_entry(obj, list, member) { \ |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 323 | size += i915_gem_obj_total_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 324 | ++count; \ |
| 325 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 326 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 327 | ++mappable_count; \ |
| 328 | } \ |
| 329 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 330 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 331 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 332 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 333 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 334 | unsigned long count; |
| 335 | u64 total, unbound; |
| 336 | u64 global, shared; |
| 337 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | static int per_file_stats(int id, void *ptr, void *data) |
| 341 | { |
| 342 | struct drm_i915_gem_object *obj = ptr; |
| 343 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 344 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 345 | |
| 346 | stats->count++; |
| 347 | stats->total += obj->base.size; |
| 348 | |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 349 | if (obj->base.name || obj->base.dma_buf) |
| 350 | stats->shared += obj->base.size; |
| 351 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 352 | if (USES_FULL_PPGTT(obj->base.dev)) { |
Chris Wilson | 1c7f4bc | 2016-02-26 11:03:19 +0000 | [diff] [blame] | 353 | list_for_each_entry(vma, &obj->vma_list, obj_link) { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 354 | struct i915_hw_ppgtt *ppgtt; |
| 355 | |
| 356 | if (!drm_mm_node_allocated(&vma->node)) |
| 357 | continue; |
| 358 | |
Chris Wilson | 596c592 | 2016-02-26 11:03:20 +0000 | [diff] [blame] | 359 | if (vma->is_ggtt) { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 360 | stats->global += obj->base.size; |
| 361 | continue; |
| 362 | } |
| 363 | |
| 364 | ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base); |
Daniel Vetter | 4d88470 | 2014-08-06 15:04:47 +0200 | [diff] [blame] | 365 | if (ppgtt->file_priv != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 366 | continue; |
| 367 | |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 368 | if (obj->active) /* XXX per-vma statistic */ |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 369 | stats->active += obj->base.size; |
| 370 | else |
| 371 | stats->inactive += obj->base.size; |
| 372 | |
| 373 | return 0; |
| 374 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 375 | } else { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 376 | if (i915_gem_obj_ggtt_bound(obj)) { |
| 377 | stats->global += obj->base.size; |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 378 | if (obj->active) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 379 | stats->active += obj->base.size; |
| 380 | else |
| 381 | stats->inactive += obj->base.size; |
| 382 | return 0; |
| 383 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 384 | } |
| 385 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 386 | if (!list_empty(&obj->global_list)) |
| 387 | stats->unbound += obj->base.size; |
| 388 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 389 | return 0; |
| 390 | } |
| 391 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 392 | #define print_file_stats(m, name, stats) do { \ |
| 393 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 394 | 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] | 395 | name, \ |
| 396 | stats.count, \ |
| 397 | stats.total, \ |
| 398 | stats.active, \ |
| 399 | stats.inactive, \ |
| 400 | stats.global, \ |
| 401 | stats.shared, \ |
| 402 | stats.unbound); \ |
| 403 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 404 | |
| 405 | static void print_batch_pool_stats(struct seq_file *m, |
| 406 | struct drm_i915_private *dev_priv) |
| 407 | { |
| 408 | struct drm_i915_gem_object *obj; |
| 409 | struct file_stats stats; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 410 | struct intel_engine_cs *engine; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 411 | int j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 412 | |
| 413 | memset(&stats, 0, sizeof(stats)); |
| 414 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 415 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 416 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 417 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 418 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 419 | batch_pool_link) |
| 420 | per_file_stats(0, obj, &stats); |
| 421 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 422 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 423 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 424 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 425 | } |
| 426 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 427 | #define count_vmas(list, member) do { \ |
| 428 | list_for_each_entry(vma, list, member) { \ |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 429 | size += i915_gem_obj_total_ggtt_size(vma->obj); \ |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 430 | ++count; \ |
| 431 | if (vma->obj->map_and_fenceable) { \ |
| 432 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 433 | ++mappable_count; \ |
| 434 | } \ |
| 435 | } \ |
| 436 | } while (0) |
| 437 | |
| 438 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 439 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 440 | struct drm_info_node *node = m->private; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 441 | struct drm_device *dev = node->minor->dev; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 442 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 443 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 444 | u32 count, mappable_count, purgeable_count; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 445 | u64 size, mappable_size, purgeable_size; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 446 | unsigned long pin_mapped_count = 0, pin_mapped_purgeable_count = 0; |
| 447 | u64 pin_mapped_size = 0, pin_mapped_purgeable_size = 0; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 448 | struct drm_i915_gem_object *obj; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 449 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 450 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 451 | int ret; |
| 452 | |
| 453 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 454 | if (ret) |
| 455 | return ret; |
| 456 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 457 | seq_printf(m, "%u objects, %zu bytes\n", |
| 458 | dev_priv->mm.object_count, |
| 459 | dev_priv->mm.object_memory); |
| 460 | |
| 461 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 462 | count_objects(&dev_priv->mm.bound_list, global_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 463 | seq_printf(m, "%u [%u] objects, %llu [%llu] bytes in gtt\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 464 | count, mappable_count, size, mappable_size); |
| 465 | |
| 466 | size = count = mappable_size = mappable_count = 0; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 467 | count_vmas(&ggtt->base.active_list, vm_link); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 468 | seq_printf(m, " %u [%u] active objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 469 | count, mappable_count, size, mappable_size); |
| 470 | |
| 471 | size = count = mappable_size = mappable_count = 0; |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 472 | count_vmas(&ggtt->base.inactive_list, vm_link); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 473 | seq_printf(m, " %u [%u] inactive objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 474 | count, mappable_count, size, mappable_size); |
| 475 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 476 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 477 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 478 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 479 | if (obj->madv == I915_MADV_DONTNEED) |
| 480 | purgeable_size += obj->base.size, ++purgeable_count; |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 481 | if (obj->mapping) { |
| 482 | pin_mapped_count++; |
| 483 | pin_mapped_size += obj->base.size; |
| 484 | if (obj->pages_pin_count == 0) { |
| 485 | pin_mapped_purgeable_count++; |
| 486 | pin_mapped_purgeable_size += obj->base.size; |
| 487 | } |
| 488 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 489 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 490 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 491 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 492 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 493 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 494 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 495 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 496 | ++count; |
| 497 | } |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 498 | if (obj->pin_display) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 499 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 500 | ++mappable_count; |
| 501 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 502 | if (obj->madv == I915_MADV_DONTNEED) { |
| 503 | purgeable_size += obj->base.size; |
| 504 | ++purgeable_count; |
| 505 | } |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 506 | if (obj->mapping) { |
| 507 | pin_mapped_count++; |
| 508 | pin_mapped_size += obj->base.size; |
| 509 | if (obj->pages_pin_count == 0) { |
| 510 | pin_mapped_purgeable_count++; |
| 511 | pin_mapped_purgeable_size += obj->base.size; |
| 512 | } |
| 513 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 514 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 515 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 516 | purgeable_count, purgeable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 517 | seq_printf(m, "%u pinned mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 518 | mappable_count, mappable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 519 | seq_printf(m, "%u fault mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 520 | count, size); |
Tvrtko Ursulin | be19b10 | 2016-04-15 11:34:53 +0100 | [diff] [blame] | 521 | seq_printf(m, |
| 522 | "%lu [%lu] pin mapped objects, %llu [%llu] bytes [purgeable]\n", |
| 523 | pin_mapped_count, pin_mapped_purgeable_count, |
| 524 | pin_mapped_size, pin_mapped_purgeable_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 525 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 526 | seq_printf(m, "%llu [%llu] gtt total\n", |
Joonas Lahtinen | 72e96d6 | 2016-03-30 16:57:10 +0300 | [diff] [blame] | 527 | ggtt->base.total, ggtt->mappable_end - ggtt->base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 528 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 529 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 530 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 531 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 532 | struct file_stats stats; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 533 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 534 | |
| 535 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 536 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 537 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 538 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 539 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 540 | /* |
| 541 | * Although we have a valid reference on file->pid, that does |
| 542 | * not guarantee that the task_struct who called get_pid() is |
| 543 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 544 | * Therefore, we need to protect this ->comm access using RCU. |
| 545 | */ |
| 546 | rcu_read_lock(); |
| 547 | task = pid_task(file->pid, PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 548 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 549 | rcu_read_unlock(); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 550 | } |
| 551 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 552 | mutex_unlock(&dev->struct_mutex); |
| 553 | |
| 554 | return 0; |
| 555 | } |
| 556 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 557 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 558 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 559 | struct drm_info_node *node = m->private; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 560 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 561 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 562 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 563 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 564 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 565 | int count, ret; |
| 566 | |
| 567 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 568 | if (ret) |
| 569 | return ret; |
| 570 | |
| 571 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 572 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 573 | if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj)) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 574 | continue; |
| 575 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 576 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 577 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 578 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 579 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 580 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 581 | count++; |
| 582 | } |
| 583 | |
| 584 | mutex_unlock(&dev->struct_mutex); |
| 585 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 586 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 587 | count, total_obj_size, total_gtt_size); |
| 588 | |
| 589 | return 0; |
| 590 | } |
| 591 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 592 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 593 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 594 | struct drm_info_node *node = m->private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 595 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 596 | struct drm_i915_private *dev_priv = dev->dev_private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 597 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 598 | int ret; |
| 599 | |
| 600 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 601 | if (ret) |
| 602 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 603 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 604 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 605 | const char pipe = pipe_name(crtc->pipe); |
| 606 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 607 | struct intel_unpin_work *work; |
| 608 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 609 | spin_lock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 610 | work = crtc->unpin_work; |
| 611 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 612 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 613 | pipe, plane); |
| 614 | } else { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 615 | u32 addr; |
| 616 | |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 617 | if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 618 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 619 | pipe, plane); |
| 620 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 621 | seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 622 | pipe, plane); |
| 623 | } |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 624 | if (work->flip_queued_req) { |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 625 | struct intel_engine_cs *engine = i915_gem_request_get_engine(work->flip_queued_req); |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 626 | |
Mika Kuoppala | 20e28fb | 2015-01-26 18:03:06 +0200 | [diff] [blame] | 627 | seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 628 | engine->name, |
John Harrison | f06cc1b | 2014-11-24 18:49:37 +0000 | [diff] [blame] | 629 | i915_gem_request_get_seqno(work->flip_queued_req), |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 630 | dev_priv->next_seqno, |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 631 | engine->get_seqno(engine), |
John Harrison | 1b5a433 | 2014-11-24 18:49:42 +0000 | [diff] [blame] | 632 | i915_gem_request_completed(work->flip_queued_req, true)); |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 633 | } else |
| 634 | seq_printf(m, "Flip not associated with any ring\n"); |
| 635 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 636 | work->flip_queued_vblank, |
| 637 | work->flip_ready_vblank, |
Daniel Vetter | 1e3feef | 2015-02-13 21:03:45 +0100 | [diff] [blame] | 638 | drm_crtc_vblank_count(&crtc->base)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 639 | if (work->enable_stall_check) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 640 | seq_puts(m, "Stall check enabled, "); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 641 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 642 | seq_puts(m, "Stall check waiting for page flip ioctl, "); |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 643 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 644 | |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 645 | if (INTEL_INFO(dev)->gen >= 4) |
| 646 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 647 | else |
| 648 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 649 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 650 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 651 | if (work->pending_flip_obj) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 652 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 653 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 654 | } |
| 655 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 656 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 657 | } |
| 658 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 659 | mutex_unlock(&dev->struct_mutex); |
| 660 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 661 | return 0; |
| 662 | } |
| 663 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 664 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 665 | { |
| 666 | struct drm_info_node *node = m->private; |
| 667 | struct drm_device *dev = node->minor->dev; |
| 668 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 669 | struct drm_i915_gem_object *obj; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 670 | struct intel_engine_cs *engine; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 671 | int total = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 672 | int ret, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 673 | |
| 674 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 675 | if (ret) |
| 676 | return ret; |
| 677 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 678 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 679 | for (j = 0; j < ARRAY_SIZE(engine->batch_pool.cache_list); j++) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 680 | int count; |
| 681 | |
| 682 | count = 0; |
| 683 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 684 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 685 | batch_pool_link) |
| 686 | count++; |
| 687 | seq_printf(m, "%s cache[%d]: %d objects\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 688 | engine->name, j, count); |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 689 | |
| 690 | list_for_each_entry(obj, |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 691 | &engine->batch_pool.cache_list[j], |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 692 | batch_pool_link) { |
| 693 | seq_puts(m, " "); |
| 694 | describe_obj(m, obj); |
| 695 | seq_putc(m, '\n'); |
| 696 | } |
| 697 | |
| 698 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 699 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 700 | } |
| 701 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 702 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 703 | |
| 704 | mutex_unlock(&dev->struct_mutex); |
| 705 | |
| 706 | return 0; |
| 707 | } |
| 708 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 709 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 710 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 711 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 712 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 713 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 714 | struct intel_engine_cs *engine; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 715 | struct drm_i915_gem_request *req; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 716 | int ret, any; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 717 | |
| 718 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 719 | if (ret) |
| 720 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 721 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 722 | any = 0; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 723 | for_each_engine(engine, dev_priv) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 724 | int count; |
| 725 | |
| 726 | count = 0; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 727 | list_for_each_entry(req, &engine->request_list, list) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 728 | count++; |
| 729 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 730 | continue; |
| 731 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 732 | seq_printf(m, "%s requests: %d\n", engine->name, count); |
| 733 | list_for_each_entry(req, &engine->request_list, list) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 734 | struct task_struct *task; |
| 735 | |
| 736 | rcu_read_lock(); |
| 737 | task = NULL; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 738 | if (req->pid) |
| 739 | task = pid_task(req->pid, PIDTYPE_PID); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 740 | seq_printf(m, " %x @ %d: %s [%d]\n", |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 741 | req->seqno, |
| 742 | (int) (jiffies - req->emitted_jiffies), |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 743 | task ? task->comm : "<unknown>", |
| 744 | task ? task->pid : -1); |
| 745 | rcu_read_unlock(); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 746 | } |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 747 | |
| 748 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 749 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 750 | mutex_unlock(&dev->struct_mutex); |
| 751 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 752 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 753 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 754 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 755 | return 0; |
| 756 | } |
| 757 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 758 | static void i915_ring_seqno_info(struct seq_file *m, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 759 | struct intel_engine_cs *engine) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 760 | { |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 761 | seq_printf(m, "Current sequence (%s): %x\n", |
| 762 | engine->name, engine->get_seqno(engine)); |
| 763 | seq_printf(m, "Current user interrupts (%s): %x\n", |
| 764 | engine->name, READ_ONCE(engine->user_interrupts)); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 765 | } |
| 766 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 767 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 768 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 769 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 770 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 771 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 772 | struct intel_engine_cs *engine; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 773 | int ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 774 | |
| 775 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 776 | if (ret) |
| 777 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 778 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 779 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 780 | for_each_engine(engine, dev_priv) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 781 | i915_ring_seqno_info(m, engine); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 782 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 783 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 784 | mutex_unlock(&dev->struct_mutex); |
| 785 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 786 | return 0; |
| 787 | } |
| 788 | |
| 789 | |
| 790 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 791 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 792 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 793 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 794 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 795 | struct intel_engine_cs *engine; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 796 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 797 | |
| 798 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 799 | if (ret) |
| 800 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 801 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 802 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 803 | if (IS_CHERRYVIEW(dev)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 804 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 805 | I915_READ(GEN8_MASTER_IRQ)); |
| 806 | |
| 807 | seq_printf(m, "Display IER:\t%08x\n", |
| 808 | I915_READ(VLV_IER)); |
| 809 | seq_printf(m, "Display IIR:\t%08x\n", |
| 810 | I915_READ(VLV_IIR)); |
| 811 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 812 | I915_READ(VLV_IIR_RW)); |
| 813 | seq_printf(m, "Display IMR:\t%08x\n", |
| 814 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 815 | for_each_pipe(dev_priv, pipe) |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 816 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 817 | pipe_name(pipe), |
| 818 | I915_READ(PIPESTAT(pipe))); |
| 819 | |
| 820 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 821 | I915_READ(PORT_HOTPLUG_EN)); |
| 822 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 823 | I915_READ(VLV_DPFLIPSTAT)); |
| 824 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 825 | I915_READ(DPINVGTT)); |
| 826 | |
| 827 | for (i = 0; i < 4; i++) { |
| 828 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 829 | i, I915_READ(GEN8_GT_IMR(i))); |
| 830 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 831 | i, I915_READ(GEN8_GT_IIR(i))); |
| 832 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 833 | i, I915_READ(GEN8_GT_IER(i))); |
| 834 | } |
| 835 | |
| 836 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 837 | I915_READ(GEN8_PCU_IMR)); |
| 838 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 839 | I915_READ(GEN8_PCU_IIR)); |
| 840 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 841 | I915_READ(GEN8_PCU_IER)); |
| 842 | } else if (INTEL_INFO(dev)->gen >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 843 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 844 | I915_READ(GEN8_MASTER_IRQ)); |
| 845 | |
| 846 | for (i = 0; i < 4; i++) { |
| 847 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 848 | i, I915_READ(GEN8_GT_IMR(i))); |
| 849 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 850 | i, I915_READ(GEN8_GT_IIR(i))); |
| 851 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 852 | i, I915_READ(GEN8_GT_IER(i))); |
| 853 | } |
| 854 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 855 | for_each_pipe(dev_priv, pipe) { |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 856 | enum intel_display_power_domain power_domain; |
| 857 | |
| 858 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 859 | if (!intel_display_power_get_if_enabled(dev_priv, |
| 860 | power_domain)) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 861 | seq_printf(m, "Pipe %c power disabled\n", |
| 862 | pipe_name(pipe)); |
| 863 | continue; |
| 864 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 865 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 866 | pipe_name(pipe), |
| 867 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 868 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 869 | pipe_name(pipe), |
| 870 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 871 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 872 | pipe_name(pipe), |
| 873 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 874 | |
| 875 | intel_display_power_put(dev_priv, power_domain); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 879 | I915_READ(GEN8_DE_PORT_IMR)); |
| 880 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 881 | I915_READ(GEN8_DE_PORT_IIR)); |
| 882 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 883 | I915_READ(GEN8_DE_PORT_IER)); |
| 884 | |
| 885 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 886 | I915_READ(GEN8_DE_MISC_IMR)); |
| 887 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 888 | I915_READ(GEN8_DE_MISC_IIR)); |
| 889 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 890 | I915_READ(GEN8_DE_MISC_IER)); |
| 891 | |
| 892 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 893 | I915_READ(GEN8_PCU_IMR)); |
| 894 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 895 | I915_READ(GEN8_PCU_IIR)); |
| 896 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 897 | I915_READ(GEN8_PCU_IER)); |
| 898 | } else if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 899 | seq_printf(m, "Display IER:\t%08x\n", |
| 900 | I915_READ(VLV_IER)); |
| 901 | seq_printf(m, "Display IIR:\t%08x\n", |
| 902 | I915_READ(VLV_IIR)); |
| 903 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 904 | I915_READ(VLV_IIR_RW)); |
| 905 | seq_printf(m, "Display IMR:\t%08x\n", |
| 906 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 907 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 908 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 909 | pipe_name(pipe), |
| 910 | I915_READ(PIPESTAT(pipe))); |
| 911 | |
| 912 | seq_printf(m, "Master IER:\t%08x\n", |
| 913 | I915_READ(VLV_MASTER_IER)); |
| 914 | |
| 915 | seq_printf(m, "Render IER:\t%08x\n", |
| 916 | I915_READ(GTIER)); |
| 917 | seq_printf(m, "Render IIR:\t%08x\n", |
| 918 | I915_READ(GTIIR)); |
| 919 | seq_printf(m, "Render IMR:\t%08x\n", |
| 920 | I915_READ(GTIMR)); |
| 921 | |
| 922 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 923 | I915_READ(GEN6_PMIER)); |
| 924 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 925 | I915_READ(GEN6_PMIIR)); |
| 926 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 927 | I915_READ(GEN6_PMIMR)); |
| 928 | |
| 929 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 930 | I915_READ(PORT_HOTPLUG_EN)); |
| 931 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 932 | I915_READ(VLV_DPFLIPSTAT)); |
| 933 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 934 | I915_READ(DPINVGTT)); |
| 935 | |
| 936 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 937 | seq_printf(m, "Interrupt enable: %08x\n", |
| 938 | I915_READ(IER)); |
| 939 | seq_printf(m, "Interrupt identity: %08x\n", |
| 940 | I915_READ(IIR)); |
| 941 | seq_printf(m, "Interrupt mask: %08x\n", |
| 942 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 943 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 944 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 945 | pipe_name(pipe), |
| 946 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 947 | } else { |
| 948 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 949 | I915_READ(DEIER)); |
| 950 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 951 | I915_READ(DEIIR)); |
| 952 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 953 | I915_READ(DEIMR)); |
| 954 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 955 | I915_READ(SDEIER)); |
| 956 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 957 | I915_READ(SDEIIR)); |
| 958 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 959 | I915_READ(SDEIMR)); |
| 960 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 961 | I915_READ(GTIER)); |
| 962 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 963 | I915_READ(GTIIR)); |
| 964 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 965 | I915_READ(GTIMR)); |
| 966 | } |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 967 | for_each_engine(engine, dev_priv) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 968 | if (INTEL_INFO(dev)->gen >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 969 | seq_printf(m, |
| 970 | "Graphics Interrupt mask (%s): %08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 971 | engine->name, I915_READ_IMR(engine)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 972 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 973 | i915_ring_seqno_info(m, engine); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 974 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 975 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 976 | mutex_unlock(&dev->struct_mutex); |
| 977 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 978 | return 0; |
| 979 | } |
| 980 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 981 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 982 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 983 | struct drm_info_node *node = m->private; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 984 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 985 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 986 | int i, ret; |
| 987 | |
| 988 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 989 | if (ret) |
| 990 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 991 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 992 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 993 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 994 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 995 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 996 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 997 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 998 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 999 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 1000 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1001 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1002 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1005 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 1006 | return 0; |
| 1007 | } |
| 1008 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1009 | static int i915_hws_info(struct seq_file *m, void *data) |
| 1010 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1011 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1012 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1013 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1014 | struct intel_engine_cs *engine; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 1015 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 1016 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1017 | |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1018 | engine = &dev_priv->engine[(uintptr_t)node->info_ent->data]; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1019 | hws = engine->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 1020 | if (hws == NULL) |
| 1021 | return 0; |
| 1022 | |
| 1023 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 1024 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1025 | i * 4, |
| 1026 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 1027 | } |
| 1028 | return 0; |
| 1029 | } |
| 1030 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1031 | static ssize_t |
| 1032 | i915_error_state_write(struct file *filp, |
| 1033 | const char __user *ubuf, |
| 1034 | size_t cnt, |
| 1035 | loff_t *ppos) |
| 1036 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1037 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1038 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1039 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1040 | |
| 1041 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 1042 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1043 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1044 | if (ret) |
| 1045 | return ret; |
| 1046 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1047 | i915_destroy_error_state(dev); |
| 1048 | mutex_unlock(&dev->struct_mutex); |
| 1049 | |
| 1050 | return cnt; |
| 1051 | } |
| 1052 | |
| 1053 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1054 | { |
| 1055 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1056 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1057 | |
| 1058 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 1059 | if (!error_priv) |
| 1060 | return -ENOMEM; |
| 1061 | |
| 1062 | error_priv->dev = dev; |
| 1063 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1064 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1065 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1066 | file->private_data = error_priv; |
| 1067 | |
| 1068 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 1072 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1073 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1074 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1075 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1076 | kfree(error_priv); |
| 1077 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1078 | return 0; |
| 1079 | } |
| 1080 | |
| 1081 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1082 | size_t count, loff_t *pos) |
| 1083 | { |
| 1084 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1085 | struct drm_i915_error_state_buf error_str; |
| 1086 | loff_t tmp_pos = 0; |
| 1087 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1088 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1089 | |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 1090 | 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] | 1091 | if (ret) |
| 1092 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1093 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1094 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1095 | if (ret) |
| 1096 | goto out; |
| 1097 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1098 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1099 | error_str.buf, |
| 1100 | error_str.bytes); |
| 1101 | |
| 1102 | if (ret_count < 0) |
| 1103 | ret = ret_count; |
| 1104 | else |
| 1105 | *pos = error_str.start + ret_count; |
| 1106 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1107 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1108 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | static const struct file_operations i915_error_state_fops = { |
| 1112 | .owner = THIS_MODULE, |
| 1113 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1114 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1115 | .write = i915_error_state_write, |
| 1116 | .llseek = default_llseek, |
| 1117 | .release = i915_error_state_release, |
| 1118 | }; |
| 1119 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1120 | static int |
| 1121 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1122 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1123 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1124 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1125 | int ret; |
| 1126 | |
| 1127 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1128 | if (ret) |
| 1129 | return ret; |
| 1130 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1131 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1132 | mutex_unlock(&dev->struct_mutex); |
| 1133 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1134 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1135 | } |
| 1136 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1137 | static int |
| 1138 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1139 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1140 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1141 | int ret; |
| 1142 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1143 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1144 | if (ret) |
| 1145 | return ret; |
| 1146 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 1147 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1148 | mutex_unlock(&dev->struct_mutex); |
| 1149 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1150 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1151 | } |
| 1152 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1153 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1154 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1155 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1156 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1157 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1158 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1159 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1160 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1161 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1162 | int ret = 0; |
| 1163 | |
| 1164 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1165 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1166 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1167 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1168 | if (IS_GEN5(dev)) { |
| 1169 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1170 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1171 | |
| 1172 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1173 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1174 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1175 | MEMSTAT_VID_SHIFT); |
| 1176 | seq_printf(m, "Current P-state: %d\n", |
| 1177 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1178 | } else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) { |
| 1179 | u32 freq_sts; |
| 1180 | |
| 1181 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1182 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
| 1183 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1184 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1185 | |
| 1186 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1187 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1188 | |
| 1189 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1190 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1191 | |
| 1192 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 1193 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1194 | |
| 1195 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 1196 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1197 | |
| 1198 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1199 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1200 | |
| 1201 | seq_printf(m, |
| 1202 | "efficient (RPe) frequency: %d MHz\n", |
| 1203 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
| 1204 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 1205 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1206 | u32 rp_state_limits; |
| 1207 | u32 gt_perf_status; |
| 1208 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1209 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1210 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1211 | u32 rpupei, rpcurup, rpprevup; |
| 1212 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1213 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1214 | int max_freq; |
| 1215 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1216 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 1217 | if (IS_BROXTON(dev)) { |
| 1218 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1219 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1220 | } else { |
| 1221 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1222 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1223 | } |
| 1224 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1225 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1226 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1227 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1228 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1229 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1230 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1231 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1232 | reqf = I915_READ(GEN6_RPNSWREQ); |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1233 | if (IS_GEN9(dev)) |
| 1234 | reqf >>= 23; |
| 1235 | else { |
| 1236 | reqf &= ~GEN6_TURBO_DISABLE; |
| 1237 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
| 1238 | reqf >>= 24; |
| 1239 | else |
| 1240 | reqf >>= 25; |
| 1241 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1242 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1243 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1244 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1245 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1246 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1247 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1248 | rpstat = I915_READ(GEN6_RPSTAT1); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1249 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK; |
| 1250 | rpcurup = I915_READ(GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK; |
| 1251 | rpprevup = I915_READ(GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK; |
| 1252 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK; |
| 1253 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK; |
| 1254 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK; |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1255 | if (IS_GEN9(dev)) |
| 1256 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
| 1257 | else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1258 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1259 | else |
| 1260 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1261 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1262 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1263 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1264 | mutex_unlock(&dev->struct_mutex); |
| 1265 | |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1266 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1267 | pm_ier = I915_READ(GEN6_PMIER); |
| 1268 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1269 | pm_isr = I915_READ(GEN6_PMISR); |
| 1270 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1271 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1272 | } else { |
| 1273 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1274 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1275 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1276 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1277 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1278 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1279 | 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] | 1280 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1281 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1282 | seq_printf(m, "Render p-state ratio: %d\n", |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1283 | (gt_perf_status & (IS_GEN9(dev) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1284 | seq_printf(m, "Render p-state VID: %d\n", |
| 1285 | gt_perf_status & 0xff); |
| 1286 | seq_printf(m, "Render p-state limit: %d\n", |
| 1287 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1288 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1289 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1290 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1291 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1292 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1293 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1294 | seq_printf(m, "RP CUR UP EI: %d (%dus)\n", |
| 1295 | rpupei, GT_PM_INTERVAL_TO_US(dev_priv, rpupei)); |
| 1296 | seq_printf(m, "RP CUR UP: %d (%dus)\n", |
| 1297 | rpcurup, GT_PM_INTERVAL_TO_US(dev_priv, rpcurup)); |
| 1298 | seq_printf(m, "RP PREV UP: %d (%dus)\n", |
| 1299 | rpprevup, GT_PM_INTERVAL_TO_US(dev_priv, rpprevup)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1300 | seq_printf(m, "Up threshold: %d%%\n", |
| 1301 | dev_priv->rps.up_threshold); |
| 1302 | |
Akash Goel | d6cda9c | 2016-04-23 00:05:46 +0530 | [diff] [blame] | 1303 | seq_printf(m, "RP CUR DOWN EI: %d (%dus)\n", |
| 1304 | rpdownei, GT_PM_INTERVAL_TO_US(dev_priv, rpdownei)); |
| 1305 | seq_printf(m, "RP CUR DOWN: %d (%dus)\n", |
| 1306 | rpcurdown, GT_PM_INTERVAL_TO_US(dev_priv, rpcurdown)); |
| 1307 | seq_printf(m, "RP PREV DOWN: %d (%dus)\n", |
| 1308 | rpprevdown, GT_PM_INTERVAL_TO_US(dev_priv, rpprevdown)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1309 | seq_printf(m, "Down threshold: %d%%\n", |
| 1310 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1311 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1312 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 0 : |
| 1313 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1314 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1315 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1316 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1317 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1318 | |
| 1319 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1320 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1321 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1322 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1323 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1324 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1325 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 16 : |
| 1326 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1327 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1328 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1329 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1330 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1331 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1332 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1333 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1334 | seq_printf(m, "Current freq: %d MHz\n", |
| 1335 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1336 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1337 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1338 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1339 | seq_printf(m, "Min freq: %d MHz\n", |
| 1340 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1341 | seq_printf(m, "Max freq: %d MHz\n", |
| 1342 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1343 | seq_printf(m, |
| 1344 | "efficient (RPe) frequency: %d MHz\n", |
| 1345 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1346 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1347 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1348 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1349 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1350 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1351 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1352 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1353 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1354 | out: |
| 1355 | intel_runtime_pm_put(dev_priv); |
| 1356 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1357 | } |
| 1358 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1359 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1360 | { |
| 1361 | struct drm_info_node *node = m->private; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1362 | struct drm_device *dev = node->minor->dev; |
| 1363 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1364 | struct intel_engine_cs *engine; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 1365 | u64 acthd[I915_NUM_ENGINES]; |
| 1366 | u32 seqno[I915_NUM_ENGINES]; |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1367 | u32 instdone[I915_NUM_INSTDONE_REG]; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1368 | enum intel_engine_id id; |
| 1369 | int j; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1370 | |
| 1371 | if (!i915.enable_hangcheck) { |
| 1372 | seq_printf(m, "Hangcheck disabled\n"); |
| 1373 | return 0; |
| 1374 | } |
| 1375 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1376 | intel_runtime_pm_get(dev_priv); |
| 1377 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1378 | for_each_engine_id(engine, dev_priv, id) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1379 | acthd[id] = intel_ring_get_active_head(engine); |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 1380 | seqno[id] = engine->get_seqno(engine); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1381 | } |
| 1382 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame^] | 1383 | i915_get_extra_instdone(dev_priv, instdone); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1384 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1385 | intel_runtime_pm_put(dev_priv); |
| 1386 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1387 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1388 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1389 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1390 | jiffies)); |
| 1391 | } else |
| 1392 | seq_printf(m, "Hangcheck inactive\n"); |
| 1393 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1394 | for_each_engine_id(engine, dev_priv, id) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1395 | seq_printf(m, "%s:\n", engine->name); |
Chris Wilson | 14fd0d6 | 2016-04-07 07:29:10 +0100 | [diff] [blame] | 1396 | seq_printf(m, "\tseqno = %x [current %x, last %x]\n", |
| 1397 | engine->hangcheck.seqno, |
| 1398 | seqno[id], |
| 1399 | engine->last_submitted_seqno); |
Chris Wilson | 12471ba | 2016-04-09 10:57:55 +0100 | [diff] [blame] | 1400 | seq_printf(m, "\tuser interrupts = %x [current %x]\n", |
| 1401 | engine->hangcheck.user_interrupts, |
| 1402 | READ_ONCE(engine->user_interrupts)); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1403 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1404 | (long long)engine->hangcheck.acthd, |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1405 | (long long)acthd[id]); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1406 | seq_printf(m, "\tscore = %d\n", engine->hangcheck.score); |
| 1407 | seq_printf(m, "\taction = %d\n", engine->hangcheck.action); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1408 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1409 | if (engine->id == RCS) { |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1410 | seq_puts(m, "\tinstdone read ="); |
| 1411 | |
| 1412 | for (j = 0; j < I915_NUM_INSTDONE_REG; j++) |
| 1413 | seq_printf(m, " 0x%08x", instdone[j]); |
| 1414 | |
| 1415 | seq_puts(m, "\n\tinstdone accu ="); |
| 1416 | |
| 1417 | for (j = 0; j < I915_NUM_INSTDONE_REG; j++) |
| 1418 | seq_printf(m, " 0x%08x", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1419 | engine->hangcheck.instdone[j]); |
Mika Kuoppala | 61642ff | 2015-12-01 17:56:12 +0200 | [diff] [blame] | 1420 | |
| 1421 | seq_puts(m, "\n"); |
| 1422 | } |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | return 0; |
| 1426 | } |
| 1427 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1428 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1429 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1430 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1431 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1432 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1433 | u32 rgvmodectl, rstdbyctl; |
| 1434 | u16 crstandvid; |
| 1435 | int ret; |
| 1436 | |
| 1437 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1438 | if (ret) |
| 1439 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1440 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1441 | |
| 1442 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1443 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1444 | crstandvid = I915_READ16(CRSTANDVID); |
| 1445 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1446 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1447 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1448 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1449 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1450 | seq_printf(m, "Boost freq: %d\n", |
| 1451 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1452 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1453 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1454 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1455 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1456 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1457 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1458 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1459 | seq_printf(m, "Starting frequency: P%d\n", |
| 1460 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1461 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1462 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1463 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1464 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1465 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1466 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1467 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1468 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1469 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1470 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1471 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1472 | break; |
| 1473 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1474 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1475 | break; |
| 1476 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1477 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1478 | break; |
| 1479 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1480 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1481 | break; |
| 1482 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1483 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1484 | break; |
| 1485 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1486 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1487 | break; |
| 1488 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1489 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1490 | break; |
| 1491 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1492 | |
| 1493 | return 0; |
| 1494 | } |
| 1495 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1496 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1497 | { |
| 1498 | struct drm_info_node *node = m->private; |
| 1499 | struct drm_device *dev = node->minor->dev; |
| 1500 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1501 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1502 | |
| 1503 | spin_lock_irq(&dev_priv->uncore.lock); |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1504 | for_each_fw_domain(fw_domain, dev_priv) { |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1505 | seq_printf(m, "%s.wake_count = %u\n", |
Tvrtko Ursulin | 33c582c | 2016-04-07 17:04:33 +0100 | [diff] [blame] | 1506 | intel_uncore_forcewake_domain_to_str(fw_domain->id), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1507 | fw_domain->wake_count); |
| 1508 | } |
| 1509 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1510 | |
| 1511 | return 0; |
| 1512 | } |
| 1513 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1514 | static int vlv_drpc_info(struct seq_file *m) |
| 1515 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1516 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1517 | struct drm_device *dev = node->minor->dev; |
| 1518 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1519 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1520 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1521 | intel_runtime_pm_get(dev_priv); |
| 1522 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1523 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1524 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1525 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1526 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1527 | intel_runtime_pm_put(dev_priv); |
| 1528 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1529 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1530 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1531 | seq_printf(m, "Turbo enabled: %s\n", |
| 1532 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1533 | seq_printf(m, "HW control enabled: %s\n", |
| 1534 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1535 | seq_printf(m, "SW control enabled: %s\n", |
| 1536 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1537 | GEN6_RP_MEDIA_SW_MODE)); |
| 1538 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1539 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1540 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1541 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1542 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1543 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1544 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1545 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1546 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1547 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1548 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1549 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1550 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1551 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1552 | } |
| 1553 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1554 | static int gen6_drpc_info(struct seq_file *m) |
| 1555 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1556 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1557 | struct drm_device *dev = node->minor->dev; |
| 1558 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1559 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1560 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1561 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1562 | |
| 1563 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1564 | if (ret) |
| 1565 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1566 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1567 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1568 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1569 | 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] | 1570 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1571 | |
| 1572 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1573 | seq_puts(m, "RC information inaccurate because somebody " |
| 1574 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1575 | } else { |
| 1576 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1577 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1578 | udelay(10); |
| 1579 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1580 | } |
| 1581 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1582 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1583 | 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] | 1584 | |
| 1585 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1586 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1587 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1588 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1589 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1590 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1591 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1592 | intel_runtime_pm_put(dev_priv); |
| 1593 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1594 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1595 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1596 | seq_printf(m, "HW control enabled: %s\n", |
| 1597 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1598 | seq_printf(m, "SW control enabled: %s\n", |
| 1599 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1600 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1601 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1602 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1603 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1604 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1605 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1606 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1607 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1608 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1609 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1610 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1611 | case GEN6_RC0: |
| 1612 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1613 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1614 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1615 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1616 | break; |
| 1617 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1618 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1619 | break; |
| 1620 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1621 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1622 | break; |
| 1623 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1624 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1625 | break; |
| 1626 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1627 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1628 | break; |
| 1629 | } |
| 1630 | |
| 1631 | seq_printf(m, "Core Power Down: %s\n", |
| 1632 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1633 | |
| 1634 | /* Not exactly sure what this is */ |
| 1635 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1636 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1637 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1638 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1639 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1640 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1641 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1642 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1643 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1644 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1645 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1646 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1647 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1648 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1649 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1650 | return 0; |
| 1651 | } |
| 1652 | |
| 1653 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1654 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1655 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1656 | struct drm_device *dev = node->minor->dev; |
| 1657 | |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1658 | if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1659 | return vlv_drpc_info(m); |
Vedang Patel | ac66cf4 | 2014-08-26 10:42:51 -0700 | [diff] [blame] | 1660 | else if (INTEL_INFO(dev)->gen >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1661 | return gen6_drpc_info(m); |
| 1662 | else |
| 1663 | return ironlake_drpc_info(m); |
| 1664 | } |
| 1665 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1666 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1667 | { |
| 1668 | struct drm_info_node *node = m->private; |
| 1669 | struct drm_device *dev = node->minor->dev; |
| 1670 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1671 | |
| 1672 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1673 | dev_priv->fb_tracking.busy_bits); |
| 1674 | |
| 1675 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1676 | dev_priv->fb_tracking.flip_bits); |
| 1677 | |
| 1678 | return 0; |
| 1679 | } |
| 1680 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1681 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1682 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1683 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1684 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1685 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1686 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1687 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1688 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1689 | return 0; |
| 1690 | } |
| 1691 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1692 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1693 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1694 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1695 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1696 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1697 | else |
| 1698 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1699 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1700 | |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1701 | if (INTEL_INFO(dev_priv)->gen >= 7) |
| 1702 | seq_printf(m, "Compressing: %s\n", |
| 1703 | yesno(I915_READ(FBC_STATUS2) & |
| 1704 | FBC_COMPRESSION_MASK)); |
| 1705 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1706 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1707 | intel_runtime_pm_put(dev_priv); |
| 1708 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1709 | return 0; |
| 1710 | } |
| 1711 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1712 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1713 | { |
| 1714 | struct drm_device *dev = data; |
| 1715 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1716 | |
| 1717 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1718 | return -ENODEV; |
| 1719 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1720 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1721 | |
| 1722 | return 0; |
| 1723 | } |
| 1724 | |
| 1725 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1726 | { |
| 1727 | struct drm_device *dev = data; |
| 1728 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1729 | u32 reg; |
| 1730 | |
| 1731 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1732 | return -ENODEV; |
| 1733 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1734 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1735 | |
| 1736 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1737 | dev_priv->fbc.false_color = val; |
| 1738 | |
| 1739 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1740 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1741 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1742 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1743 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1744 | return 0; |
| 1745 | } |
| 1746 | |
| 1747 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1748 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1749 | "%llu\n"); |
| 1750 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1751 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1752 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1753 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1754 | struct drm_device *dev = node->minor->dev; |
| 1755 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1756 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1757 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1758 | seq_puts(m, "not supported\n"); |
| 1759 | return 0; |
| 1760 | } |
| 1761 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1762 | intel_runtime_pm_get(dev_priv); |
| 1763 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1764 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1765 | yesno(i915.enable_ips)); |
| 1766 | |
| 1767 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1768 | seq_puts(m, "Currently: unknown\n"); |
| 1769 | } else { |
| 1770 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1771 | seq_puts(m, "Currently: enabled\n"); |
| 1772 | else |
| 1773 | seq_puts(m, "Currently: disabled\n"); |
| 1774 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1775 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1776 | intel_runtime_pm_put(dev_priv); |
| 1777 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1778 | return 0; |
| 1779 | } |
| 1780 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1781 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1782 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1783 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1784 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1785 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1786 | bool sr_enabled = false; |
| 1787 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1788 | intel_runtime_pm_get(dev_priv); |
| 1789 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1790 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1791 | 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] | 1792 | else if (IS_CRESTLINE(dev) || IS_G4X(dev) || |
| 1793 | IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1794 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1795 | else if (IS_I915GM(dev)) |
| 1796 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1797 | else if (IS_PINEVIEW(dev)) |
| 1798 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1799 | else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1800 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1801 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1802 | intel_runtime_pm_put(dev_priv); |
| 1803 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1804 | seq_printf(m, "self-refresh: %s\n", |
| 1805 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1806 | |
| 1807 | return 0; |
| 1808 | } |
| 1809 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1810 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1811 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1812 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1813 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1814 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1815 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1816 | int ret; |
| 1817 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1818 | if (!IS_GEN5(dev)) |
| 1819 | return -ENODEV; |
| 1820 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1821 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1822 | if (ret) |
| 1823 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1824 | |
| 1825 | temp = i915_mch_val(dev_priv); |
| 1826 | chipset = i915_chipset_val(dev_priv); |
| 1827 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1828 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1829 | |
| 1830 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1831 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1832 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1833 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1834 | |
| 1835 | return 0; |
| 1836 | } |
| 1837 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1838 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1839 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1840 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1841 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1842 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1843 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1844 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1845 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1846 | |
Akash Goel | 97d3308 | 2015-06-29 14:50:23 +0530 | [diff] [blame] | 1847 | if (!HAS_CORE_RING_FREQ(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1848 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1849 | return 0; |
| 1850 | } |
| 1851 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1852 | intel_runtime_pm_get(dev_priv); |
| 1853 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1854 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1855 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1856 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1857 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1858 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1859 | |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1860 | if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1861 | /* Convert GT frequency to 50 HZ units */ |
| 1862 | min_gpu_freq = |
| 1863 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1864 | max_gpu_freq = |
| 1865 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1866 | } else { |
| 1867 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1868 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1869 | } |
| 1870 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1871 | 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] | 1872 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1873 | 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] | 1874 | ia_freq = gpu_freq; |
| 1875 | sandybridge_pcode_read(dev_priv, |
| 1876 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1877 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1878 | 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] | 1879 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1880 | (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1881 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1882 | ((ia_freq >> 0) & 0xff) * 100, |
| 1883 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1884 | } |
| 1885 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1886 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1887 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1888 | out: |
| 1889 | intel_runtime_pm_put(dev_priv); |
| 1890 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1891 | } |
| 1892 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1893 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1894 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1895 | struct drm_info_node *node = m->private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1896 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1897 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1898 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1899 | int ret; |
| 1900 | |
| 1901 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1902 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1903 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1904 | |
Jani Nikula | 2455a8e | 2015-12-14 12:50:53 +0200 | [diff] [blame] | 1905 | if (opregion->header) |
| 1906 | seq_write(m, opregion->header, OPREGION_SIZE); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1907 | |
| 1908 | mutex_unlock(&dev->struct_mutex); |
| 1909 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1910 | out: |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1911 | return 0; |
| 1912 | } |
| 1913 | |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 1914 | static int i915_vbt(struct seq_file *m, void *unused) |
| 1915 | { |
| 1916 | struct drm_info_node *node = m->private; |
| 1917 | struct drm_device *dev = node->minor->dev; |
| 1918 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1919 | struct intel_opregion *opregion = &dev_priv->opregion; |
| 1920 | |
| 1921 | if (opregion->vbt) |
| 1922 | seq_write(m, opregion->vbt, opregion->vbt_size); |
| 1923 | |
| 1924 | return 0; |
| 1925 | } |
| 1926 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1927 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1928 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1929 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1930 | struct drm_device *dev = node->minor->dev; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1931 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1932 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1933 | int ret; |
| 1934 | |
| 1935 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1936 | if (ret) |
| 1937 | return ret; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1938 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1939 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1940 | if (to_i915(dev)->fbdev) { |
| 1941 | fbdev_fb = to_intel_framebuffer(to_i915(dev)->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1942 | |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1943 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1944 | fbdev_fb->base.width, |
| 1945 | fbdev_fb->base.height, |
| 1946 | fbdev_fb->base.depth, |
| 1947 | fbdev_fb->base.bits_per_pixel, |
| 1948 | fbdev_fb->base.modifier[0], |
| 1949 | atomic_read(&fbdev_fb->base.refcount.refcount)); |
| 1950 | describe_obj(m, fbdev_fb->obj); |
| 1951 | seq_putc(m, '\n'); |
| 1952 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1953 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1954 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1955 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1956 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1957 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1958 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1959 | continue; |
| 1960 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1961 | 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] | 1962 | fb->base.width, |
| 1963 | fb->base.height, |
| 1964 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1965 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1966 | fb->base.modifier[0], |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1967 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1968 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1969 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1970 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1971 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 188c1ab | 2016-04-03 14:14:20 +0100 | [diff] [blame] | 1972 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1973 | |
| 1974 | return 0; |
| 1975 | } |
| 1976 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1977 | static void describe_ctx_ringbuf(struct seq_file *m, |
| 1978 | struct intel_ringbuffer *ringbuf) |
| 1979 | { |
| 1980 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
| 1981 | ringbuf->space, ringbuf->head, ringbuf->tail, |
| 1982 | ringbuf->last_retired_head); |
| 1983 | } |
| 1984 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1985 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1986 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1987 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1988 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1989 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1990 | struct intel_engine_cs *engine; |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1991 | struct intel_context *ctx; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1992 | enum intel_engine_id id; |
| 1993 | int ret; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1994 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1995 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1996 | if (ret) |
| 1997 | return ret; |
| 1998 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1999 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2000 | if (!i915.enable_execlists && |
| 2001 | ctx->legacy_hw_ctx.rcs_state == NULL) |
Chris Wilson | b77f699 | 2014-04-30 08:30:00 +0100 | [diff] [blame] | 2002 | continue; |
| 2003 | |
Chris Wilson | 5d1808e | 2016-04-28 09:56:51 +0100 | [diff] [blame] | 2004 | seq_printf(m, "HW context %u ", ctx->hw_id); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 2005 | describe_ctx(m, ctx); |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2006 | if (ctx == dev_priv->kernel_context) |
| 2007 | seq_printf(m, "(kernel context) "); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2008 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2009 | if (i915.enable_execlists) { |
| 2010 | seq_putc(m, '\n'); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 2011 | for_each_engine_id(engine, dev_priv, id) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2012 | struct drm_i915_gem_object *ctx_obj = |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 2013 | ctx->engine[id].state; |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2014 | struct intel_ringbuffer *ringbuf = |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 2015 | ctx->engine[id].ringbuf; |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2016 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2017 | seq_printf(m, "%s: ", engine->name); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 2018 | if (ctx_obj) |
| 2019 | describe_obj(m, ctx_obj); |
| 2020 | if (ringbuf) |
| 2021 | describe_ctx_ringbuf(m, ringbuf); |
| 2022 | seq_putc(m, '\n'); |
| 2023 | } |
| 2024 | } else { |
| 2025 | describe_obj(m, ctx->legacy_hw_ctx.rcs_state); |
| 2026 | } |
| 2027 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 2028 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 2029 | } |
| 2030 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 2031 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2032 | |
| 2033 | return 0; |
| 2034 | } |
| 2035 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2036 | static void i915_dump_lrc_obj(struct seq_file *m, |
Tvrtko Ursulin | ca82580 | 2016-01-15 15:10:27 +0000 | [diff] [blame] | 2037 | struct intel_context *ctx, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2038 | struct intel_engine_cs *engine) |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2039 | { |
| 2040 | struct page *page; |
| 2041 | uint32_t *reg_state; |
| 2042 | int j; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2043 | struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state; |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2044 | unsigned long ggtt_offset = 0; |
| 2045 | |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2046 | seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id); |
| 2047 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2048 | if (ctx_obj == NULL) { |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2049 | seq_puts(m, "\tNot allocated\n"); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2050 | return; |
| 2051 | } |
| 2052 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2053 | if (!i915_gem_obj_ggtt_bound(ctx_obj)) |
| 2054 | seq_puts(m, "\tNot bound in GGTT\n"); |
| 2055 | else |
| 2056 | ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj); |
| 2057 | |
| 2058 | if (i915_gem_object_get_pages(ctx_obj)) { |
| 2059 | seq_puts(m, "\tFailed to get pages for context object\n"); |
| 2060 | return; |
| 2061 | } |
| 2062 | |
Alex Dai | d167519 | 2015-08-12 15:43:43 +0100 | [diff] [blame] | 2063 | page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2064 | if (!WARN_ON(page == NULL)) { |
| 2065 | reg_state = kmap_atomic(page); |
| 2066 | |
| 2067 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 2068 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2069 | ggtt_offset + 4096 + (j * 4), |
| 2070 | reg_state[j], reg_state[j + 1], |
| 2071 | reg_state[j + 2], reg_state[j + 3]); |
| 2072 | } |
| 2073 | kunmap_atomic(reg_state); |
| 2074 | } |
| 2075 | |
| 2076 | seq_putc(m, '\n'); |
| 2077 | } |
| 2078 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2079 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2080 | { |
| 2081 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2082 | struct drm_device *dev = node->minor->dev; |
| 2083 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2084 | struct intel_engine_cs *engine; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2085 | struct intel_context *ctx; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2086 | int ret; |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2087 | |
| 2088 | if (!i915.enable_execlists) { |
| 2089 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2090 | return 0; |
| 2091 | } |
| 2092 | |
| 2093 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2094 | if (ret) |
| 2095 | return ret; |
| 2096 | |
Dave Gordon | e28e404 | 2016-01-19 19:02:55 +0000 | [diff] [blame] | 2097 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
Chris Wilson | 24f1d3c | 2016-04-28 09:56:53 +0100 | [diff] [blame] | 2098 | for_each_engine(engine, dev_priv) |
| 2099 | i915_dump_lrc_obj(m, ctx, engine); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2100 | |
| 2101 | mutex_unlock(&dev->struct_mutex); |
| 2102 | |
| 2103 | return 0; |
| 2104 | } |
| 2105 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2106 | static int i915_execlists(struct seq_file *m, void *data) |
| 2107 | { |
| 2108 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 2109 | struct drm_device *dev = node->minor->dev; |
| 2110 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2111 | struct intel_engine_cs *engine; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2112 | u32 status_pointer; |
| 2113 | u8 read_pointer; |
| 2114 | u8 write_pointer; |
| 2115 | u32 status; |
| 2116 | u32 ctx_id; |
| 2117 | struct list_head *cursor; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2118 | int i, ret; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2119 | |
| 2120 | if (!i915.enable_execlists) { |
| 2121 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 2122 | return 0; |
| 2123 | } |
| 2124 | |
| 2125 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2126 | if (ret) |
| 2127 | return ret; |
| 2128 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2129 | intel_runtime_pm_get(dev_priv); |
| 2130 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2131 | for_each_engine(engine, dev_priv) { |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2132 | struct drm_i915_gem_request *head_req = NULL; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2133 | int count = 0; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2134 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2135 | seq_printf(m, "%s\n", engine->name); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2136 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2137 | status = I915_READ(RING_EXECLIST_STATUS_LO(engine)); |
| 2138 | ctx_id = I915_READ(RING_EXECLIST_STATUS_HI(engine)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2139 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 2140 | status, ctx_id); |
| 2141 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2142 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(engine)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2143 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 2144 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2145 | read_pointer = engine->next_context_status_buffer; |
Ben Widawsky | 5590a5f | 2016-01-05 10:30:05 -0800 | [diff] [blame] | 2146 | write_pointer = GEN8_CSB_WRITE_PTR(status_pointer); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2147 | if (read_pointer > write_pointer) |
Ben Widawsky | 5590a5f | 2016-01-05 10:30:05 -0800 | [diff] [blame] | 2148 | write_pointer += GEN8_CSB_ENTRIES; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2149 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 2150 | read_pointer, write_pointer); |
| 2151 | |
Ben Widawsky | 5590a5f | 2016-01-05 10:30:05 -0800 | [diff] [blame] | 2152 | for (i = 0; i < GEN8_CSB_ENTRIES; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2153 | status = I915_READ(RING_CONTEXT_STATUS_BUF_LO(engine, i)); |
| 2154 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF_HI(engine, i)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2155 | |
| 2156 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 2157 | i, status, ctx_id); |
| 2158 | } |
| 2159 | |
Tvrtko Ursulin | 27af5ee | 2016-04-04 12:11:56 +0100 | [diff] [blame] | 2160 | spin_lock_bh(&engine->execlist_lock); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2161 | list_for_each(cursor, &engine->execlist_queue) |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2162 | count++; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2163 | head_req = list_first_entry_or_null(&engine->execlist_queue, |
| 2164 | struct drm_i915_gem_request, |
| 2165 | execlist_link); |
Tvrtko Ursulin | 27af5ee | 2016-04-04 12:11:56 +0100 | [diff] [blame] | 2166 | spin_unlock_bh(&engine->execlist_lock); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2167 | |
| 2168 | seq_printf(m, "\t%d requests in queue\n", count); |
| 2169 | if (head_req) { |
Chris Wilson | 7069b14 | 2016-04-28 09:56:52 +0100 | [diff] [blame] | 2170 | seq_printf(m, "\tHead request context: %u\n", |
| 2171 | head_req->ctx->hw_id); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2172 | seq_printf(m, "\tHead request tail: %u\n", |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2173 | head_req->tail); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2174 | } |
| 2175 | |
| 2176 | seq_putc(m, '\n'); |
| 2177 | } |
| 2178 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2179 | intel_runtime_pm_put(dev_priv); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2180 | mutex_unlock(&dev->struct_mutex); |
| 2181 | |
| 2182 | return 0; |
| 2183 | } |
| 2184 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2185 | static const char *swizzle_string(unsigned swizzle) |
| 2186 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2187 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2188 | case I915_BIT_6_SWIZZLE_NONE: |
| 2189 | return "none"; |
| 2190 | case I915_BIT_6_SWIZZLE_9: |
| 2191 | return "bit9"; |
| 2192 | case I915_BIT_6_SWIZZLE_9_10: |
| 2193 | return "bit9/bit10"; |
| 2194 | case I915_BIT_6_SWIZZLE_9_11: |
| 2195 | return "bit9/bit11"; |
| 2196 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2197 | return "bit9/bit10/bit11"; |
| 2198 | case I915_BIT_6_SWIZZLE_9_17: |
| 2199 | return "bit9/bit17"; |
| 2200 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2201 | return "bit9/bit10/bit17"; |
| 2202 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2203 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2204 | } |
| 2205 | |
| 2206 | return "bug"; |
| 2207 | } |
| 2208 | |
| 2209 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2210 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2211 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2212 | struct drm_device *dev = node->minor->dev; |
| 2213 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2214 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2215 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2216 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2217 | if (ret) |
| 2218 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2219 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2220 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2221 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2222 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2223 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2224 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2225 | |
| 2226 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 2227 | seq_printf(m, "DDC = 0x%08x\n", |
| 2228 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2229 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2230 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2231 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2232 | I915_READ16(C0DRB3)); |
| 2233 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2234 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2235 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2236 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2237 | I915_READ(MAD_DIMM_C0)); |
| 2238 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2239 | I915_READ(MAD_DIMM_C1)); |
| 2240 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2241 | I915_READ(MAD_DIMM_C2)); |
| 2242 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2243 | I915_READ(TILECTL)); |
Robert Beckett | 5907f5f | 2014-01-23 14:23:14 +0000 | [diff] [blame] | 2244 | if (INTEL_INFO(dev)->gen >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2245 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2246 | I915_READ(GAMTARBMODE)); |
| 2247 | else |
| 2248 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2249 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2250 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2251 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2252 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2253 | |
| 2254 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2255 | seq_puts(m, "L-shaped memory detected\n"); |
| 2256 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2257 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2258 | mutex_unlock(&dev->struct_mutex); |
| 2259 | |
| 2260 | return 0; |
| 2261 | } |
| 2262 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2263 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2264 | { |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 2265 | struct intel_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2266 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2267 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2268 | |
| 2269 | if (!ppgtt) { |
| 2270 | seq_printf(m, " no ppgtt for context %d\n", |
| 2271 | ctx->user_handle); |
| 2272 | return 0; |
| 2273 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2274 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2275 | if (i915_gem_context_is_default(ctx)) |
| 2276 | seq_puts(m, " default context:\n"); |
| 2277 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2278 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2279 | ppgtt->debug_dump(ppgtt, m); |
| 2280 | |
| 2281 | return 0; |
| 2282 | } |
| 2283 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2284 | 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] | 2285 | { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2286 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2287 | struct intel_engine_cs *engine; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2288 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2289 | int i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2290 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2291 | if (!ppgtt) |
| 2292 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2293 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2294 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2295 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2296 | for (i = 0; i < 4; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2297 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(engine, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2298 | pdp <<= 32; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2299 | pdp |= I915_READ(GEN8_RING_PDP_LDW(engine, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2300 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2301 | } |
| 2302 | } |
| 2303 | } |
| 2304 | |
| 2305 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2306 | { |
| 2307 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2308 | struct intel_engine_cs *engine; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2309 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2310 | if (INTEL_INFO(dev)->gen == 6) |
| 2311 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2312 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2313 | for_each_engine(engine, dev_priv) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2314 | seq_printf(m, "%s\n", engine->name); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2315 | if (INTEL_INFO(dev)->gen == 7) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2316 | seq_printf(m, "GFX_MODE: 0x%08x\n", |
| 2317 | I915_READ(RING_MODE_GEN7(engine))); |
| 2318 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", |
| 2319 | I915_READ(RING_PP_DIR_BASE(engine))); |
| 2320 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", |
| 2321 | I915_READ(RING_PP_DIR_BASE_READ(engine))); |
| 2322 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", |
| 2323 | I915_READ(RING_PP_DIR_DCLV(engine))); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2324 | } |
| 2325 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2326 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2327 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2328 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2329 | 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] | 2330 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2331 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2332 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2333 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2334 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2335 | } |
| 2336 | |
| 2337 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2338 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2339 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2340 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2341 | struct drm_i915_private *dev_priv = dev->dev_private; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2342 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2343 | |
| 2344 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2345 | if (ret) |
| 2346 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2347 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2348 | |
| 2349 | if (INTEL_INFO(dev)->gen >= 8) |
| 2350 | gen8_ppgtt_info(m, dev); |
| 2351 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2352 | gen6_ppgtt_info(m, dev); |
| 2353 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2354 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2355 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2356 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2357 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2358 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2359 | if (!task) { |
| 2360 | ret = -ESRCH; |
| 2361 | goto out_put; |
| 2362 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2363 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2364 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2365 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2366 | (void *)(unsigned long)m); |
| 2367 | } |
| 2368 | |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2369 | out_put: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2370 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2371 | mutex_unlock(&dev->struct_mutex); |
| 2372 | |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2373 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2374 | } |
| 2375 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2376 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2377 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2378 | struct intel_engine_cs *engine; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2379 | int count = 0; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2380 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2381 | for_each_engine(engine, i915) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2382 | count += engine->irq_refcount; |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2383 | |
| 2384 | return count; |
| 2385 | } |
| 2386 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2387 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2388 | { |
| 2389 | struct drm_info_node *node = m->private; |
| 2390 | struct drm_device *dev = node->minor->dev; |
| 2391 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2392 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2393 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2394 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
| 2395 | seq_printf(m, "GPU busy? %d\n", dev_priv->mm.busy); |
| 2396 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
| 2397 | seq_printf(m, "Frequency requested %d; min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
| 2398 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq), |
| 2399 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2400 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2401 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2402 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2403 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2404 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2405 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2406 | struct task_struct *task; |
| 2407 | |
| 2408 | rcu_read_lock(); |
| 2409 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2410 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2411 | task ? task->comm : "<unknown>", |
| 2412 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2413 | file_priv->rps.boosts, |
| 2414 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2415 | rcu_read_unlock(); |
| 2416 | } |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2417 | seq_printf(m, "Semaphore boosts: %d%s\n", |
| 2418 | dev_priv->rps.semaphores.boosts, |
| 2419 | list_empty(&dev_priv->rps.semaphores.link) ? "" : ", active"); |
| 2420 | seq_printf(m, "MMIO flip boosts: %d%s\n", |
| 2421 | dev_priv->rps.mmioflips.boosts, |
| 2422 | list_empty(&dev_priv->rps.mmioflips.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2423 | seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2424 | spin_unlock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2425 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2426 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2427 | } |
| 2428 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2429 | static int i915_llc(struct seq_file *m, void *data) |
| 2430 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2431 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2432 | struct drm_device *dev = node->minor->dev; |
| 2433 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2434 | const bool edram = INTEL_GEN(dev_priv) > 8; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2435 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2436 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
Mika Kuoppala | 3accaf7 | 2016-04-13 17:26:43 +0300 | [diff] [blame] | 2437 | seq_printf(m, "%s: %lluMB\n", edram ? "eDRAM" : "eLLC", |
| 2438 | intel_uncore_edram_size(dev_priv)/1024/1024); |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2439 | |
| 2440 | return 0; |
| 2441 | } |
| 2442 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2443 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2444 | { |
| 2445 | struct drm_info_node *node = m->private; |
| 2446 | struct drm_i915_private *dev_priv = node->minor->dev->dev_private; |
| 2447 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
| 2448 | u32 tmp, i; |
| 2449 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2450 | if (!HAS_GUC_UCODE(dev_priv)) |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2451 | return 0; |
| 2452 | |
| 2453 | seq_printf(m, "GuC firmware status:\n"); |
| 2454 | seq_printf(m, "\tpath: %s\n", |
| 2455 | guc_fw->guc_fw_path); |
| 2456 | seq_printf(m, "\tfetch: %s\n", |
| 2457 | intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status)); |
| 2458 | seq_printf(m, "\tload: %s\n", |
| 2459 | intel_guc_fw_status_repr(guc_fw->guc_fw_load_status)); |
| 2460 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2461 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
| 2462 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2463 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2464 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2465 | guc_fw->header_offset, guc_fw->header_size); |
| 2466 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2467 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2468 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2469 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2470 | |
| 2471 | tmp = I915_READ(GUC_STATUS); |
| 2472 | |
| 2473 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2474 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2475 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2476 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2477 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2478 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2479 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2480 | seq_puts(m, "\nScratch registers:\n"); |
| 2481 | for (i = 0; i < 16; i++) |
| 2482 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2483 | |
| 2484 | return 0; |
| 2485 | } |
| 2486 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2487 | static void i915_guc_client_info(struct seq_file *m, |
| 2488 | struct drm_i915_private *dev_priv, |
| 2489 | struct i915_guc_client *client) |
| 2490 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2491 | struct intel_engine_cs *engine; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2492 | uint64_t tot = 0; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2493 | |
| 2494 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2495 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2496 | seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", |
| 2497 | client->doorbell_id, client->doorbell_offset, client->cookie); |
| 2498 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2499 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2500 | |
| 2501 | seq_printf(m, "\tFailed to queue: %u\n", client->q_fail); |
| 2502 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2503 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2504 | |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2505 | for_each_engine(engine, dev_priv) { |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2506 | seq_printf(m, "\tSubmissions: %llu %s\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2507 | client->submissions[engine->guc_id], |
| 2508 | engine->name); |
| 2509 | tot += client->submissions[engine->guc_id]; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2510 | } |
| 2511 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2512 | } |
| 2513 | |
| 2514 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2515 | { |
| 2516 | struct drm_info_node *node = m->private; |
| 2517 | struct drm_device *dev = node->minor->dev; |
| 2518 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2519 | struct intel_guc guc; |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 2520 | struct i915_guc_client client = {}; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2521 | struct intel_engine_cs *engine; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2522 | u64 total = 0; |
| 2523 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2524 | if (!HAS_GUC_SCHED(dev_priv)) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2525 | return 0; |
| 2526 | |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2527 | if (mutex_lock_interruptible(&dev->struct_mutex)) |
| 2528 | return 0; |
| 2529 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2530 | /* 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] | 2531 | guc = dev_priv->guc; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2532 | if (guc.execbuf_client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2533 | client = *guc.execbuf_client; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame] | 2534 | |
| 2535 | mutex_unlock(&dev->struct_mutex); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2536 | |
| 2537 | seq_printf(m, "GuC total action count: %llu\n", guc.action_count); |
| 2538 | seq_printf(m, "GuC action failure count: %u\n", guc.action_fail); |
| 2539 | seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd); |
| 2540 | seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status); |
| 2541 | seq_printf(m, "GuC last action error code: %d\n", guc.action_err); |
| 2542 | |
| 2543 | seq_printf(m, "\nGuC submissions:\n"); |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 2544 | for_each_engine(engine, dev_priv) { |
Alex Dai | 397097b | 2016-01-23 11:58:14 -0800 | [diff] [blame] | 2545 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2546 | engine->name, guc.submissions[engine->guc_id], |
| 2547 | guc.last_seqno[engine->guc_id]); |
| 2548 | total += guc.submissions[engine->guc_id]; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2549 | } |
| 2550 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2551 | |
| 2552 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client); |
| 2553 | i915_guc_client_info(m, dev_priv, &client); |
| 2554 | |
| 2555 | /* Add more as required ... */ |
| 2556 | |
| 2557 | return 0; |
| 2558 | } |
| 2559 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2560 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2561 | { |
| 2562 | struct drm_info_node *node = m->private; |
| 2563 | struct drm_device *dev = node->minor->dev; |
| 2564 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2565 | struct drm_i915_gem_object *log_obj = dev_priv->guc.log_obj; |
| 2566 | u32 *log; |
| 2567 | int i = 0, pg; |
| 2568 | |
| 2569 | if (!log_obj) |
| 2570 | return 0; |
| 2571 | |
| 2572 | for (pg = 0; pg < log_obj->base.size / PAGE_SIZE; pg++) { |
| 2573 | log = kmap_atomic(i915_gem_object_get_page(log_obj, pg)); |
| 2574 | |
| 2575 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2576 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2577 | *(log + i), *(log + i + 1), |
| 2578 | *(log + i + 2), *(log + i + 3)); |
| 2579 | |
| 2580 | kunmap_atomic(log); |
| 2581 | } |
| 2582 | |
| 2583 | seq_putc(m, '\n'); |
| 2584 | |
| 2585 | return 0; |
| 2586 | } |
| 2587 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2588 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2589 | { |
| 2590 | struct drm_info_node *node = m->private; |
| 2591 | struct drm_device *dev = node->minor->dev; |
| 2592 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2593 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2594 | u32 stat[3]; |
| 2595 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2596 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2597 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2598 | if (!HAS_PSR(dev)) { |
| 2599 | seq_puts(m, "PSR not supported\n"); |
| 2600 | return 0; |
| 2601 | } |
| 2602 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2603 | intel_runtime_pm_get(dev_priv); |
| 2604 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2605 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2606 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2607 | 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] | 2608 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2609 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2610 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2611 | dev_priv->psr.busy_frontbuffer_bits); |
| 2612 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2613 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2614 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2615 | if (HAS_DDI(dev)) |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2616 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2617 | else { |
| 2618 | for_each_pipe(dev_priv, pipe) { |
| 2619 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2620 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2621 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2622 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2623 | enabled = true; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2624 | } |
| 2625 | } |
Rodrigo Vivi | 60e5ffe | 2016-02-01 12:02:07 -0800 | [diff] [blame] | 2626 | |
| 2627 | seq_printf(m, "Main link in standby mode: %s\n", |
| 2628 | yesno(dev_priv->psr.link_standby)); |
| 2629 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2630 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2631 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2632 | if (!HAS_DDI(dev)) |
| 2633 | for_each_pipe(dev_priv, pipe) { |
| 2634 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2635 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2636 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2637 | } |
| 2638 | seq_puts(m, "\n"); |
| 2639 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2640 | /* |
| 2641 | * VLV/CHV PSR has no kind of performance counter |
| 2642 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2643 | */ |
| 2644 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2645 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2646 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2647 | |
| 2648 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2649 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2650 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2651 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2652 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2653 | return 0; |
| 2654 | } |
| 2655 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2656 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2657 | { |
| 2658 | struct drm_info_node *node = m->private; |
| 2659 | struct drm_device *dev = node->minor->dev; |
| 2660 | struct intel_encoder *encoder; |
| 2661 | struct intel_connector *connector; |
| 2662 | struct intel_dp *intel_dp = NULL; |
| 2663 | int ret; |
| 2664 | u8 crc[6]; |
| 2665 | |
| 2666 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2667 | for_each_intel_connector(dev, connector) { |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2668 | |
| 2669 | if (connector->base.dpms != DRM_MODE_DPMS_ON) |
| 2670 | continue; |
| 2671 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2672 | if (!connector->base.encoder) |
| 2673 | continue; |
| 2674 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2675 | encoder = to_intel_encoder(connector->base.encoder); |
| 2676 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 2677 | continue; |
| 2678 | |
| 2679 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 2680 | |
| 2681 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2682 | if (ret) |
| 2683 | goto out; |
| 2684 | |
| 2685 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2686 | crc[0], crc[1], crc[2], |
| 2687 | crc[3], crc[4], crc[5]); |
| 2688 | goto out; |
| 2689 | } |
| 2690 | ret = -ENODEV; |
| 2691 | out: |
| 2692 | drm_modeset_unlock_all(dev); |
| 2693 | return ret; |
| 2694 | } |
| 2695 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2696 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2697 | { |
| 2698 | struct drm_info_node *node = m->private; |
| 2699 | struct drm_device *dev = node->minor->dev; |
| 2700 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2701 | u64 power; |
| 2702 | u32 units; |
| 2703 | |
| 2704 | if (INTEL_INFO(dev)->gen < 6) |
| 2705 | return -ENODEV; |
| 2706 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2707 | intel_runtime_pm_get(dev_priv); |
| 2708 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2709 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2710 | power = (power & 0x1f00) >> 8; |
| 2711 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2712 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2713 | power *= units; |
| 2714 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2715 | intel_runtime_pm_put(dev_priv); |
| 2716 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2717 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2718 | |
| 2719 | return 0; |
| 2720 | } |
| 2721 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2722 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2723 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2724 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2725 | struct drm_device *dev = node->minor->dev; |
| 2726 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2727 | |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2728 | if (!HAS_RUNTIME_PM(dev_priv)) |
| 2729 | seq_puts(m, "Runtime power management not supported\n"); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2730 | |
Paulo Zanoni | 86c4ec0 | 2014-02-21 13:52:24 -0300 | [diff] [blame] | 2731 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2732 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2733 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2734 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2735 | seq_printf(m, "Usage count: %d\n", |
| 2736 | atomic_read(&dev->dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2737 | #else |
| 2738 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2739 | #endif |
Chris Wilson | a156e64 | 2016-04-03 14:14:21 +0100 | [diff] [blame] | 2740 | seq_printf(m, "PCI device power state: %s [%d]\n", |
| 2741 | pci_power_name(dev_priv->dev->pdev->current_state), |
| 2742 | dev_priv->dev->pdev->current_state); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2743 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2744 | return 0; |
| 2745 | } |
| 2746 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2747 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2748 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2749 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2750 | struct drm_device *dev = node->minor->dev; |
| 2751 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2752 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2753 | int i; |
| 2754 | |
| 2755 | mutex_lock(&power_domains->lock); |
| 2756 | |
| 2757 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2758 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2759 | struct i915_power_well *power_well; |
| 2760 | enum intel_display_power_domain power_domain; |
| 2761 | |
| 2762 | power_well = &power_domains->power_wells[i]; |
| 2763 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2764 | power_well->count); |
| 2765 | |
| 2766 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2767 | power_domain++) { |
| 2768 | if (!(BIT(power_domain) & power_well->domains)) |
| 2769 | continue; |
| 2770 | |
| 2771 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2772 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2773 | power_domains->domain_use_count[power_domain]); |
| 2774 | } |
| 2775 | } |
| 2776 | |
| 2777 | mutex_unlock(&power_domains->lock); |
| 2778 | |
| 2779 | return 0; |
| 2780 | } |
| 2781 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2782 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2783 | { |
| 2784 | struct drm_info_node *node = m->private; |
| 2785 | struct drm_device *dev = node->minor->dev; |
| 2786 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2787 | struct intel_csr *csr; |
| 2788 | |
| 2789 | if (!HAS_CSR(dev)) { |
| 2790 | seq_puts(m, "not supported\n"); |
| 2791 | return 0; |
| 2792 | } |
| 2793 | |
| 2794 | csr = &dev_priv->csr; |
| 2795 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2796 | intel_runtime_pm_get(dev_priv); |
| 2797 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2798 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2799 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2800 | |
| 2801 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2802 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2803 | |
| 2804 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2805 | CSR_VERSION_MINOR(csr->version)); |
| 2806 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2807 | if (IS_SKYLAKE(dev) && csr->version >= CSR_VERSION(1, 6)) { |
| 2808 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2809 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2810 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2811 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2812 | } else if (IS_BROXTON(dev) && csr->version >= CSR_VERSION(1, 4)) { |
| 2813 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2814 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2815 | } |
| 2816 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2817 | out: |
| 2818 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2819 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2820 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2821 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2822 | intel_runtime_pm_put(dev_priv); |
| 2823 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2824 | return 0; |
| 2825 | } |
| 2826 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2827 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2828 | struct drm_display_mode *mode) |
| 2829 | { |
| 2830 | int i; |
| 2831 | |
| 2832 | for (i = 0; i < tabs; i++) |
| 2833 | seq_putc(m, '\t'); |
| 2834 | |
| 2835 | 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", |
| 2836 | mode->base.id, mode->name, |
| 2837 | mode->vrefresh, mode->clock, |
| 2838 | mode->hdisplay, mode->hsync_start, |
| 2839 | mode->hsync_end, mode->htotal, |
| 2840 | mode->vdisplay, mode->vsync_start, |
| 2841 | mode->vsync_end, mode->vtotal, |
| 2842 | mode->type, mode->flags); |
| 2843 | } |
| 2844 | |
| 2845 | static void intel_encoder_info(struct seq_file *m, |
| 2846 | struct intel_crtc *intel_crtc, |
| 2847 | struct intel_encoder *intel_encoder) |
| 2848 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2849 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2850 | struct drm_device *dev = node->minor->dev; |
| 2851 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2852 | struct intel_connector *intel_connector; |
| 2853 | struct drm_encoder *encoder; |
| 2854 | |
| 2855 | encoder = &intel_encoder->base; |
| 2856 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2857 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2858 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2859 | struct drm_connector *connector = &intel_connector->base; |
| 2860 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2861 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2862 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2863 | drm_get_connector_status_name(connector->status)); |
| 2864 | if (connector->status == connector_status_connected) { |
| 2865 | struct drm_display_mode *mode = &crtc->mode; |
| 2866 | seq_printf(m, ", mode:\n"); |
| 2867 | intel_seq_print_mode(m, 2, mode); |
| 2868 | } else { |
| 2869 | seq_putc(m, '\n'); |
| 2870 | } |
| 2871 | } |
| 2872 | } |
| 2873 | |
| 2874 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2875 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2876 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2877 | struct drm_device *dev = node->minor->dev; |
| 2878 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2879 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2880 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2881 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2882 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2883 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2884 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2885 | fb->base.id, plane_state->src_x >> 16, |
| 2886 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2887 | else |
| 2888 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2889 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2890 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2891 | } |
| 2892 | |
| 2893 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2894 | { |
| 2895 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2896 | |
| 2897 | seq_printf(m, "\tfixed mode:\n"); |
| 2898 | intel_seq_print_mode(m, 2, mode); |
| 2899 | } |
| 2900 | |
| 2901 | static void intel_dp_info(struct seq_file *m, |
| 2902 | struct intel_connector *intel_connector) |
| 2903 | { |
| 2904 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2905 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2906 | |
| 2907 | 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] | 2908 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2909 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2910 | intel_panel_info(m, &intel_connector->panel); |
| 2911 | } |
| 2912 | |
| 2913 | static void intel_hdmi_info(struct seq_file *m, |
| 2914 | struct intel_connector *intel_connector) |
| 2915 | { |
| 2916 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2917 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2918 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2919 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2920 | } |
| 2921 | |
| 2922 | static void intel_lvds_info(struct seq_file *m, |
| 2923 | struct intel_connector *intel_connector) |
| 2924 | { |
| 2925 | intel_panel_info(m, &intel_connector->panel); |
| 2926 | } |
| 2927 | |
| 2928 | static void intel_connector_info(struct seq_file *m, |
| 2929 | struct drm_connector *connector) |
| 2930 | { |
| 2931 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2932 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2933 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2934 | |
| 2935 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2936 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2937 | drm_get_connector_status_name(connector->status)); |
| 2938 | if (connector->status == connector_status_connected) { |
| 2939 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2940 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2941 | connector->display_info.width_mm, |
| 2942 | connector->display_info.height_mm); |
| 2943 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2944 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2945 | seq_printf(m, "\tCEA rev: %d\n", |
| 2946 | connector->display_info.cea_rev); |
| 2947 | } |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2948 | if (intel_encoder) { |
| 2949 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2950 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2951 | intel_dp_info(m, intel_connector); |
| 2952 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2953 | intel_hdmi_info(m, intel_connector); |
| 2954 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2955 | intel_lvds_info(m, intel_connector); |
| 2956 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2957 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2958 | seq_printf(m, "\tmodes:\n"); |
| 2959 | list_for_each_entry(mode, &connector->modes, head) |
| 2960 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2961 | } |
| 2962 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2963 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 2964 | { |
| 2965 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2966 | u32 state; |
| 2967 | |
| 2968 | if (IS_845G(dev) || IS_I865G(dev)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 2969 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2970 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2971 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2972 | |
| 2973 | return state; |
| 2974 | } |
| 2975 | |
| 2976 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 2977 | { |
| 2978 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2979 | u32 pos; |
| 2980 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2981 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2982 | |
| 2983 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2984 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2985 | *x = -*x; |
| 2986 | |
| 2987 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2988 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2989 | *y = -*y; |
| 2990 | |
| 2991 | return cursor_active(dev, pipe); |
| 2992 | } |
| 2993 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2994 | static const char *plane_type(enum drm_plane_type type) |
| 2995 | { |
| 2996 | switch (type) { |
| 2997 | case DRM_PLANE_TYPE_OVERLAY: |
| 2998 | return "OVL"; |
| 2999 | case DRM_PLANE_TYPE_PRIMARY: |
| 3000 | return "PRI"; |
| 3001 | case DRM_PLANE_TYPE_CURSOR: |
| 3002 | return "CUR"; |
| 3003 | /* |
| 3004 | * Deliberately omitting default: to generate compiler warnings |
| 3005 | * when a new drm_plane_type gets added. |
| 3006 | */ |
| 3007 | } |
| 3008 | |
| 3009 | return "unknown"; |
| 3010 | } |
| 3011 | |
| 3012 | static const char *plane_rotation(unsigned int rotation) |
| 3013 | { |
| 3014 | static char buf[48]; |
| 3015 | /* |
| 3016 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 3017 | * will print them all to visualize if the values are misused |
| 3018 | */ |
| 3019 | snprintf(buf, sizeof(buf), |
| 3020 | "%s%s%s%s%s%s(0x%08x)", |
| 3021 | (rotation & BIT(DRM_ROTATE_0)) ? "0 " : "", |
| 3022 | (rotation & BIT(DRM_ROTATE_90)) ? "90 " : "", |
| 3023 | (rotation & BIT(DRM_ROTATE_180)) ? "180 " : "", |
| 3024 | (rotation & BIT(DRM_ROTATE_270)) ? "270 " : "", |
| 3025 | (rotation & BIT(DRM_REFLECT_X)) ? "FLIPX " : "", |
| 3026 | (rotation & BIT(DRM_REFLECT_Y)) ? "FLIPY " : "", |
| 3027 | rotation); |
| 3028 | |
| 3029 | return buf; |
| 3030 | } |
| 3031 | |
| 3032 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3033 | { |
| 3034 | struct drm_info_node *node = m->private; |
| 3035 | struct drm_device *dev = node->minor->dev; |
| 3036 | struct intel_plane *intel_plane; |
| 3037 | |
| 3038 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 3039 | struct drm_plane_state *state; |
| 3040 | struct drm_plane *plane = &intel_plane->base; |
| 3041 | |
| 3042 | if (!plane->state) { |
| 3043 | seq_puts(m, "plane->state is NULL!\n"); |
| 3044 | continue; |
| 3045 | } |
| 3046 | |
| 3047 | state = plane->state; |
| 3048 | |
| 3049 | 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", |
| 3050 | plane->base.id, |
| 3051 | plane_type(intel_plane->base.type), |
| 3052 | state->crtc_x, state->crtc_y, |
| 3053 | state->crtc_w, state->crtc_h, |
| 3054 | (state->src_x >> 16), |
| 3055 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 3056 | (state->src_y >> 16), |
| 3057 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 3058 | (state->src_w >> 16), |
| 3059 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3060 | (state->src_h >> 16), |
| 3061 | ((state->src_h & 0xffff) * 15625) >> 10, |
| 3062 | state->fb ? drm_get_format_name(state->fb->pixel_format) : "N/A", |
| 3063 | plane_rotation(state->rotation)); |
| 3064 | } |
| 3065 | } |
| 3066 | |
| 3067 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3068 | { |
| 3069 | struct intel_crtc_state *pipe_config; |
| 3070 | int num_scalers = intel_crtc->num_scalers; |
| 3071 | int i; |
| 3072 | |
| 3073 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3074 | |
| 3075 | /* Not all platformas have a scaler */ |
| 3076 | if (num_scalers) { |
| 3077 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3078 | num_scalers, |
| 3079 | pipe_config->scaler_state.scaler_users, |
| 3080 | pipe_config->scaler_state.scaler_id); |
| 3081 | |
| 3082 | for (i = 0; i < SKL_NUM_SCALERS; i++) { |
| 3083 | struct intel_scaler *sc = |
| 3084 | &pipe_config->scaler_state.scalers[i]; |
| 3085 | |
| 3086 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3087 | i, yesno(sc->in_use), sc->mode); |
| 3088 | } |
| 3089 | seq_puts(m, "\n"); |
| 3090 | } else { |
| 3091 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3092 | } |
| 3093 | } |
| 3094 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3095 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3096 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 3097 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3098 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3099 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3100 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3101 | struct drm_connector *connector; |
| 3102 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3103 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3104 | drm_modeset_lock_all(dev); |
| 3105 | seq_printf(m, "CRTC info\n"); |
| 3106 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3107 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3108 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3109 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3110 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3111 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3112 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3113 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3114 | 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] | 3115 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3116 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3117 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3118 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3119 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3120 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3121 | intel_crtc_info(m, crtc); |
| 3122 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3123 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3124 | 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] | 3125 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3126 | x, y, crtc->base.cursor->state->crtc_w, |
| 3127 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3128 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3129 | intel_scaler_info(m, crtc); |
| 3130 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3131 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3132 | |
| 3133 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3134 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3135 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3136 | } |
| 3137 | |
| 3138 | seq_printf(m, "\n"); |
| 3139 | seq_printf(m, "Connector info\n"); |
| 3140 | seq_printf(m, "--------------\n"); |
| 3141 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3142 | intel_connector_info(m, connector); |
| 3143 | } |
| 3144 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3145 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3146 | |
| 3147 | return 0; |
| 3148 | } |
| 3149 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3150 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3151 | { |
| 3152 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3153 | struct drm_device *dev = node->minor->dev; |
| 3154 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3155 | struct intel_engine_cs *engine; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3156 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3157 | enum intel_engine_id id; |
| 3158 | int j, ret; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3159 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame^] | 3160 | if (!i915_semaphore_is_enabled(dev_priv)) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3161 | seq_puts(m, "Semaphores are disabled\n"); |
| 3162 | return 0; |
| 3163 | } |
| 3164 | |
| 3165 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3166 | if (ret) |
| 3167 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3168 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3169 | |
| 3170 | if (IS_BROADWELL(dev)) { |
| 3171 | struct page *page; |
| 3172 | uint64_t *seqno; |
| 3173 | |
| 3174 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 3175 | |
| 3176 | seqno = (uint64_t *)kmap_atomic(page); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3177 | for_each_engine_id(engine, dev_priv, id) { |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3178 | uint64_t offset; |
| 3179 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3180 | seq_printf(m, "%s\n", engine->name); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3181 | |
| 3182 | seq_puts(m, " Last signal:"); |
| 3183 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3184 | offset = id * I915_NUM_ENGINES + j; |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3185 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3186 | seqno[offset], offset * 8); |
| 3187 | } |
| 3188 | seq_putc(m, '\n'); |
| 3189 | |
| 3190 | seq_puts(m, " Last wait: "); |
| 3191 | for (j = 0; j < num_rings; j++) { |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3192 | offset = id + (j * I915_NUM_ENGINES); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3193 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3194 | seqno[offset], offset * 8); |
| 3195 | } |
| 3196 | seq_putc(m, '\n'); |
| 3197 | |
| 3198 | } |
| 3199 | kunmap_atomic(seqno); |
| 3200 | } else { |
| 3201 | seq_puts(m, " Last signal:"); |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 3202 | for_each_engine(engine, dev_priv) |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3203 | for (j = 0; j < num_rings; j++) |
| 3204 | seq_printf(m, "0x%08x\n", |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3205 | I915_READ(engine->semaphore.mbox.signal[j])); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3206 | seq_putc(m, '\n'); |
| 3207 | } |
| 3208 | |
| 3209 | seq_puts(m, "\nSync seqno:\n"); |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 3210 | for_each_engine(engine, dev_priv) { |
| 3211 | for (j = 0; j < num_rings; j++) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3212 | seq_printf(m, " 0x%08x ", |
| 3213 | engine->semaphore.sync_seqno[j]); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3214 | seq_putc(m, '\n'); |
| 3215 | } |
| 3216 | seq_putc(m, '\n'); |
| 3217 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3218 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3219 | mutex_unlock(&dev->struct_mutex); |
| 3220 | return 0; |
| 3221 | } |
| 3222 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3223 | static int i915_shared_dplls_info(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; |
| 3227 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3228 | int i; |
| 3229 | |
| 3230 | drm_modeset_lock_all(dev); |
| 3231 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3232 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3233 | |
| 3234 | 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] | 3235 | seq_printf(m, " crtc_mask: 0x%08x, active: 0x%x, on: %s\n", |
| 3236 | pll->config.crtc_mask, pll->active_mask, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3237 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3238 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 3239 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 3240 | pll->config.hw_state.dpll_md); |
| 3241 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 3242 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 3243 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3244 | } |
| 3245 | drm_modeset_unlock_all(dev); |
| 3246 | |
| 3247 | return 0; |
| 3248 | } |
| 3249 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3250 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3251 | { |
| 3252 | int i; |
| 3253 | int ret; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3254 | struct intel_engine_cs *engine; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3255 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3256 | struct drm_device *dev = node->minor->dev; |
| 3257 | struct drm_i915_private *dev_priv = dev->dev_private; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3258 | struct i915_workarounds *workarounds = &dev_priv->workarounds; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3259 | enum intel_engine_id id; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3260 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3261 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3262 | if (ret) |
| 3263 | return ret; |
| 3264 | |
| 3265 | intel_runtime_pm_get(dev_priv); |
| 3266 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3267 | seq_printf(m, "Workarounds applied: %d\n", workarounds->count); |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3268 | for_each_engine_id(engine, dev_priv, id) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3269 | seq_printf(m, "HW whitelist count for %s: %d\n", |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 3270 | engine->name, workarounds->hw_whitelist_count[id]); |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3271 | for (i = 0; i < workarounds->count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3272 | i915_reg_t addr; |
| 3273 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3274 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3275 | |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 3276 | addr = workarounds->reg[i].addr; |
| 3277 | mask = workarounds->reg[i].mask; |
| 3278 | value = workarounds->reg[i].value; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3279 | read = I915_READ(addr); |
| 3280 | ok = (value & mask) == (read & mask); |
| 3281 | 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] | 3282 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3283 | } |
| 3284 | |
| 3285 | intel_runtime_pm_put(dev_priv); |
| 3286 | mutex_unlock(&dev->struct_mutex); |
| 3287 | |
| 3288 | return 0; |
| 3289 | } |
| 3290 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3291 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3292 | { |
| 3293 | struct drm_info_node *node = m->private; |
| 3294 | struct drm_device *dev = node->minor->dev; |
| 3295 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3296 | struct skl_ddb_allocation *ddb; |
| 3297 | struct skl_ddb_entry *entry; |
| 3298 | enum pipe pipe; |
| 3299 | int plane; |
| 3300 | |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3301 | if (INTEL_INFO(dev)->gen < 9) |
| 3302 | return 0; |
| 3303 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3304 | drm_modeset_lock_all(dev); |
| 3305 | |
| 3306 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3307 | |
| 3308 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3309 | |
| 3310 | for_each_pipe(dev_priv, pipe) { |
| 3311 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3312 | |
Damien Lespiau | dd74078 | 2015-02-28 14:54:08 +0000 | [diff] [blame] | 3313 | for_each_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3314 | entry = &ddb->plane[pipe][plane]; |
| 3315 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3316 | entry->start, entry->end, |
| 3317 | skl_ddb_entry_size(entry)); |
| 3318 | } |
| 3319 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3320 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3321 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3322 | entry->end, skl_ddb_entry_size(entry)); |
| 3323 | } |
| 3324 | |
| 3325 | drm_modeset_unlock_all(dev); |
| 3326 | |
| 3327 | return 0; |
| 3328 | } |
| 3329 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3330 | static void drrs_status_per_crtc(struct seq_file *m, |
| 3331 | struct drm_device *dev, struct intel_crtc *intel_crtc) |
| 3332 | { |
| 3333 | struct intel_encoder *intel_encoder; |
| 3334 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3335 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3336 | int vrefresh = 0; |
| 3337 | |
| 3338 | for_each_encoder_on_crtc(dev, &intel_crtc->base, intel_encoder) { |
| 3339 | /* Encoder connected on this CRTC */ |
| 3340 | switch (intel_encoder->type) { |
| 3341 | case INTEL_OUTPUT_EDP: |
| 3342 | seq_puts(m, "eDP:\n"); |
| 3343 | break; |
| 3344 | case INTEL_OUTPUT_DSI: |
| 3345 | seq_puts(m, "DSI:\n"); |
| 3346 | break; |
| 3347 | case INTEL_OUTPUT_HDMI: |
| 3348 | seq_puts(m, "HDMI:\n"); |
| 3349 | break; |
| 3350 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3351 | seq_puts(m, "DP:\n"); |
| 3352 | break; |
| 3353 | default: |
| 3354 | seq_printf(m, "Other encoder (id=%d).\n", |
| 3355 | intel_encoder->type); |
| 3356 | return; |
| 3357 | } |
| 3358 | } |
| 3359 | |
| 3360 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3361 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3362 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3363 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3364 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3365 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3366 | else |
| 3367 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3368 | |
| 3369 | seq_puts(m, "\n\n"); |
| 3370 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3371 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3372 | struct intel_panel *panel; |
| 3373 | |
| 3374 | mutex_lock(&drrs->mutex); |
| 3375 | /* DRRS Supported */ |
| 3376 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3377 | |
| 3378 | /* disable_drrs() will make drrs->dp NULL */ |
| 3379 | if (!drrs->dp) { |
| 3380 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3381 | mutex_unlock(&drrs->mutex); |
| 3382 | return; |
| 3383 | } |
| 3384 | |
| 3385 | panel = &drrs->dp->attached_connector->panel; |
| 3386 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3387 | drrs->busy_frontbuffer_bits); |
| 3388 | |
| 3389 | seq_puts(m, "\n\t\t"); |
| 3390 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3391 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3392 | vrefresh = panel->fixed_mode->vrefresh; |
| 3393 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3394 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3395 | vrefresh = panel->downclock_mode->vrefresh; |
| 3396 | } else { |
| 3397 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3398 | drrs->refresh_rate_type); |
| 3399 | mutex_unlock(&drrs->mutex); |
| 3400 | return; |
| 3401 | } |
| 3402 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3403 | |
| 3404 | seq_puts(m, "\n\t\t"); |
| 3405 | mutex_unlock(&drrs->mutex); |
| 3406 | } else { |
| 3407 | /* DRRS not supported. Print the VBT parameter*/ |
| 3408 | seq_puts(m, "\tDRRS Supported : No"); |
| 3409 | } |
| 3410 | seq_puts(m, "\n"); |
| 3411 | } |
| 3412 | |
| 3413 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3414 | { |
| 3415 | struct drm_info_node *node = m->private; |
| 3416 | struct drm_device *dev = node->minor->dev; |
| 3417 | struct intel_crtc *intel_crtc; |
| 3418 | int active_crtc_cnt = 0; |
| 3419 | |
| 3420 | for_each_intel_crtc(dev, intel_crtc) { |
| 3421 | drm_modeset_lock(&intel_crtc->base.mutex, NULL); |
| 3422 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3423 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3424 | active_crtc_cnt++; |
| 3425 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3426 | |
| 3427 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3428 | } |
| 3429 | |
| 3430 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 3431 | } |
| 3432 | |
| 3433 | if (!active_crtc_cnt) |
| 3434 | seq_puts(m, "No active crtc found\n"); |
| 3435 | |
| 3436 | return 0; |
| 3437 | } |
| 3438 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3439 | struct pipe_crc_info { |
| 3440 | const char *name; |
| 3441 | struct drm_device *dev; |
| 3442 | enum pipe pipe; |
| 3443 | }; |
| 3444 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3445 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3446 | { |
| 3447 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3448 | struct drm_device *dev = node->minor->dev; |
| 3449 | struct drm_encoder *encoder; |
| 3450 | struct intel_encoder *intel_encoder; |
| 3451 | struct intel_digital_port *intel_dig_port; |
| 3452 | drm_modeset_lock_all(dev); |
| 3453 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 3454 | intel_encoder = to_intel_encoder(encoder); |
| 3455 | if (intel_encoder->type != INTEL_OUTPUT_DISPLAYPORT) |
| 3456 | continue; |
| 3457 | intel_dig_port = enc_to_dig_port(encoder); |
| 3458 | if (!intel_dig_port->dp.can_mst) |
| 3459 | continue; |
| 3460 | |
| 3461 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3462 | } |
| 3463 | drm_modeset_unlock_all(dev); |
| 3464 | return 0; |
| 3465 | } |
| 3466 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3467 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3468 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3469 | struct pipe_crc_info *info = inode->i_private; |
| 3470 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 3471 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3472 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 3473 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 3474 | return -ENODEV; |
| 3475 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3476 | spin_lock_irq(&pipe_crc->lock); |
| 3477 | |
| 3478 | if (pipe_crc->opened) { |
| 3479 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3480 | return -EBUSY; /* already open */ |
| 3481 | } |
| 3482 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3483 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3484 | filep->private_data = inode->i_private; |
| 3485 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3486 | spin_unlock_irq(&pipe_crc->lock); |
| 3487 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3488 | return 0; |
| 3489 | } |
| 3490 | |
| 3491 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 3492 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3493 | struct pipe_crc_info *info = inode->i_private; |
| 3494 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 3495 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3496 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3497 | spin_lock_irq(&pipe_crc->lock); |
| 3498 | pipe_crc->opened = false; |
| 3499 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3500 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3501 | return 0; |
| 3502 | } |
| 3503 | |
| 3504 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 3505 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 3506 | /* account for \'0' */ |
| 3507 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 3508 | |
| 3509 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 3510 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3511 | assert_spin_locked(&pipe_crc->lock); |
| 3512 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3513 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3514 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3515 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3516 | static ssize_t |
| 3517 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 3518 | loff_t *pos) |
| 3519 | { |
| 3520 | struct pipe_crc_info *info = filep->private_data; |
| 3521 | struct drm_device *dev = info->dev; |
| 3522 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3523 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3524 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3525 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3526 | ssize_t bytes_read; |
| 3527 | |
| 3528 | /* |
| 3529 | * Don't allow user space to provide buffers not big enough to hold |
| 3530 | * a line of data. |
| 3531 | */ |
| 3532 | if (count < PIPE_CRC_LINE_LEN) |
| 3533 | return -EINVAL; |
| 3534 | |
| 3535 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 3536 | return 0; |
| 3537 | |
| 3538 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3539 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3540 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3541 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3542 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3543 | if (filep->f_flags & O_NONBLOCK) { |
| 3544 | spin_unlock_irq(&pipe_crc->lock); |
| 3545 | return -EAGAIN; |
| 3546 | } |
| 3547 | |
| 3548 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 3549 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 3550 | if (ret) { |
| 3551 | spin_unlock_irq(&pipe_crc->lock); |
| 3552 | return ret; |
| 3553 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3554 | } |
| 3555 | |
| 3556 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3557 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3558 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3559 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3560 | while (n_entries > 0) { |
| 3561 | struct intel_pipe_crc_entry *entry = |
| 3562 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3563 | int ret; |
| 3564 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3565 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3566 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3567 | break; |
| 3568 | |
| 3569 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3570 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3571 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3572 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3573 | "%8u %8x %8x %8x %8x %8x\n", |
| 3574 | entry->frame, entry->crc[0], |
| 3575 | entry->crc[1], entry->crc[2], |
| 3576 | entry->crc[3], entry->crc[4]); |
| 3577 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3578 | spin_unlock_irq(&pipe_crc->lock); |
| 3579 | |
| 3580 | ret = copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3581 | if (ret == PIPE_CRC_LINE_LEN) |
| 3582 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3583 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3584 | user_buf += PIPE_CRC_LINE_LEN; |
| 3585 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3586 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3587 | spin_lock_irq(&pipe_crc->lock); |
| 3588 | } |
| 3589 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3590 | spin_unlock_irq(&pipe_crc->lock); |
| 3591 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3592 | return bytes_read; |
| 3593 | } |
| 3594 | |
| 3595 | static const struct file_operations i915_pipe_crc_fops = { |
| 3596 | .owner = THIS_MODULE, |
| 3597 | .open = i915_pipe_crc_open, |
| 3598 | .read = i915_pipe_crc_read, |
| 3599 | .release = i915_pipe_crc_release, |
| 3600 | }; |
| 3601 | |
| 3602 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3603 | { |
| 3604 | .name = "i915_pipe_A_crc", |
| 3605 | .pipe = PIPE_A, |
| 3606 | }, |
| 3607 | { |
| 3608 | .name = "i915_pipe_B_crc", |
| 3609 | .pipe = PIPE_B, |
| 3610 | }, |
| 3611 | { |
| 3612 | .name = "i915_pipe_C_crc", |
| 3613 | .pipe = PIPE_C, |
| 3614 | }, |
| 3615 | }; |
| 3616 | |
| 3617 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3618 | enum pipe pipe) |
| 3619 | { |
| 3620 | struct drm_device *dev = minor->dev; |
| 3621 | struct dentry *ent; |
| 3622 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3623 | |
| 3624 | info->dev = dev; |
| 3625 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3626 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3627 | if (!ent) |
| 3628 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3629 | |
| 3630 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3631 | } |
| 3632 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3633 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3634 | "none", |
| 3635 | "plane1", |
| 3636 | "plane2", |
| 3637 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3638 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3639 | "TV", |
| 3640 | "DP-B", |
| 3641 | "DP-C", |
| 3642 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3643 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3644 | }; |
| 3645 | |
| 3646 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3647 | { |
| 3648 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3649 | return pipe_crc_sources[source]; |
| 3650 | } |
| 3651 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3652 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3653 | { |
| 3654 | struct drm_device *dev = m->private; |
| 3655 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3656 | int i; |
| 3657 | |
| 3658 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3659 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3660 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3661 | |
| 3662 | return 0; |
| 3663 | } |
| 3664 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3665 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3666 | { |
| 3667 | struct drm_device *dev = inode->i_private; |
| 3668 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3669 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3670 | } |
| 3671 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3672 | 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] | 3673 | uint32_t *val) |
| 3674 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3675 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3676 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3677 | |
| 3678 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3679 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3680 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3681 | break; |
| 3682 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3683 | *val = 0; |
| 3684 | break; |
| 3685 | default: |
| 3686 | return -EINVAL; |
| 3687 | } |
| 3688 | |
| 3689 | return 0; |
| 3690 | } |
| 3691 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3692 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 3693 | enum intel_pipe_crc_source *source) |
| 3694 | { |
| 3695 | struct intel_encoder *encoder; |
| 3696 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3697 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3698 | int ret = 0; |
| 3699 | |
| 3700 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3701 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3702 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3703 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3704 | if (!encoder->base.crtc) |
| 3705 | continue; |
| 3706 | |
| 3707 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3708 | |
| 3709 | if (crtc->pipe != pipe) |
| 3710 | continue; |
| 3711 | |
| 3712 | switch (encoder->type) { |
| 3713 | case INTEL_OUTPUT_TVOUT: |
| 3714 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3715 | break; |
| 3716 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3717 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3718 | dig_port = enc_to_dig_port(&encoder->base); |
| 3719 | switch (dig_port->port) { |
| 3720 | case PORT_B: |
| 3721 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3722 | break; |
| 3723 | case PORT_C: |
| 3724 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3725 | break; |
| 3726 | case PORT_D: |
| 3727 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3728 | break; |
| 3729 | default: |
| 3730 | WARN(1, "nonexisting DP port %c\n", |
| 3731 | port_name(dig_port->port)); |
| 3732 | break; |
| 3733 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3734 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3735 | default: |
| 3736 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3737 | } |
| 3738 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3739 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3740 | |
| 3741 | return ret; |
| 3742 | } |
| 3743 | |
| 3744 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3745 | enum pipe pipe, |
| 3746 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3747 | uint32_t *val) |
| 3748 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3749 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3750 | bool need_stable_symbols = false; |
| 3751 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3752 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3753 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3754 | if (ret) |
| 3755 | return ret; |
| 3756 | } |
| 3757 | |
| 3758 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3759 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3760 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3761 | break; |
| 3762 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3763 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3764 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3765 | break; |
| 3766 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3767 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3768 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3769 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3770 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3771 | if (!IS_CHERRYVIEW(dev)) |
| 3772 | return -EINVAL; |
| 3773 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3774 | need_stable_symbols = true; |
| 3775 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3776 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3777 | *val = 0; |
| 3778 | break; |
| 3779 | default: |
| 3780 | return -EINVAL; |
| 3781 | } |
| 3782 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3783 | /* |
| 3784 | * When the pipe CRC tap point is after the transcoders we need |
| 3785 | * to tweak symbol-level features to produce a deterministic series of |
| 3786 | * symbols for a given frame. We need to reset those features only once |
| 3787 | * a frame (instead of every nth symbol): |
| 3788 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3789 | * link (SDVO) |
| 3790 | * - DisplayPort scrambling: used for EMI reduction |
| 3791 | */ |
| 3792 | if (need_stable_symbols) { |
| 3793 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3794 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3795 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3796 | switch (pipe) { |
| 3797 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3798 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3799 | break; |
| 3800 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3801 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3802 | break; |
| 3803 | case PIPE_C: |
| 3804 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3805 | break; |
| 3806 | default: |
| 3807 | return -EINVAL; |
| 3808 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3809 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3810 | } |
| 3811 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3812 | return 0; |
| 3813 | } |
| 3814 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3815 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3816 | enum pipe pipe, |
| 3817 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3818 | uint32_t *val) |
| 3819 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3820 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3821 | bool need_stable_symbols = false; |
| 3822 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3823 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3824 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3825 | if (ret) |
| 3826 | return ret; |
| 3827 | } |
| 3828 | |
| 3829 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3830 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3831 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3832 | break; |
| 3833 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 3834 | if (!SUPPORTS_TV(dev)) |
| 3835 | return -EINVAL; |
| 3836 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3837 | break; |
| 3838 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3839 | if (!IS_G4X(dev)) |
| 3840 | return -EINVAL; |
| 3841 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3842 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3843 | break; |
| 3844 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3845 | if (!IS_G4X(dev)) |
| 3846 | return -EINVAL; |
| 3847 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3848 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3849 | break; |
| 3850 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3851 | if (!IS_G4X(dev)) |
| 3852 | return -EINVAL; |
| 3853 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3854 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3855 | break; |
| 3856 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3857 | *val = 0; |
| 3858 | break; |
| 3859 | default: |
| 3860 | return -EINVAL; |
| 3861 | } |
| 3862 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3863 | /* |
| 3864 | * When the pipe CRC tap point is after the transcoders we need |
| 3865 | * to tweak symbol-level features to produce a deterministic series of |
| 3866 | * symbols for a given frame. We need to reset those features only once |
| 3867 | * a frame (instead of every nth symbol): |
| 3868 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3869 | * link (SDVO) |
| 3870 | * - DisplayPort scrambling: used for EMI reduction |
| 3871 | */ |
| 3872 | if (need_stable_symbols) { |
| 3873 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3874 | |
| 3875 | WARN_ON(!IS_G4X(dev)); |
| 3876 | |
| 3877 | I915_WRITE(PORT_DFT_I9XX, |
| 3878 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3879 | |
| 3880 | if (pipe == PIPE_A) |
| 3881 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3882 | else |
| 3883 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3884 | |
| 3885 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3886 | } |
| 3887 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3888 | return 0; |
| 3889 | } |
| 3890 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3891 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3892 | enum pipe pipe) |
| 3893 | { |
| 3894 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3895 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3896 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3897 | switch (pipe) { |
| 3898 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3899 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3900 | break; |
| 3901 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3902 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3903 | break; |
| 3904 | case PIPE_C: |
| 3905 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 3906 | break; |
| 3907 | default: |
| 3908 | return; |
| 3909 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3910 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3911 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3912 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3913 | |
| 3914 | } |
| 3915 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3916 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3917 | enum pipe pipe) |
| 3918 | { |
| 3919 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3920 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3921 | |
| 3922 | if (pipe == PIPE_A) |
| 3923 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3924 | else |
| 3925 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3926 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3927 | |
| 3928 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3929 | I915_WRITE(PORT_DFT_I9XX, |
| 3930 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3931 | } |
| 3932 | } |
| 3933 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3934 | 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] | 3935 | uint32_t *val) |
| 3936 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3937 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3938 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3939 | |
| 3940 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3941 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3942 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 3943 | break; |
| 3944 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3945 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 3946 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3947 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3948 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 3949 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3950 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3951 | *val = 0; |
| 3952 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3953 | default: |
| 3954 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3955 | } |
| 3956 | |
| 3957 | return 0; |
| 3958 | } |
| 3959 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3960 | 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] | 3961 | { |
| 3962 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3963 | struct intel_crtc *crtc = |
| 3964 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3965 | struct intel_crtc_state *pipe_config; |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3966 | struct drm_atomic_state *state; |
| 3967 | int ret = 0; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3968 | |
| 3969 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3970 | state = drm_atomic_state_alloc(dev); |
| 3971 | if (!state) { |
| 3972 | ret = -ENOMEM; |
| 3973 | goto out; |
| 3974 | } |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3975 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3976 | state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base); |
| 3977 | pipe_config = intel_atomic_get_crtc_state(state, crtc); |
| 3978 | if (IS_ERR(pipe_config)) { |
| 3979 | ret = PTR_ERR(pipe_config); |
| 3980 | goto out; |
| 3981 | } |
| 3982 | |
| 3983 | pipe_config->pch_pfit.force_thru = enable; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3984 | if (pipe_config->cpu_transcoder == TRANSCODER_EDP && |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3985 | pipe_config->pch_pfit.enabled != enable) |
| 3986 | pipe_config->base.connectors_changed = true; |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3987 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3988 | ret = drm_atomic_commit(state); |
| 3989 | out: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3990 | drm_modeset_unlock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3991 | WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret); |
| 3992 | if (ret) |
| 3993 | drm_atomic_state_free(state); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3994 | } |
| 3995 | |
| 3996 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3997 | enum pipe pipe, |
| 3998 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3999 | uint32_t *val) |
| 4000 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4001 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 4002 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 4003 | |
| 4004 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4005 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 4006 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 4007 | break; |
| 4008 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 4009 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 4010 | break; |
| 4011 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4012 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4013 | hsw_trans_edp_pipe_A_crc_wa(dev, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4014 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4015 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 4016 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4017 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4018 | *val = 0; |
| 4019 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 4020 | default: |
| 4021 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4022 | } |
| 4023 | |
| 4024 | return 0; |
| 4025 | } |
| 4026 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4027 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 4028 | enum intel_pipe_crc_source source) |
| 4029 | { |
| 4030 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4031 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4032 | struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, |
| 4033 | pipe)); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4034 | enum intel_display_power_domain power_domain; |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 4035 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4036 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4037 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4038 | if (pipe_crc->source == source) |
| 4039 | return 0; |
| 4040 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 4041 | /* forbid changing the source without going back to 'none' */ |
| 4042 | if (pipe_crc->source && source) |
| 4043 | return -EINVAL; |
| 4044 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4045 | power_domain = POWER_DOMAIN_PIPE(pipe); |
| 4046 | if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) { |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 4047 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 4048 | return -EIO; |
| 4049 | } |
| 4050 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 4051 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4052 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 4053 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4054 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4055 | else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4056 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 4057 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 4058 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4059 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4060 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4061 | |
| 4062 | if (ret != 0) |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4063 | goto out; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 4064 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4065 | /* none -> real source transition */ |
| 4066 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4067 | struct intel_pipe_crc_entry *entries; |
| 4068 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4069 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 4070 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 4071 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 4072 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 4073 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4074 | GFP_KERNEL); |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4075 | if (!entries) { |
| 4076 | ret = -ENOMEM; |
| 4077 | goto out; |
| 4078 | } |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4079 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4080 | /* |
| 4081 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 4082 | * enabled and disabled dynamically based on package C states, |
| 4083 | * user space can't make reliable use of the CRCs, so let's just |
| 4084 | * completely disable it. |
| 4085 | */ |
| 4086 | hsw_disable_ips(crtc); |
| 4087 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4088 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 4089 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4090 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4091 | pipe_crc->head = 0; |
| 4092 | pipe_crc->tail = 0; |
| 4093 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4094 | } |
| 4095 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4096 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4097 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4098 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 4099 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 4100 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4101 | /* real source -> none transition */ |
| 4102 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4103 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4104 | struct intel_crtc *crtc = |
| 4105 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4106 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4107 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 4108 | pipe_name(pipe)); |
| 4109 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4110 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4111 | if (crtc->base.state->active) |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4112 | intel_wait_for_vblank(dev, pipe); |
| 4113 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 4114 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4115 | spin_lock_irq(&pipe_crc->lock); |
| 4116 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4117 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 4118 | pipe_crc->head = 0; |
| 4119 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4120 | spin_unlock_irq(&pipe_crc->lock); |
| 4121 | |
| 4122 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4123 | |
| 4124 | if (IS_G4X(dev)) |
| 4125 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4126 | else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4127 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4128 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4129 | hsw_trans_edp_pipe_A_crc_wa(dev, false); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4130 | |
| 4131 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4132 | } |
| 4133 | |
Imre Deak | e129649 | 2016-02-12 18:55:17 +0200 | [diff] [blame] | 4134 | ret = 0; |
| 4135 | |
| 4136 | out: |
| 4137 | intel_display_power_put(dev_priv, power_domain); |
| 4138 | |
| 4139 | return ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4140 | } |
| 4141 | |
| 4142 | /* |
| 4143 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4144 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 4145 | * object: 'pipe' |
| 4146 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4147 | * source: (none | plane1 | plane2 | pf) |
| 4148 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 4149 | * |
| 4150 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4151 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 4152 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4153 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4154 | 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] | 4155 | { |
| 4156 | int n_words = 0; |
| 4157 | |
| 4158 | while (*buf) { |
| 4159 | char *end; |
| 4160 | |
| 4161 | /* skip leading white space */ |
| 4162 | buf = skip_spaces(buf); |
| 4163 | if (!*buf) |
| 4164 | break; /* end of buffer */ |
| 4165 | |
| 4166 | /* find end of word */ |
| 4167 | for (end = buf; *end && !isspace(*end); end++) |
| 4168 | ; |
| 4169 | |
| 4170 | if (n_words == max_words) { |
| 4171 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 4172 | max_words); |
| 4173 | return -EINVAL; /* ran out of words[] before bytes */ |
| 4174 | } |
| 4175 | |
| 4176 | if (*end) |
| 4177 | *end++ = '\0'; |
| 4178 | words[n_words++] = buf; |
| 4179 | buf = end; |
| 4180 | } |
| 4181 | |
| 4182 | return n_words; |
| 4183 | } |
| 4184 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4185 | enum intel_pipe_crc_object { |
| 4186 | PIPE_CRC_OBJECT_PIPE, |
| 4187 | }; |
| 4188 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 4189 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4190 | "pipe", |
| 4191 | }; |
| 4192 | |
| 4193 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4194 | 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] | 4195 | { |
| 4196 | int i; |
| 4197 | |
| 4198 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 4199 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4200 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4201 | return 0; |
| 4202 | } |
| 4203 | |
| 4204 | return -EINVAL; |
| 4205 | } |
| 4206 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4207 | 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] | 4208 | { |
| 4209 | const char name = buf[0]; |
| 4210 | |
| 4211 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 4212 | return -EINVAL; |
| 4213 | |
| 4214 | *pipe = name - 'A'; |
| 4215 | |
| 4216 | return 0; |
| 4217 | } |
| 4218 | |
| 4219 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4220 | 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] | 4221 | { |
| 4222 | int i; |
| 4223 | |
| 4224 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 4225 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4226 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4227 | return 0; |
| 4228 | } |
| 4229 | |
| 4230 | return -EINVAL; |
| 4231 | } |
| 4232 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4233 | 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] | 4234 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4235 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4236 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4237 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4238 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4239 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4240 | enum intel_pipe_crc_source source; |
| 4241 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4242 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4243 | if (n_words != N_WORDS) { |
| 4244 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 4245 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4246 | return -EINVAL; |
| 4247 | } |
| 4248 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4249 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4250 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4251 | return -EINVAL; |
| 4252 | } |
| 4253 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4254 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4255 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 4256 | return -EINVAL; |
| 4257 | } |
| 4258 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4259 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4260 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4261 | return -EINVAL; |
| 4262 | } |
| 4263 | |
| 4264 | return pipe_crc_set_source(dev, pipe, source); |
| 4265 | } |
| 4266 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4267 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 4268 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4269 | { |
| 4270 | struct seq_file *m = file->private_data; |
| 4271 | struct drm_device *dev = m->private; |
| 4272 | char *tmpbuf; |
| 4273 | int ret; |
| 4274 | |
| 4275 | if (len == 0) |
| 4276 | return 0; |
| 4277 | |
| 4278 | if (len > PAGE_SIZE - 1) { |
| 4279 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 4280 | PAGE_SIZE); |
| 4281 | return -E2BIG; |
| 4282 | } |
| 4283 | |
| 4284 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 4285 | if (!tmpbuf) |
| 4286 | return -ENOMEM; |
| 4287 | |
| 4288 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 4289 | ret = -EFAULT; |
| 4290 | goto out; |
| 4291 | } |
| 4292 | tmpbuf[len] = '\0'; |
| 4293 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4294 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4295 | |
| 4296 | out: |
| 4297 | kfree(tmpbuf); |
| 4298 | if (ret < 0) |
| 4299 | return ret; |
| 4300 | |
| 4301 | *offp += len; |
| 4302 | return len; |
| 4303 | } |
| 4304 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4305 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4306 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4307 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4308 | .read = seq_read, |
| 4309 | .llseek = seq_lseek, |
| 4310 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4311 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4312 | }; |
| 4313 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4314 | static ssize_t i915_displayport_test_active_write(struct file *file, |
| 4315 | const char __user *ubuf, |
| 4316 | size_t len, loff_t *offp) |
| 4317 | { |
| 4318 | char *input_buffer; |
| 4319 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4320 | struct drm_device *dev; |
| 4321 | struct drm_connector *connector; |
| 4322 | struct list_head *connector_list; |
| 4323 | struct intel_dp *intel_dp; |
| 4324 | int val = 0; |
| 4325 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 4326 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4327 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4328 | connector_list = &dev->mode_config.connector_list; |
| 4329 | |
| 4330 | if (len == 0) |
| 4331 | return 0; |
| 4332 | |
| 4333 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 4334 | if (!input_buffer) |
| 4335 | return -ENOMEM; |
| 4336 | |
| 4337 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 4338 | status = -EFAULT; |
| 4339 | goto out; |
| 4340 | } |
| 4341 | |
| 4342 | input_buffer[len] = '\0'; |
| 4343 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 4344 | |
| 4345 | list_for_each_entry(connector, connector_list, head) { |
| 4346 | |
| 4347 | if (connector->connector_type != |
| 4348 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4349 | continue; |
| 4350 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 4351 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4352 | connector->encoder != NULL) { |
| 4353 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4354 | status = kstrtoint(input_buffer, 10, &val); |
| 4355 | if (status < 0) |
| 4356 | goto out; |
| 4357 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 4358 | /* To prevent erroneous activation of the compliance |
| 4359 | * testing code, only accept an actual value of 1 here |
| 4360 | */ |
| 4361 | if (val == 1) |
| 4362 | intel_dp->compliance_test_active = 1; |
| 4363 | else |
| 4364 | intel_dp->compliance_test_active = 0; |
| 4365 | } |
| 4366 | } |
| 4367 | out: |
| 4368 | kfree(input_buffer); |
| 4369 | if (status < 0) |
| 4370 | return status; |
| 4371 | |
| 4372 | *offp += len; |
| 4373 | return len; |
| 4374 | } |
| 4375 | |
| 4376 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 4377 | { |
| 4378 | struct drm_device *dev = m->private; |
| 4379 | struct drm_connector *connector; |
| 4380 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4381 | struct intel_dp *intel_dp; |
| 4382 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4383 | list_for_each_entry(connector, connector_list, head) { |
| 4384 | |
| 4385 | if (connector->connector_type != |
| 4386 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4387 | continue; |
| 4388 | |
| 4389 | if (connector->status == connector_status_connected && |
| 4390 | connector->encoder != NULL) { |
| 4391 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4392 | if (intel_dp->compliance_test_active) |
| 4393 | seq_puts(m, "1"); |
| 4394 | else |
| 4395 | seq_puts(m, "0"); |
| 4396 | } else |
| 4397 | seq_puts(m, "0"); |
| 4398 | } |
| 4399 | |
| 4400 | return 0; |
| 4401 | } |
| 4402 | |
| 4403 | static int i915_displayport_test_active_open(struct inode *inode, |
| 4404 | struct file *file) |
| 4405 | { |
| 4406 | struct drm_device *dev = inode->i_private; |
| 4407 | |
| 4408 | return single_open(file, i915_displayport_test_active_show, dev); |
| 4409 | } |
| 4410 | |
| 4411 | static const struct file_operations i915_displayport_test_active_fops = { |
| 4412 | .owner = THIS_MODULE, |
| 4413 | .open = i915_displayport_test_active_open, |
| 4414 | .read = seq_read, |
| 4415 | .llseek = seq_lseek, |
| 4416 | .release = single_release, |
| 4417 | .write = i915_displayport_test_active_write |
| 4418 | }; |
| 4419 | |
| 4420 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 4421 | { |
| 4422 | struct drm_device *dev = m->private; |
| 4423 | struct drm_connector *connector; |
| 4424 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4425 | struct intel_dp *intel_dp; |
| 4426 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4427 | list_for_each_entry(connector, connector_list, head) { |
| 4428 | |
| 4429 | if (connector->connector_type != |
| 4430 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4431 | continue; |
| 4432 | |
| 4433 | if (connector->status == connector_status_connected && |
| 4434 | connector->encoder != NULL) { |
| 4435 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4436 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 4437 | } else |
| 4438 | seq_puts(m, "0"); |
| 4439 | } |
| 4440 | |
| 4441 | return 0; |
| 4442 | } |
| 4443 | static int i915_displayport_test_data_open(struct inode *inode, |
| 4444 | struct file *file) |
| 4445 | { |
| 4446 | struct drm_device *dev = inode->i_private; |
| 4447 | |
| 4448 | return single_open(file, i915_displayport_test_data_show, dev); |
| 4449 | } |
| 4450 | |
| 4451 | static const struct file_operations i915_displayport_test_data_fops = { |
| 4452 | .owner = THIS_MODULE, |
| 4453 | .open = i915_displayport_test_data_open, |
| 4454 | .read = seq_read, |
| 4455 | .llseek = seq_lseek, |
| 4456 | .release = single_release |
| 4457 | }; |
| 4458 | |
| 4459 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 4460 | { |
| 4461 | struct drm_device *dev = m->private; |
| 4462 | struct drm_connector *connector; |
| 4463 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4464 | struct intel_dp *intel_dp; |
| 4465 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4466 | list_for_each_entry(connector, connector_list, head) { |
| 4467 | |
| 4468 | if (connector->connector_type != |
| 4469 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4470 | continue; |
| 4471 | |
| 4472 | if (connector->status == connector_status_connected && |
| 4473 | connector->encoder != NULL) { |
| 4474 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4475 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 4476 | } else |
| 4477 | seq_puts(m, "0"); |
| 4478 | } |
| 4479 | |
| 4480 | return 0; |
| 4481 | } |
| 4482 | |
| 4483 | static int i915_displayport_test_type_open(struct inode *inode, |
| 4484 | struct file *file) |
| 4485 | { |
| 4486 | struct drm_device *dev = inode->i_private; |
| 4487 | |
| 4488 | return single_open(file, i915_displayport_test_type_show, dev); |
| 4489 | } |
| 4490 | |
| 4491 | static const struct file_operations i915_displayport_test_type_fops = { |
| 4492 | .owner = THIS_MODULE, |
| 4493 | .open = i915_displayport_test_type_open, |
| 4494 | .read = seq_read, |
| 4495 | .llseek = seq_lseek, |
| 4496 | .release = single_release |
| 4497 | }; |
| 4498 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4499 | 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] | 4500 | { |
| 4501 | struct drm_device *dev = m->private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4502 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4503 | int num_levels; |
| 4504 | |
| 4505 | if (IS_CHERRYVIEW(dev)) |
| 4506 | num_levels = 3; |
| 4507 | else if (IS_VALLEYVIEW(dev)) |
| 4508 | num_levels = 1; |
| 4509 | else |
| 4510 | num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4511 | |
| 4512 | drm_modeset_lock_all(dev); |
| 4513 | |
| 4514 | for (level = 0; level < num_levels; level++) { |
| 4515 | unsigned int latency = wm[level]; |
| 4516 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4517 | /* |
| 4518 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4519 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4520 | */ |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 4521 | if (INTEL_INFO(dev)->gen >= 9 || IS_VALLEYVIEW(dev) || |
| 4522 | IS_CHERRYVIEW(dev)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4523 | latency *= 10; |
| 4524 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4525 | latency *= 5; |
| 4526 | |
| 4527 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4528 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4529 | } |
| 4530 | |
| 4531 | drm_modeset_unlock_all(dev); |
| 4532 | } |
| 4533 | |
| 4534 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 4535 | { |
| 4536 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4537 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4538 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4539 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4540 | if (INTEL_INFO(dev)->gen >= 9) |
| 4541 | latencies = dev_priv->wm.skl_latency; |
| 4542 | else |
| 4543 | latencies = to_i915(dev)->wm.pri_latency; |
| 4544 | |
| 4545 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4546 | |
| 4547 | return 0; |
| 4548 | } |
| 4549 | |
| 4550 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4551 | { |
| 4552 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4553 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4554 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4555 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4556 | if (INTEL_INFO(dev)->gen >= 9) |
| 4557 | latencies = dev_priv->wm.skl_latency; |
| 4558 | else |
| 4559 | latencies = to_i915(dev)->wm.spr_latency; |
| 4560 | |
| 4561 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4562 | |
| 4563 | return 0; |
| 4564 | } |
| 4565 | |
| 4566 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4567 | { |
| 4568 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4569 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4570 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4571 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4572 | if (INTEL_INFO(dev)->gen >= 9) |
| 4573 | latencies = dev_priv->wm.skl_latency; |
| 4574 | else |
| 4575 | latencies = to_i915(dev)->wm.cur_latency; |
| 4576 | |
| 4577 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4578 | |
| 4579 | return 0; |
| 4580 | } |
| 4581 | |
| 4582 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4583 | { |
| 4584 | struct drm_device *dev = inode->i_private; |
| 4585 | |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4586 | if (INTEL_INFO(dev)->gen < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4587 | return -ENODEV; |
| 4588 | |
| 4589 | return single_open(file, pri_wm_latency_show, dev); |
| 4590 | } |
| 4591 | |
| 4592 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4593 | { |
| 4594 | struct drm_device *dev = inode->i_private; |
| 4595 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4596 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4597 | return -ENODEV; |
| 4598 | |
| 4599 | return single_open(file, spr_wm_latency_show, dev); |
| 4600 | } |
| 4601 | |
| 4602 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4603 | { |
| 4604 | struct drm_device *dev = inode->i_private; |
| 4605 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4606 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4607 | return -ENODEV; |
| 4608 | |
| 4609 | return single_open(file, cur_wm_latency_show, dev); |
| 4610 | } |
| 4611 | |
| 4612 | 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] | 4613 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4614 | { |
| 4615 | struct seq_file *m = file->private_data; |
| 4616 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4617 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4618 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4619 | int level; |
| 4620 | int ret; |
| 4621 | char tmp[32]; |
| 4622 | |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4623 | if (IS_CHERRYVIEW(dev)) |
| 4624 | num_levels = 3; |
| 4625 | else if (IS_VALLEYVIEW(dev)) |
| 4626 | num_levels = 1; |
| 4627 | else |
| 4628 | num_levels = ilk_wm_max_level(dev) + 1; |
| 4629 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4630 | if (len >= sizeof(tmp)) |
| 4631 | return -EINVAL; |
| 4632 | |
| 4633 | if (copy_from_user(tmp, ubuf, len)) |
| 4634 | return -EFAULT; |
| 4635 | |
| 4636 | tmp[len] = '\0'; |
| 4637 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4638 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4639 | &new[0], &new[1], &new[2], &new[3], |
| 4640 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4641 | if (ret != num_levels) |
| 4642 | return -EINVAL; |
| 4643 | |
| 4644 | drm_modeset_lock_all(dev); |
| 4645 | |
| 4646 | for (level = 0; level < num_levels; level++) |
| 4647 | wm[level] = new[level]; |
| 4648 | |
| 4649 | drm_modeset_unlock_all(dev); |
| 4650 | |
| 4651 | return len; |
| 4652 | } |
| 4653 | |
| 4654 | |
| 4655 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4656 | size_t len, loff_t *offp) |
| 4657 | { |
| 4658 | struct seq_file *m = file->private_data; |
| 4659 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4660 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4661 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4662 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4663 | if (INTEL_INFO(dev)->gen >= 9) |
| 4664 | latencies = dev_priv->wm.skl_latency; |
| 4665 | else |
| 4666 | latencies = to_i915(dev)->wm.pri_latency; |
| 4667 | |
| 4668 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4669 | } |
| 4670 | |
| 4671 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4672 | size_t len, loff_t *offp) |
| 4673 | { |
| 4674 | struct seq_file *m = file->private_data; |
| 4675 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4676 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4677 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4678 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4679 | if (INTEL_INFO(dev)->gen >= 9) |
| 4680 | latencies = dev_priv->wm.skl_latency; |
| 4681 | else |
| 4682 | latencies = to_i915(dev)->wm.spr_latency; |
| 4683 | |
| 4684 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4685 | } |
| 4686 | |
| 4687 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4688 | size_t len, loff_t *offp) |
| 4689 | { |
| 4690 | struct seq_file *m = file->private_data; |
| 4691 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4692 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4693 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4694 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4695 | if (INTEL_INFO(dev)->gen >= 9) |
| 4696 | latencies = dev_priv->wm.skl_latency; |
| 4697 | else |
| 4698 | latencies = to_i915(dev)->wm.cur_latency; |
| 4699 | |
| 4700 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4701 | } |
| 4702 | |
| 4703 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4704 | .owner = THIS_MODULE, |
| 4705 | .open = pri_wm_latency_open, |
| 4706 | .read = seq_read, |
| 4707 | .llseek = seq_lseek, |
| 4708 | .release = single_release, |
| 4709 | .write = pri_wm_latency_write |
| 4710 | }; |
| 4711 | |
| 4712 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4713 | .owner = THIS_MODULE, |
| 4714 | .open = spr_wm_latency_open, |
| 4715 | .read = seq_read, |
| 4716 | .llseek = seq_lseek, |
| 4717 | .release = single_release, |
| 4718 | .write = spr_wm_latency_write |
| 4719 | }; |
| 4720 | |
| 4721 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4722 | .owner = THIS_MODULE, |
| 4723 | .open = cur_wm_latency_open, |
| 4724 | .read = seq_read, |
| 4725 | .llseek = seq_lseek, |
| 4726 | .release = single_release, |
| 4727 | .write = cur_wm_latency_write |
| 4728 | }; |
| 4729 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4730 | static int |
| 4731 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4732 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4733 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4734 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4735 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4736 | *val = i915_terminally_wedged(&dev_priv->gpu_error); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4737 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4738 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4739 | } |
| 4740 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4741 | static int |
| 4742 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4743 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4744 | struct drm_device *dev = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4745 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4746 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4747 | /* |
| 4748 | * There is no safeguard against this debugfs entry colliding |
| 4749 | * with the hangcheck calling same i915_handle_error() in |
| 4750 | * parallel, causing an explosion. For now we assume that the |
| 4751 | * test harness is responsible enough not to inject gpu hangs |
| 4752 | * while it is writing to 'i915_wedged' |
| 4753 | */ |
| 4754 | |
Chris Wilson | d98c52c | 2016-04-13 17:35:05 +0100 | [diff] [blame] | 4755 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4756 | return -EAGAIN; |
| 4757 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4758 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4759 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame^] | 4760 | i915_handle_error(dev_priv, val, |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4761 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4762 | |
| 4763 | intel_runtime_pm_put(dev_priv); |
| 4764 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4765 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4766 | } |
| 4767 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4768 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4769 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4770 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4771 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4772 | static int |
| 4773 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4774 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4775 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4776 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4777 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4778 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4779 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4780 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4781 | } |
| 4782 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4783 | static int |
| 4784 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4785 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4786 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4787 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4788 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4789 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4790 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4791 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4792 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4793 | if (ret) |
| 4794 | return ret; |
| 4795 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 4796 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4797 | mutex_unlock(&dev->struct_mutex); |
| 4798 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4799 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4800 | } |
| 4801 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4802 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 4803 | i915_ring_stop_get, i915_ring_stop_set, |
| 4804 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 4805 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4806 | static int |
| 4807 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4808 | { |
| 4809 | struct drm_device *dev = data; |
| 4810 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4811 | |
| 4812 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4813 | return 0; |
| 4814 | } |
| 4815 | |
| 4816 | static int |
| 4817 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4818 | { |
| 4819 | struct drm_device *dev = data; |
| 4820 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4821 | int ret; |
| 4822 | |
| 4823 | /* Lock against concurrent debugfs callers */ |
| 4824 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4825 | if (ret) |
| 4826 | return ret; |
| 4827 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4828 | mutex_unlock(&dev->struct_mutex); |
| 4829 | |
| 4830 | return 0; |
| 4831 | } |
| 4832 | |
| 4833 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4834 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4835 | "0x%08llx\n"); |
| 4836 | |
| 4837 | static int |
| 4838 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4839 | { |
| 4840 | struct drm_device *dev = data; |
| 4841 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4842 | |
| 4843 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4844 | |
| 4845 | return 0; |
| 4846 | } |
| 4847 | |
| 4848 | static int |
| 4849 | i915_ring_test_irq_set(void *data, u64 val) |
| 4850 | { |
| 4851 | struct drm_device *dev = data; |
| 4852 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4853 | int ret; |
| 4854 | |
| 4855 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 4856 | |
| 4857 | /* Lock against concurrent debugfs callers */ |
| 4858 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4859 | if (ret) |
| 4860 | return ret; |
| 4861 | |
| 4862 | dev_priv->gpu_error.test_irq_rings = val; |
| 4863 | mutex_unlock(&dev->struct_mutex); |
| 4864 | |
| 4865 | return 0; |
| 4866 | } |
| 4867 | |
| 4868 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4869 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4870 | "0x%08llx\n"); |
| 4871 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4872 | #define DROP_UNBOUND 0x1 |
| 4873 | #define DROP_BOUND 0x2 |
| 4874 | #define DROP_RETIRE 0x4 |
| 4875 | #define DROP_ACTIVE 0x8 |
| 4876 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4877 | DROP_BOUND | \ |
| 4878 | DROP_RETIRE | \ |
| 4879 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4880 | static int |
| 4881 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4882 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4883 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4884 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4885 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4886 | } |
| 4887 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4888 | static int |
| 4889 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4890 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4891 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4892 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4893 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4894 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4895 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4896 | |
| 4897 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4898 | * on ioctls on -EAGAIN. */ |
| 4899 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4900 | if (ret) |
| 4901 | return ret; |
| 4902 | |
| 4903 | if (val & DROP_ACTIVE) { |
| 4904 | ret = i915_gpu_idle(dev); |
| 4905 | if (ret) |
| 4906 | goto unlock; |
| 4907 | } |
| 4908 | |
| 4909 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame^] | 4910 | i915_gem_retire_requests(dev_priv); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4911 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4912 | if (val & DROP_BOUND) |
| 4913 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4914 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4915 | if (val & DROP_UNBOUND) |
| 4916 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4917 | |
| 4918 | unlock: |
| 4919 | mutex_unlock(&dev->struct_mutex); |
| 4920 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4921 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4922 | } |
| 4923 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4924 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4925 | i915_drop_caches_get, i915_drop_caches_set, |
| 4926 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4927 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4928 | static int |
| 4929 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4930 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4931 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4932 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4933 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4934 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4935 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4936 | return -ENODEV; |
| 4937 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4938 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4939 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4940 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4941 | if (ret) |
| 4942 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4943 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4944 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4945 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4946 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4947 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4948 | } |
| 4949 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4950 | static int |
| 4951 | i915_max_freq_set(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; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4954 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4955 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4956 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4957 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4958 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4959 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4960 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4961 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4962 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4963 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4964 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4965 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4966 | if (ret) |
| 4967 | return ret; |
| 4968 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4969 | /* |
| 4970 | * Turbo will still be enabled, but won't go above the set value. |
| 4971 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4972 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4973 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4974 | hw_max = dev_priv->rps.max_freq; |
| 4975 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4976 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4977 | 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] | 4978 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4979 | return -EINVAL; |
| 4980 | } |
| 4981 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4982 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4983 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4984 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4985 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4986 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4987 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4988 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4989 | } |
| 4990 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4991 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4992 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4993 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4994 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4995 | static int |
| 4996 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4997 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4998 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4999 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5000 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5001 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 5002 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5003 | return -ENODEV; |
| 5004 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 5005 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 5006 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5007 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5008 | if (ret) |
| 5009 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5010 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 5011 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 5012 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5013 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5014 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5015 | } |
| 5016 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5017 | static int |
| 5018 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5019 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5020 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5021 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 5022 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5023 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5024 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 5025 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5026 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 5027 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 5028 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 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 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 5051 | intel_set_rps(dev, 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; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 5066 | struct drm_i915_private *dev_priv = dev->dev_private; |
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); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5081 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 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; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5092 | struct drm_i915_private *dev_priv = dev->dev_private; |
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 | { |
| 5129 | struct drm_i915_private *dev_priv = dev->dev_private; |
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 | { |
| 5161 | struct drm_i915_private *dev_priv = dev->dev_private; |
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 | { |
| 5226 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 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; |
| 5251 | struct drm_device *dev = node->minor->dev; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5252 | struct sseu_dev_status stat; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5253 | |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5254 | if (INTEL_INFO(dev)->gen < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5255 | return -ENODEV; |
| 5256 | |
| 5257 | seq_puts(m, "SSEU Device Info\n"); |
| 5258 | seq_printf(m, " Available Slice Total: %u\n", |
| 5259 | INTEL_INFO(dev)->slice_total); |
| 5260 | seq_printf(m, " Available Subslice Total: %u\n", |
| 5261 | INTEL_INFO(dev)->subslice_total); |
| 5262 | seq_printf(m, " Available Subslice Per Slice: %u\n", |
| 5263 | INTEL_INFO(dev)->subslice_per_slice); |
| 5264 | seq_printf(m, " Available EU Total: %u\n", |
| 5265 | INTEL_INFO(dev)->eu_total); |
| 5266 | seq_printf(m, " Available EU Per Subslice: %u\n", |
| 5267 | INTEL_INFO(dev)->eu_per_subslice); |
| 5268 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 5269 | yesno(INTEL_INFO(dev)->has_slice_pg)); |
| 5270 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 5271 | yesno(INTEL_INFO(dev)->has_subslice_pg)); |
| 5272 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 5273 | yesno(INTEL_INFO(dev)->has_eu_pg)); |
| 5274 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5275 | seq_puts(m, "SSEU Device Status\n"); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5276 | memset(&stat, 0, sizeof(stat)); |
Jeff McGee | 5575f03 | 2015-02-27 10:22:32 -0800 | [diff] [blame] | 5277 | if (IS_CHERRYVIEW(dev)) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5278 | cherryview_sseu_device_status(dev, &stat); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5279 | } else if (IS_BROADWELL(dev)) { |
| 5280 | broadwell_sseu_device_status(dev, &stat); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5281 | } else if (INTEL_INFO(dev)->gen >= 9) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5282 | gen9_sseu_device_status(dev, &stat); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5283 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5284 | seq_printf(m, " Enabled Slice Total: %u\n", |
| 5285 | stat.slice_total); |
| 5286 | seq_printf(m, " Enabled Subslice Total: %u\n", |
| 5287 | stat.subslice_total); |
| 5288 | seq_printf(m, " Enabled Subslice Per Slice: %u\n", |
| 5289 | stat.subslice_per_slice); |
| 5290 | seq_printf(m, " Enabled EU Total: %u\n", |
| 5291 | stat.eu_total); |
| 5292 | seq_printf(m, " Enabled EU Per Subslice: %u\n", |
| 5293 | stat.eu_per_subslice); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5294 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5295 | return 0; |
| 5296 | } |
| 5297 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5298 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 5299 | { |
| 5300 | struct drm_device *dev = inode->i_private; |
| 5301 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5302 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 5303 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5304 | return 0; |
| 5305 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5306 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5307 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5308 | |
| 5309 | return 0; |
| 5310 | } |
| 5311 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 5312 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5313 | { |
| 5314 | struct drm_device *dev = inode->i_private; |
| 5315 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 5316 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 5317 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5318 | return 0; |
| 5319 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5320 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5321 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5322 | |
| 5323 | return 0; |
| 5324 | } |
| 5325 | |
| 5326 | static const struct file_operations i915_forcewake_fops = { |
| 5327 | .owner = THIS_MODULE, |
| 5328 | .open = i915_forcewake_open, |
| 5329 | .release = i915_forcewake_release, |
| 5330 | }; |
| 5331 | |
| 5332 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 5333 | { |
| 5334 | struct drm_device *dev = minor->dev; |
| 5335 | struct dentry *ent; |
| 5336 | |
| 5337 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5338 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5339 | root, dev, |
| 5340 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5341 | if (!ent) |
| 5342 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5343 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5344 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5345 | } |
| 5346 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5347 | static int i915_debugfs_create(struct dentry *root, |
| 5348 | struct drm_minor *minor, |
| 5349 | const char *name, |
| 5350 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5351 | { |
| 5352 | struct drm_device *dev = minor->dev; |
| 5353 | struct dentry *ent; |
| 5354 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5355 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5356 | S_IRUGO | S_IWUSR, |
| 5357 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5358 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5359 | if (!ent) |
| 5360 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5361 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5362 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5363 | } |
| 5364 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5365 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 5366 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 5367 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 5368 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 5369 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5370 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5371 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 5372 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 5373 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5374 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 5375 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 5376 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5377 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 5378 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 5379 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 5380 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 5381 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 5382 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 5383 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 5384 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 5385 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 5386 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 5387 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 5388 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 5389 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 5390 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 5391 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 5392 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 5393 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 5394 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 5395 | {"i915_opregion", i915_opregion, 0}, |
Jani Nikula | ada8f95 | 2015-12-15 13:17:12 +0200 | [diff] [blame] | 5396 | {"i915_vbt", i915_vbt, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 5397 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 5398 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 5399 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 5400 | {"i915_execlists", i915_execlists, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 5401 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 5402 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 5403 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 5404 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 5405 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 5406 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 5407 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 5408 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 5409 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 5410 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 5411 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 5412 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 5413 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 5414 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 5415 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 5416 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5417 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 5418 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 5419 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5420 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5421 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5422 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5423 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5424 | const char *name; |
| 5425 | const struct file_operations *fops; |
| 5426 | } i915_debugfs_files[] = { |
| 5427 | {"i915_wedged", &i915_wedged_fops}, |
| 5428 | {"i915_max_freq", &i915_max_freq_fops}, |
| 5429 | {"i915_min_freq", &i915_min_freq_fops}, |
| 5430 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 5431 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 5432 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 5433 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5434 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 5435 | {"i915_error_state", &i915_error_state_fops}, |
| 5436 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 5437 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 5438 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 5439 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 5440 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 5441 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 5442 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 5443 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
| 5444 | {"i915_dp_test_active", &i915_displayport_test_active_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5445 | }; |
| 5446 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5447 | void intel_display_crc_init(struct drm_device *dev) |
| 5448 | { |
| 5449 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5450 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5451 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 5452 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5453 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5454 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 5455 | pipe_crc->opened = false; |
| 5456 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5457 | init_waitqueue_head(&pipe_crc->wq); |
| 5458 | } |
| 5459 | } |
| 5460 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5461 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5462 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5463 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 5464 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5465 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 5466 | if (ret) |
| 5467 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5468 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5469 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 5470 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 5471 | if (ret) |
| 5472 | return ret; |
| 5473 | } |
| 5474 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5475 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5476 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 5477 | i915_debugfs_files[i].name, |
| 5478 | i915_debugfs_files[i].fops); |
| 5479 | if (ret) |
| 5480 | return ret; |
| 5481 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 5482 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5483 | return drm_debugfs_create_files(i915_debugfs_list, |
| 5484 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5485 | minor->debugfs_root, minor); |
| 5486 | } |
| 5487 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5488 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5489 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5490 | int i; |
| 5491 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5492 | drm_debugfs_remove_files(i915_debugfs_list, |
| 5493 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5494 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5495 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 5496 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5497 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 5498 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5499 | struct drm_info_list *info_list = |
| 5500 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 5501 | |
| 5502 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5503 | } |
| 5504 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5505 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5506 | struct drm_info_list *info_list = |
| 5507 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 5508 | |
| 5509 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5510 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5511 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5512 | |
| 5513 | struct dpcd_block { |
| 5514 | /* DPCD dump start address. */ |
| 5515 | unsigned int offset; |
| 5516 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 5517 | unsigned int end; |
| 5518 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 5519 | size_t size; |
| 5520 | /* Only valid for eDP. */ |
| 5521 | bool edp; |
| 5522 | }; |
| 5523 | |
| 5524 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 5525 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 5526 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 5527 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 5528 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 5529 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 5530 | { .offset = DP_SET_POWER }, |
| 5531 | { .offset = DP_EDP_DPCD_REV }, |
| 5532 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 5533 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 5534 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 5535 | }; |
| 5536 | |
| 5537 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 5538 | { |
| 5539 | struct drm_connector *connector = m->private; |
| 5540 | struct intel_dp *intel_dp = |
| 5541 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5542 | uint8_t buf[16]; |
| 5543 | ssize_t err; |
| 5544 | int i; |
| 5545 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 5546 | if (connector->status != connector_status_connected) |
| 5547 | return -ENODEV; |
| 5548 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5549 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 5550 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 5551 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 5552 | |
| 5553 | if (b->edp && |
| 5554 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 5555 | continue; |
| 5556 | |
| 5557 | /* low tech for now */ |
| 5558 | if (WARN_ON(size > sizeof(buf))) |
| 5559 | continue; |
| 5560 | |
| 5561 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 5562 | if (err <= 0) { |
| 5563 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 5564 | size, b->offset, err); |
| 5565 | continue; |
| 5566 | } |
| 5567 | |
| 5568 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 5569 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5570 | |
| 5571 | return 0; |
| 5572 | } |
| 5573 | |
| 5574 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5575 | { |
| 5576 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5577 | } |
| 5578 | |
| 5579 | static const struct file_operations i915_dpcd_fops = { |
| 5580 | .owner = THIS_MODULE, |
| 5581 | .open = i915_dpcd_open, |
| 5582 | .read = seq_read, |
| 5583 | .llseek = seq_lseek, |
| 5584 | .release = single_release, |
| 5585 | }; |
| 5586 | |
| 5587 | /** |
| 5588 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5589 | * @connector: pointer to a registered drm_connector |
| 5590 | * |
| 5591 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5592 | * drm_debugfs_connector_remove(). |
| 5593 | * |
| 5594 | * Returns 0 on success, negative error codes on error. |
| 5595 | */ |
| 5596 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5597 | { |
| 5598 | struct dentry *root = connector->debugfs_entry; |
| 5599 | |
| 5600 | /* The connector must have been registered beforehands. */ |
| 5601 | if (!root) |
| 5602 | return -ENODEV; |
| 5603 | |
| 5604 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5605 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5606 | debugfs_create_file("i915_dpcd", S_IRUGO, root, connector, |
| 5607 | &i915_dpcd_fops); |
| 5608 | |
| 5609 | return 0; |
| 5610 | } |