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 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 92 | static const char *get_pin_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 93 | { |
Chris Wilson | baaa5cf | 2015-04-15 16:42:46 +0100 | [diff] [blame] | 94 | if (obj->pin_display) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 95 | return "p"; |
| 96 | else |
| 97 | return " "; |
| 98 | } |
| 99 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 100 | static const char *get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 101 | { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 102 | switch (obj->tiling_mode) { |
| 103 | default: |
| 104 | case I915_TILING_NONE: return " "; |
| 105 | case I915_TILING_X: return "X"; |
| 106 | case I915_TILING_Y: return "Y"; |
| 107 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 110 | static inline const char *get_global_flag(struct drm_i915_gem_object *obj) |
| 111 | { |
Tvrtko Ursulin | aff4376 | 2014-10-24 12:42:33 +0100 | [diff] [blame] | 112 | return i915_gem_obj_to_ggtt(obj) ? "g" : " "; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 115 | static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj) |
| 116 | { |
| 117 | u64 size = 0; |
| 118 | struct i915_vma *vma; |
| 119 | |
| 120 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 121 | if (i915_is_ggtt(vma->vm) && |
| 122 | drm_mm_node_allocated(&vma->node)) |
| 123 | size += vma->node.size; |
| 124 | } |
| 125 | |
| 126 | return size; |
| 127 | } |
| 128 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 129 | static void |
| 130 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 131 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 132 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
| 133 | struct intel_engine_cs *ring; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 134 | struct i915_vma *vma; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 135 | int pin_count = 0; |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 136 | int i; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 137 | |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 138 | seq_printf(m, "%pK: %s%s%s%s %8zdKiB %02x %02x [ ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 139 | &obj->base, |
Chris Wilson | 481a3d4 | 2015-04-07 16:20:39 +0100 | [diff] [blame] | 140 | obj->active ? "*" : " ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 141 | get_pin_flag(obj), |
| 142 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 143 | get_global_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 144 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 145 | obj->base.read_domains, |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 146 | obj->base.write_domain); |
| 147 | for_each_ring(ring, dev_priv, i) |
| 148 | seq_printf(m, "%x ", |
| 149 | i915_gem_request_get_seqno(obj->last_read_req[i])); |
| 150 | seq_printf(m, "] %x %x%s%s%s", |
John Harrison | 97b2a6a | 2014-11-24 18:49:26 +0000 | [diff] [blame] | 151 | i915_gem_request_get_seqno(obj->last_write_req), |
| 152 | i915_gem_request_get_seqno(obj->last_fenced_req), |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 153 | i915_cache_level_str(to_i915(obj->base.dev), obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 154 | obj->dirty ? " dirty" : "", |
| 155 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 156 | if (obj->base.name) |
| 157 | seq_printf(m, " (name: %d)", obj->base.name); |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 158 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 159 | if (vma->pin_count > 0) |
| 160 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 161 | } |
| 162 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 163 | if (obj->pin_display) |
| 164 | seq_printf(m, " (display)"); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 165 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 166 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 167 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 168 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
| 169 | i915_is_ggtt(vma->vm) ? "g" : "pp", |
| 170 | vma->node.start, vma->node.size); |
| 171 | if (i915_is_ggtt(vma->vm)) |
| 172 | seq_printf(m, ", type: %u)", vma->ggtt_view.type); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 173 | else |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 174 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 175 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 176 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 177 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 178 | if (obj->pin_display || obj->fault_mappable) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 179 | char s[3], *t = s; |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 180 | if (obj->pin_display) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 181 | *t++ = 'p'; |
| 182 | if (obj->fault_mappable) |
| 183 | *t++ = 'f'; |
| 184 | *t = '\0'; |
| 185 | seq_printf(m, " (%s mappable)", s); |
| 186 | } |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 187 | if (obj->last_write_req != NULL) |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 188 | seq_printf(m, " (%s)", |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 189 | i915_gem_request_get_ring(obj->last_write_req)->name); |
Daniel Vetter | d5a81ef | 2014-06-18 14:46:49 +0200 | [diff] [blame] | 190 | if (obj->frontbuffer_bits) |
| 191 | seq_printf(m, " (frontbuffer: 0x%03x)", obj->frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 192 | } |
| 193 | |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 194 | static void describe_ctx(struct seq_file *m, struct intel_context *ctx) |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 195 | { |
Oscar Mateo | ea0c76f | 2014-07-03 16:27:59 +0100 | [diff] [blame] | 196 | seq_putc(m, ctx->legacy_hw_ctx.initialized ? 'I' : 'i'); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 197 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 198 | seq_putc(m, ' '); |
| 199 | } |
| 200 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 201 | 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] | 202 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 203 | struct drm_info_node *node = m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 204 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 205 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 206 | struct drm_device *dev = node->minor->dev; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 207 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 208 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 209 | struct i915_vma *vma; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 210 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 211 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 212 | |
| 213 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 214 | if (ret) |
| 215 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 216 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 217 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 218 | switch (list) { |
| 219 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 220 | seq_puts(m, "Active:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 221 | head = &vm->active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 222 | break; |
| 223 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 224 | seq_puts(m, "Inactive:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 225 | head = &vm->inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 226 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 227 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 228 | mutex_unlock(&dev->struct_mutex); |
| 229 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 230 | } |
| 231 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 232 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 233 | list_for_each_entry(vma, head, mm_list) { |
| 234 | seq_printf(m, " "); |
| 235 | describe_obj(m, vma->obj); |
| 236 | seq_printf(m, "\n"); |
| 237 | total_obj_size += vma->obj->base.size; |
| 238 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 239 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 240 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 241 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 242 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 243 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 244 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 245 | return 0; |
| 246 | } |
| 247 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 248 | static int obj_rank_by_stolen(void *priv, |
| 249 | struct list_head *A, struct list_head *B) |
| 250 | { |
| 251 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 252 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 253 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 254 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 255 | |
Rasmus Villemoes | 2d05fa1 | 2015-09-28 23:08:50 +0200 | [diff] [blame] | 256 | if (a->stolen->start < b->stolen->start) |
| 257 | return -1; |
| 258 | if (a->stolen->start > b->stolen->start) |
| 259 | return 1; |
| 260 | return 0; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 264 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 265 | struct drm_info_node *node = m->private; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 266 | struct drm_device *dev = node->minor->dev; |
| 267 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 268 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 269 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 270 | LIST_HEAD(stolen); |
| 271 | int count, ret; |
| 272 | |
| 273 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 274 | if (ret) |
| 275 | return ret; |
| 276 | |
| 277 | total_obj_size = total_gtt_size = count = 0; |
| 278 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 279 | if (obj->stolen == NULL) |
| 280 | continue; |
| 281 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 282 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 283 | |
| 284 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 285 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 286 | count++; |
| 287 | } |
| 288 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 289 | if (obj->stolen == NULL) |
| 290 | continue; |
| 291 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 292 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 293 | |
| 294 | total_obj_size += obj->base.size; |
| 295 | count++; |
| 296 | } |
| 297 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 298 | seq_puts(m, "Stolen:\n"); |
| 299 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 300 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 301 | seq_puts(m, " "); |
| 302 | describe_obj(m, obj); |
| 303 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 304 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 305 | } |
| 306 | mutex_unlock(&dev->struct_mutex); |
| 307 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 308 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 309 | count, total_obj_size, total_gtt_size); |
| 310 | return 0; |
| 311 | } |
| 312 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 313 | #define count_objects(list, member) do { \ |
| 314 | list_for_each_entry(obj, list, member) { \ |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 315 | size += i915_gem_obj_total_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 316 | ++count; \ |
| 317 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 318 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 319 | ++mappable_count; \ |
| 320 | } \ |
| 321 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 322 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 323 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 324 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 325 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 326 | unsigned long count; |
| 327 | u64 total, unbound; |
| 328 | u64 global, shared; |
| 329 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 330 | }; |
| 331 | |
| 332 | static int per_file_stats(int id, void *ptr, void *data) |
| 333 | { |
| 334 | struct drm_i915_gem_object *obj = ptr; |
| 335 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 336 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 337 | |
| 338 | stats->count++; |
| 339 | stats->total += obj->base.size; |
| 340 | |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 341 | if (obj->base.name || obj->base.dma_buf) |
| 342 | stats->shared += obj->base.size; |
| 343 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 344 | if (USES_FULL_PPGTT(obj->base.dev)) { |
| 345 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 346 | struct i915_hw_ppgtt *ppgtt; |
| 347 | |
| 348 | if (!drm_mm_node_allocated(&vma->node)) |
| 349 | continue; |
| 350 | |
| 351 | if (i915_is_ggtt(vma->vm)) { |
| 352 | stats->global += obj->base.size; |
| 353 | continue; |
| 354 | } |
| 355 | |
| 356 | ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base); |
Daniel Vetter | 4d88470 | 2014-08-06 15:04:47 +0200 | [diff] [blame] | 357 | if (ppgtt->file_priv != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 358 | continue; |
| 359 | |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 360 | if (obj->active) /* XXX per-vma statistic */ |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 361 | stats->active += obj->base.size; |
| 362 | else |
| 363 | stats->inactive += obj->base.size; |
| 364 | |
| 365 | return 0; |
| 366 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 367 | } else { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 368 | if (i915_gem_obj_ggtt_bound(obj)) { |
| 369 | stats->global += obj->base.size; |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 370 | if (obj->active) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 371 | stats->active += obj->base.size; |
| 372 | else |
| 373 | stats->inactive += obj->base.size; |
| 374 | return 0; |
| 375 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 376 | } |
| 377 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 378 | if (!list_empty(&obj->global_list)) |
| 379 | stats->unbound += obj->base.size; |
| 380 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 381 | return 0; |
| 382 | } |
| 383 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 384 | #define print_file_stats(m, name, stats) do { \ |
| 385 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 386 | 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] | 387 | name, \ |
| 388 | stats.count, \ |
| 389 | stats.total, \ |
| 390 | stats.active, \ |
| 391 | stats.inactive, \ |
| 392 | stats.global, \ |
| 393 | stats.shared, \ |
| 394 | stats.unbound); \ |
| 395 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 396 | |
| 397 | static void print_batch_pool_stats(struct seq_file *m, |
| 398 | struct drm_i915_private *dev_priv) |
| 399 | { |
| 400 | struct drm_i915_gem_object *obj; |
| 401 | struct file_stats stats; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 402 | struct intel_engine_cs *ring; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 403 | int i, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 404 | |
| 405 | memset(&stats, 0, sizeof(stats)); |
| 406 | |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 407 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 408 | for (j = 0; j < ARRAY_SIZE(ring->batch_pool.cache_list); j++) { |
| 409 | list_for_each_entry(obj, |
| 410 | &ring->batch_pool.cache_list[j], |
| 411 | batch_pool_link) |
| 412 | per_file_stats(0, obj, &stats); |
| 413 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 414 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 415 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 416 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 417 | } |
| 418 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 419 | #define count_vmas(list, member) do { \ |
| 420 | list_for_each_entry(vma, list, member) { \ |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 421 | size += i915_gem_obj_total_ggtt_size(vma->obj); \ |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 422 | ++count; \ |
| 423 | if (vma->obj->map_and_fenceable) { \ |
| 424 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 425 | ++mappable_count; \ |
| 426 | } \ |
| 427 | } \ |
| 428 | } while (0) |
| 429 | |
| 430 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 431 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 432 | struct drm_info_node *node = m->private; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 433 | struct drm_device *dev = node->minor->dev; |
| 434 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 435 | u32 count, mappable_count, purgeable_count; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 436 | u64 size, mappable_size, purgeable_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 437 | struct drm_i915_gem_object *obj; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 438 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 439 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 440 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 441 | int ret; |
| 442 | |
| 443 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 444 | if (ret) |
| 445 | return ret; |
| 446 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 447 | seq_printf(m, "%u objects, %zu bytes\n", |
| 448 | dev_priv->mm.object_count, |
| 449 | dev_priv->mm.object_memory); |
| 450 | |
| 451 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 452 | count_objects(&dev_priv->mm.bound_list, global_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 453 | seq_printf(m, "%u [%u] objects, %llu [%llu] bytes in gtt\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 454 | count, mappable_count, size, mappable_size); |
| 455 | |
| 456 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 457 | count_vmas(&vm->active_list, mm_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 458 | seq_printf(m, " %u [%u] active objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 459 | count, mappable_count, size, mappable_size); |
| 460 | |
| 461 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 462 | count_vmas(&vm->inactive_list, mm_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 463 | seq_printf(m, " %u [%u] inactive objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 464 | count, mappable_count, size, mappable_size); |
| 465 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 466 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 467 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 468 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 469 | if (obj->madv == I915_MADV_DONTNEED) |
| 470 | purgeable_size += obj->base.size, ++purgeable_count; |
| 471 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 472 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 473 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 474 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 475 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 476 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 477 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 478 | ++count; |
| 479 | } |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 480 | if (obj->pin_display) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 481 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 482 | ++mappable_count; |
| 483 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 484 | if (obj->madv == I915_MADV_DONTNEED) { |
| 485 | purgeable_size += obj->base.size; |
| 486 | ++purgeable_count; |
| 487 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 488 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 489 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 490 | purgeable_count, purgeable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 491 | seq_printf(m, "%u pinned mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 492 | mappable_count, mappable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 493 | seq_printf(m, "%u fault mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 494 | count, size); |
| 495 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 496 | seq_printf(m, "%llu [%llu] gtt total\n", |
Ben Widawsky | 853ba5d | 2013-07-16 16:50:05 -0700 | [diff] [blame] | 497 | dev_priv->gtt.base.total, |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 498 | (u64)dev_priv->gtt.mappable_end - dev_priv->gtt.base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 499 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 500 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 501 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 502 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 503 | struct file_stats stats; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 504 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 505 | |
| 506 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 507 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 508 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 509 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 510 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 511 | /* |
| 512 | * Although we have a valid reference on file->pid, that does |
| 513 | * not guarantee that the task_struct who called get_pid() is |
| 514 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 515 | * Therefore, we need to protect this ->comm access using RCU. |
| 516 | */ |
| 517 | rcu_read_lock(); |
| 518 | task = pid_task(file->pid, PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 519 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 520 | rcu_read_unlock(); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 521 | } |
| 522 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 523 | mutex_unlock(&dev->struct_mutex); |
| 524 | |
| 525 | return 0; |
| 526 | } |
| 527 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 528 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 529 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 530 | struct drm_info_node *node = m->private; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 531 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 532 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 533 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 534 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 535 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 536 | int count, ret; |
| 537 | |
| 538 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 539 | if (ret) |
| 540 | return ret; |
| 541 | |
| 542 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 543 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 544 | if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj)) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 545 | continue; |
| 546 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 547 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 548 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 549 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 550 | total_obj_size += obj->base.size; |
Tvrtko Ursulin | ca1543b | 2015-07-01 11:51:10 +0100 | [diff] [blame] | 551 | total_gtt_size += i915_gem_obj_total_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 552 | count++; |
| 553 | } |
| 554 | |
| 555 | mutex_unlock(&dev->struct_mutex); |
| 556 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 557 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 558 | count, total_obj_size, total_gtt_size); |
| 559 | |
| 560 | return 0; |
| 561 | } |
| 562 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 563 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 564 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 565 | struct drm_info_node *node = m->private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 566 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 567 | struct drm_i915_private *dev_priv = dev->dev_private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 568 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 569 | int ret; |
| 570 | |
| 571 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 572 | if (ret) |
| 573 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 574 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 575 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 576 | const char pipe = pipe_name(crtc->pipe); |
| 577 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 578 | struct intel_unpin_work *work; |
| 579 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 580 | spin_lock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 581 | work = crtc->unpin_work; |
| 582 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 583 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 584 | pipe, plane); |
| 585 | } else { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 586 | u32 addr; |
| 587 | |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 588 | if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 589 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 590 | pipe, plane); |
| 591 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 592 | 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] | 593 | pipe, plane); |
| 594 | } |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 595 | if (work->flip_queued_req) { |
| 596 | struct intel_engine_cs *ring = |
| 597 | i915_gem_request_get_ring(work->flip_queued_req); |
| 598 | |
Mika Kuoppala | 20e28fb | 2015-01-26 18:03:06 +0200 | [diff] [blame] | 599 | seq_printf(m, "Flip queued on %s at seqno %x, next seqno %x [current breadcrumb %x], completed? %d\n", |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 600 | ring->name, |
John Harrison | f06cc1b | 2014-11-24 18:49:37 +0000 | [diff] [blame] | 601 | i915_gem_request_get_seqno(work->flip_queued_req), |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 602 | dev_priv->next_seqno, |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 603 | ring->get_seqno(ring, true), |
John Harrison | 1b5a433 | 2014-11-24 18:49:42 +0000 | [diff] [blame] | 604 | i915_gem_request_completed(work->flip_queued_req, true)); |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 605 | } else |
| 606 | seq_printf(m, "Flip not associated with any ring\n"); |
| 607 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 608 | work->flip_queued_vblank, |
| 609 | work->flip_ready_vblank, |
Daniel Vetter | 1e3feef | 2015-02-13 21:03:45 +0100 | [diff] [blame] | 610 | drm_crtc_vblank_count(&crtc->base)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 611 | if (work->enable_stall_check) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 612 | seq_puts(m, "Stall check enabled, "); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 613 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 614 | seq_puts(m, "Stall check waiting for page flip ioctl, "); |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 615 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 616 | |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 617 | if (INTEL_INFO(dev)->gen >= 4) |
| 618 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 619 | else |
| 620 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 621 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 622 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 623 | if (work->pending_flip_obj) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 624 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 625 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 626 | } |
| 627 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 628 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 629 | } |
| 630 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 631 | mutex_unlock(&dev->struct_mutex); |
| 632 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 633 | return 0; |
| 634 | } |
| 635 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 636 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 637 | { |
| 638 | struct drm_info_node *node = m->private; |
| 639 | struct drm_device *dev = node->minor->dev; |
| 640 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 641 | struct drm_i915_gem_object *obj; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 642 | struct intel_engine_cs *ring; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 643 | int total = 0; |
| 644 | int ret, i, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 645 | |
| 646 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 647 | if (ret) |
| 648 | return ret; |
| 649 | |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 650 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 651 | for (j = 0; j < ARRAY_SIZE(ring->batch_pool.cache_list); j++) { |
| 652 | int count; |
| 653 | |
| 654 | count = 0; |
| 655 | list_for_each_entry(obj, |
| 656 | &ring->batch_pool.cache_list[j], |
| 657 | batch_pool_link) |
| 658 | count++; |
| 659 | seq_printf(m, "%s cache[%d]: %d objects\n", |
| 660 | ring->name, j, count); |
| 661 | |
| 662 | list_for_each_entry(obj, |
| 663 | &ring->batch_pool.cache_list[j], |
| 664 | batch_pool_link) { |
| 665 | seq_puts(m, " "); |
| 666 | describe_obj(m, obj); |
| 667 | seq_putc(m, '\n'); |
| 668 | } |
| 669 | |
| 670 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 671 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 672 | } |
| 673 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 674 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 675 | |
| 676 | mutex_unlock(&dev->struct_mutex); |
| 677 | |
| 678 | return 0; |
| 679 | } |
| 680 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 681 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 682 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 683 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 684 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 685 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 686 | struct intel_engine_cs *ring; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 687 | struct drm_i915_gem_request *req; |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 688 | int ret, any, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 689 | |
| 690 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 691 | if (ret) |
| 692 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 693 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 694 | any = 0; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 695 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 696 | int count; |
| 697 | |
| 698 | count = 0; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 699 | list_for_each_entry(req, &ring->request_list, list) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 700 | count++; |
| 701 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 702 | continue; |
| 703 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 704 | seq_printf(m, "%s requests: %d\n", ring->name, count); |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 705 | list_for_each_entry(req, &ring->request_list, list) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 706 | struct task_struct *task; |
| 707 | |
| 708 | rcu_read_lock(); |
| 709 | task = NULL; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 710 | if (req->pid) |
| 711 | task = pid_task(req->pid, PIDTYPE_PID); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 712 | seq_printf(m, " %x @ %d: %s [%d]\n", |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 713 | req->seqno, |
| 714 | (int) (jiffies - req->emitted_jiffies), |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 715 | task ? task->comm : "<unknown>", |
| 716 | task ? task->pid : -1); |
| 717 | rcu_read_unlock(); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 718 | } |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 719 | |
| 720 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 721 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 722 | mutex_unlock(&dev->struct_mutex); |
| 723 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 724 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 725 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 726 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 727 | return 0; |
| 728 | } |
| 729 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 730 | static void i915_ring_seqno_info(struct seq_file *m, |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 731 | struct intel_engine_cs *ring) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 732 | { |
| 733 | if (ring->get_seqno) { |
Mika Kuoppala | 20e28fb | 2015-01-26 18:03:06 +0200 | [diff] [blame] | 734 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | b2eadbc | 2012-08-09 10:58:30 +0100 | [diff] [blame] | 735 | ring->name, ring->get_seqno(ring, false)); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 736 | } |
| 737 | } |
| 738 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 739 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 740 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 741 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 742 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 743 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 744 | struct intel_engine_cs *ring; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 745 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 746 | |
| 747 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 748 | if (ret) |
| 749 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 750 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 751 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 752 | for_each_ring(ring, dev_priv, i) |
| 753 | i915_ring_seqno_info(m, ring); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 754 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 755 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 756 | mutex_unlock(&dev->struct_mutex); |
| 757 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 758 | return 0; |
| 759 | } |
| 760 | |
| 761 | |
| 762 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 763 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 764 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 765 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 766 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 767 | struct intel_engine_cs *ring; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 768 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 769 | |
| 770 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 771 | if (ret) |
| 772 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 773 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 774 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 775 | if (IS_CHERRYVIEW(dev)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 776 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 777 | I915_READ(GEN8_MASTER_IRQ)); |
| 778 | |
| 779 | seq_printf(m, "Display IER:\t%08x\n", |
| 780 | I915_READ(VLV_IER)); |
| 781 | seq_printf(m, "Display IIR:\t%08x\n", |
| 782 | I915_READ(VLV_IIR)); |
| 783 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 784 | I915_READ(VLV_IIR_RW)); |
| 785 | seq_printf(m, "Display IMR:\t%08x\n", |
| 786 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 787 | for_each_pipe(dev_priv, pipe) |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 788 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 789 | pipe_name(pipe), |
| 790 | I915_READ(PIPESTAT(pipe))); |
| 791 | |
| 792 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 793 | I915_READ(PORT_HOTPLUG_EN)); |
| 794 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 795 | I915_READ(VLV_DPFLIPSTAT)); |
| 796 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 797 | I915_READ(DPINVGTT)); |
| 798 | |
| 799 | for (i = 0; i < 4; i++) { |
| 800 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 801 | i, I915_READ(GEN8_GT_IMR(i))); |
| 802 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 803 | i, I915_READ(GEN8_GT_IIR(i))); |
| 804 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 805 | i, I915_READ(GEN8_GT_IER(i))); |
| 806 | } |
| 807 | |
| 808 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 809 | I915_READ(GEN8_PCU_IMR)); |
| 810 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 811 | I915_READ(GEN8_PCU_IIR)); |
| 812 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 813 | I915_READ(GEN8_PCU_IER)); |
| 814 | } else if (INTEL_INFO(dev)->gen >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 815 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 816 | I915_READ(GEN8_MASTER_IRQ)); |
| 817 | |
| 818 | for (i = 0; i < 4; i++) { |
| 819 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 820 | i, I915_READ(GEN8_GT_IMR(i))); |
| 821 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 822 | i, I915_READ(GEN8_GT_IIR(i))); |
| 823 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 824 | i, I915_READ(GEN8_GT_IER(i))); |
| 825 | } |
| 826 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 827 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 828 | if (!intel_display_power_is_enabled(dev_priv, |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 829 | POWER_DOMAIN_PIPE(pipe))) { |
| 830 | seq_printf(m, "Pipe %c power disabled\n", |
| 831 | pipe_name(pipe)); |
| 832 | continue; |
| 833 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 834 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 835 | pipe_name(pipe), |
| 836 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 837 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 838 | pipe_name(pipe), |
| 839 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 840 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 841 | pipe_name(pipe), |
| 842 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 846 | I915_READ(GEN8_DE_PORT_IMR)); |
| 847 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 848 | I915_READ(GEN8_DE_PORT_IIR)); |
| 849 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 850 | I915_READ(GEN8_DE_PORT_IER)); |
| 851 | |
| 852 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 853 | I915_READ(GEN8_DE_MISC_IMR)); |
| 854 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 855 | I915_READ(GEN8_DE_MISC_IIR)); |
| 856 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 857 | I915_READ(GEN8_DE_MISC_IER)); |
| 858 | |
| 859 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 860 | I915_READ(GEN8_PCU_IMR)); |
| 861 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 862 | I915_READ(GEN8_PCU_IIR)); |
| 863 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 864 | I915_READ(GEN8_PCU_IER)); |
| 865 | } else if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 866 | seq_printf(m, "Display IER:\t%08x\n", |
| 867 | I915_READ(VLV_IER)); |
| 868 | seq_printf(m, "Display IIR:\t%08x\n", |
| 869 | I915_READ(VLV_IIR)); |
| 870 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 871 | I915_READ(VLV_IIR_RW)); |
| 872 | seq_printf(m, "Display IMR:\t%08x\n", |
| 873 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 874 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 875 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 876 | pipe_name(pipe), |
| 877 | I915_READ(PIPESTAT(pipe))); |
| 878 | |
| 879 | seq_printf(m, "Master IER:\t%08x\n", |
| 880 | I915_READ(VLV_MASTER_IER)); |
| 881 | |
| 882 | seq_printf(m, "Render IER:\t%08x\n", |
| 883 | I915_READ(GTIER)); |
| 884 | seq_printf(m, "Render IIR:\t%08x\n", |
| 885 | I915_READ(GTIIR)); |
| 886 | seq_printf(m, "Render IMR:\t%08x\n", |
| 887 | I915_READ(GTIMR)); |
| 888 | |
| 889 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 890 | I915_READ(GEN6_PMIER)); |
| 891 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 892 | I915_READ(GEN6_PMIIR)); |
| 893 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 894 | I915_READ(GEN6_PMIMR)); |
| 895 | |
| 896 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 897 | I915_READ(PORT_HOTPLUG_EN)); |
| 898 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 899 | I915_READ(VLV_DPFLIPSTAT)); |
| 900 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 901 | I915_READ(DPINVGTT)); |
| 902 | |
| 903 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 904 | seq_printf(m, "Interrupt enable: %08x\n", |
| 905 | I915_READ(IER)); |
| 906 | seq_printf(m, "Interrupt identity: %08x\n", |
| 907 | I915_READ(IIR)); |
| 908 | seq_printf(m, "Interrupt mask: %08x\n", |
| 909 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 910 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 911 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 912 | pipe_name(pipe), |
| 913 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 914 | } else { |
| 915 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 916 | I915_READ(DEIER)); |
| 917 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 918 | I915_READ(DEIIR)); |
| 919 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 920 | I915_READ(DEIMR)); |
| 921 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 922 | I915_READ(SDEIER)); |
| 923 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 924 | I915_READ(SDEIIR)); |
| 925 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 926 | I915_READ(SDEIMR)); |
| 927 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 928 | I915_READ(GTIER)); |
| 929 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 930 | I915_READ(GTIIR)); |
| 931 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 932 | I915_READ(GTIMR)); |
| 933 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 934 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 935 | if (INTEL_INFO(dev)->gen >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 936 | seq_printf(m, |
| 937 | "Graphics Interrupt mask (%s): %08x\n", |
| 938 | ring->name, I915_READ_IMR(ring)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 939 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 940 | i915_ring_seqno_info(m, ring); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 941 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 942 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 943 | mutex_unlock(&dev->struct_mutex); |
| 944 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 945 | return 0; |
| 946 | } |
| 947 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 948 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 949 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 950 | struct drm_info_node *node = m->private; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 951 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 952 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 953 | int i, ret; |
| 954 | |
| 955 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 956 | if (ret) |
| 957 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 958 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 959 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 960 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 961 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 962 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 963 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 964 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 965 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 966 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 967 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 968 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 969 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 970 | } |
| 971 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 972 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 973 | return 0; |
| 974 | } |
| 975 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 976 | static int i915_hws_info(struct seq_file *m, void *data) |
| 977 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 978 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 979 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 980 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 981 | struct intel_engine_cs *ring; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 982 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 983 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 984 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 985 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 986 | hws = ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 987 | if (hws == NULL) |
| 988 | return 0; |
| 989 | |
| 990 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 991 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 992 | i * 4, |
| 993 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 994 | } |
| 995 | return 0; |
| 996 | } |
| 997 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 998 | static ssize_t |
| 999 | i915_error_state_write(struct file *filp, |
| 1000 | const char __user *ubuf, |
| 1001 | size_t cnt, |
| 1002 | loff_t *ppos) |
| 1003 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1004 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1005 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1006 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1007 | |
| 1008 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 1009 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1010 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1011 | if (ret) |
| 1012 | return ret; |
| 1013 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1014 | i915_destroy_error_state(dev); |
| 1015 | mutex_unlock(&dev->struct_mutex); |
| 1016 | |
| 1017 | return cnt; |
| 1018 | } |
| 1019 | |
| 1020 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1021 | { |
| 1022 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1023 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1024 | |
| 1025 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 1026 | if (!error_priv) |
| 1027 | return -ENOMEM; |
| 1028 | |
| 1029 | error_priv->dev = dev; |
| 1030 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1031 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1032 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1033 | file->private_data = error_priv; |
| 1034 | |
| 1035 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 1039 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1040 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1041 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1042 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1043 | kfree(error_priv); |
| 1044 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1045 | return 0; |
| 1046 | } |
| 1047 | |
| 1048 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1049 | size_t count, loff_t *pos) |
| 1050 | { |
| 1051 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1052 | struct drm_i915_error_state_buf error_str; |
| 1053 | loff_t tmp_pos = 0; |
| 1054 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1055 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1056 | |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 1057 | 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] | 1058 | if (ret) |
| 1059 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1060 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1061 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1062 | if (ret) |
| 1063 | goto out; |
| 1064 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1065 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1066 | error_str.buf, |
| 1067 | error_str.bytes); |
| 1068 | |
| 1069 | if (ret_count < 0) |
| 1070 | ret = ret_count; |
| 1071 | else |
| 1072 | *pos = error_str.start + ret_count; |
| 1073 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1074 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1075 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | static const struct file_operations i915_error_state_fops = { |
| 1079 | .owner = THIS_MODULE, |
| 1080 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1081 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1082 | .write = i915_error_state_write, |
| 1083 | .llseek = default_llseek, |
| 1084 | .release = i915_error_state_release, |
| 1085 | }; |
| 1086 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1087 | static int |
| 1088 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1089 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1090 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1091 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1092 | int ret; |
| 1093 | |
| 1094 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1095 | if (ret) |
| 1096 | return ret; |
| 1097 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1098 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1099 | mutex_unlock(&dev->struct_mutex); |
| 1100 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1101 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1102 | } |
| 1103 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1104 | static int |
| 1105 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1106 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1107 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1108 | int ret; |
| 1109 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1110 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1111 | if (ret) |
| 1112 | return ret; |
| 1113 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 1114 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1115 | mutex_unlock(&dev->struct_mutex); |
| 1116 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1117 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1118 | } |
| 1119 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1120 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1121 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1122 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1123 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1124 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1125 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1126 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1127 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1128 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1129 | int ret = 0; |
| 1130 | |
| 1131 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1132 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1133 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1134 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1135 | if (IS_GEN5(dev)) { |
| 1136 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1137 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1138 | |
| 1139 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1140 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1141 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1142 | MEMSTAT_VID_SHIFT); |
| 1143 | seq_printf(m, "Current P-state: %d\n", |
| 1144 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1145 | } else if (IS_GEN6(dev) || (IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) || |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1146 | IS_BROADWELL(dev) || IS_GEN9(dev)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1147 | u32 rp_state_limits; |
| 1148 | u32 gt_perf_status; |
| 1149 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1150 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1151 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1152 | u32 rpupei, rpcurup, rpprevup; |
| 1153 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1154 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1155 | int max_freq; |
| 1156 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1157 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 1158 | if (IS_BROXTON(dev)) { |
| 1159 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1160 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1161 | } else { |
| 1162 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1163 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1164 | } |
| 1165 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1166 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1167 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1168 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1169 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1170 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1171 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1172 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1173 | reqf = I915_READ(GEN6_RPNSWREQ); |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1174 | if (IS_GEN9(dev)) |
| 1175 | reqf >>= 23; |
| 1176 | else { |
| 1177 | reqf &= ~GEN6_TURBO_DISABLE; |
| 1178 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
| 1179 | reqf >>= 24; |
| 1180 | else |
| 1181 | reqf >>= 25; |
| 1182 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1183 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1184 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1185 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1186 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1187 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1188 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1189 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 1190 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 1191 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 1192 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 1193 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 1194 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 1195 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1196 | if (IS_GEN9(dev)) |
| 1197 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
| 1198 | else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1199 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1200 | else |
| 1201 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1202 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1203 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1204 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1205 | mutex_unlock(&dev->struct_mutex); |
| 1206 | |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1207 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1208 | pm_ier = I915_READ(GEN6_PMIER); |
| 1209 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1210 | pm_isr = I915_READ(GEN6_PMISR); |
| 1211 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1212 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1213 | } else { |
| 1214 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1215 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1216 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1217 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1218 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1219 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1220 | 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] | 1221 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1222 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1223 | seq_printf(m, "Render p-state ratio: %d\n", |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1224 | (gt_perf_status & (IS_GEN9(dev) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1225 | seq_printf(m, "Render p-state VID: %d\n", |
| 1226 | gt_perf_status & 0xff); |
| 1227 | seq_printf(m, "Render p-state limit: %d\n", |
| 1228 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1229 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1230 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1231 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1232 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1233 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1234 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1235 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 1236 | GEN6_CURICONT_MASK); |
| 1237 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 1238 | GEN6_CURBSYTAVG_MASK); |
| 1239 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 1240 | GEN6_CURBSYTAVG_MASK); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1241 | seq_printf(m, "Up threshold: %d%%\n", |
| 1242 | dev_priv->rps.up_threshold); |
| 1243 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1244 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 1245 | GEN6_CURIAVG_MASK); |
| 1246 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 1247 | GEN6_CURBSYTAVG_MASK); |
| 1248 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 1249 | GEN6_CURBSYTAVG_MASK); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1250 | seq_printf(m, "Down threshold: %d%%\n", |
| 1251 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1252 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1253 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 0 : |
| 1254 | rp_state_cap >> 16) & 0xff; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1255 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1256 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1257 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1258 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1259 | |
| 1260 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1261 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1262 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1263 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1264 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1265 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame] | 1266 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 16 : |
| 1267 | rp_state_cap >> 0) & 0xff; |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1268 | max_freq *= (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1269 | GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1270 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1271 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1272 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1273 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1274 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1275 | seq_printf(m, "Current freq: %d MHz\n", |
| 1276 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1277 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1278 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1279 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1280 | seq_printf(m, "Min freq: %d MHz\n", |
| 1281 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1282 | seq_printf(m, "Max freq: %d MHz\n", |
| 1283 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1284 | seq_printf(m, |
| 1285 | "efficient (RPe) frequency: %d MHz\n", |
| 1286 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1287 | } else if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1288 | u32 freq_sts; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1289 | |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1290 | mutex_lock(&dev_priv->rps.hw_lock); |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 1291 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1292 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1293 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1294 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1295 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1296 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1297 | |
| 1298 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1299 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1300 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1301 | seq_printf(m, "max GPU freq: %d MHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1302 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1303 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1304 | seq_printf(m, "min GPU freq: %d MHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1305 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1306 | |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1307 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1308 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1309 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1310 | seq_printf(m, |
| 1311 | "efficient (RPe) frequency: %d MHz\n", |
| 1312 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1313 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1314 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1315 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1316 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1317 | |
Mika Kahola | 1170f28 | 2015-09-25 14:00:32 +0300 | [diff] [blame] | 1318 | seq_printf(m, "Current CD clock frequency: %d kHz\n", dev_priv->cdclk_freq); |
| 1319 | seq_printf(m, "Max CD clock frequency: %d kHz\n", dev_priv->max_cdclk_freq); |
| 1320 | seq_printf(m, "Max pixel clock frequency: %d kHz\n", dev_priv->max_dotclk_freq); |
| 1321 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1322 | out: |
| 1323 | intel_runtime_pm_put(dev_priv); |
| 1324 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1325 | } |
| 1326 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1327 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1328 | { |
| 1329 | struct drm_info_node *node = m->private; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1330 | struct drm_device *dev = node->minor->dev; |
| 1331 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1332 | struct intel_engine_cs *ring; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1333 | u64 acthd[I915_NUM_RINGS]; |
| 1334 | u32 seqno[I915_NUM_RINGS]; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1335 | int i; |
| 1336 | |
| 1337 | if (!i915.enable_hangcheck) { |
| 1338 | seq_printf(m, "Hangcheck disabled\n"); |
| 1339 | return 0; |
| 1340 | } |
| 1341 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1342 | intel_runtime_pm_get(dev_priv); |
| 1343 | |
| 1344 | for_each_ring(ring, dev_priv, i) { |
| 1345 | seqno[i] = ring->get_seqno(ring, false); |
| 1346 | acthd[i] = intel_ring_get_active_head(ring); |
| 1347 | } |
| 1348 | |
| 1349 | intel_runtime_pm_put(dev_priv); |
| 1350 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1351 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1352 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1353 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1354 | jiffies)); |
| 1355 | } else |
| 1356 | seq_printf(m, "Hangcheck inactive\n"); |
| 1357 | |
| 1358 | for_each_ring(ring, dev_priv, i) { |
| 1359 | seq_printf(m, "%s:\n", ring->name); |
| 1360 | seq_printf(m, "\tseqno = %x [current %x]\n", |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1361 | ring->hangcheck.seqno, seqno[i]); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1362 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
| 1363 | (long long)ring->hangcheck.acthd, |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1364 | (long long)acthd[i]); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1365 | seq_printf(m, "\tmax ACTHD = 0x%08llx\n", |
| 1366 | (long long)ring->hangcheck.max_acthd); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1367 | seq_printf(m, "\tscore = %d\n", ring->hangcheck.score); |
| 1368 | seq_printf(m, "\taction = %d\n", ring->hangcheck.action); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1369 | } |
| 1370 | |
| 1371 | return 0; |
| 1372 | } |
| 1373 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1374 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1375 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1376 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1377 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1378 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1379 | u32 rgvmodectl, rstdbyctl; |
| 1380 | u16 crstandvid; |
| 1381 | int ret; |
| 1382 | |
| 1383 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1384 | if (ret) |
| 1385 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1386 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1387 | |
| 1388 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1389 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1390 | crstandvid = I915_READ16(CRSTANDVID); |
| 1391 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1392 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1393 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1394 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1395 | seq_printf(m, "HD boost: %s\n", yesno(rgvmodectl & MEMMODE_BOOST_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1396 | seq_printf(m, "Boost freq: %d\n", |
| 1397 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1398 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1399 | seq_printf(m, "HW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1400 | yesno(rgvmodectl & MEMMODE_HWIDLE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1401 | seq_printf(m, "SW control enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1402 | yesno(rgvmodectl & MEMMODE_SWMODE_EN)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1403 | seq_printf(m, "Gated voltage change: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1404 | yesno(rgvmodectl & MEMMODE_RCLK_GATE)); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1405 | seq_printf(m, "Starting frequency: P%d\n", |
| 1406 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1407 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1408 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1409 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1410 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1411 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1412 | seq_printf(m, "Render standby enabled: %s\n", |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 1413 | yesno(!(rstdbyctl & RCX_SW_EXIT))); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1414 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1415 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1416 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1417 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1418 | break; |
| 1419 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1420 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1421 | break; |
| 1422 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1423 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1424 | break; |
| 1425 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1426 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1427 | break; |
| 1428 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1429 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1430 | break; |
| 1431 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1432 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1433 | break; |
| 1434 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1435 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1436 | break; |
| 1437 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1438 | |
| 1439 | return 0; |
| 1440 | } |
| 1441 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1442 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1443 | { |
| 1444 | struct drm_info_node *node = m->private; |
| 1445 | struct drm_device *dev = node->minor->dev; |
| 1446 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1447 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1448 | int i; |
| 1449 | |
| 1450 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1451 | for_each_fw_domain(fw_domain, dev_priv, i) { |
| 1452 | seq_printf(m, "%s.wake_count = %u\n", |
Mika Kuoppala | 05a2fb1 | 2015-01-19 16:20:43 +0200 | [diff] [blame] | 1453 | intel_uncore_forcewake_domain_to_str(i), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1454 | fw_domain->wake_count); |
| 1455 | } |
| 1456 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1457 | |
| 1458 | return 0; |
| 1459 | } |
| 1460 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1461 | static int vlv_drpc_info(struct seq_file *m) |
| 1462 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1463 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1464 | struct drm_device *dev = node->minor->dev; |
| 1465 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1466 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1467 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1468 | intel_runtime_pm_get(dev_priv); |
| 1469 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1470 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1471 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1472 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1473 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1474 | intel_runtime_pm_put(dev_priv); |
| 1475 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1476 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1477 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1478 | seq_printf(m, "Turbo enabled: %s\n", |
| 1479 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1480 | seq_printf(m, "HW control enabled: %s\n", |
| 1481 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1482 | seq_printf(m, "SW control enabled: %s\n", |
| 1483 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1484 | GEN6_RP_MEDIA_SW_MODE)); |
| 1485 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1486 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1487 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1488 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1489 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1490 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1491 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1492 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1493 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1494 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1495 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1496 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1497 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1498 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1499 | } |
| 1500 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1501 | static int gen6_drpc_info(struct seq_file *m) |
| 1502 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1503 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1504 | struct drm_device *dev = node->minor->dev; |
| 1505 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1506 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1507 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1508 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1509 | |
| 1510 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1511 | if (ret) |
| 1512 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1513 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1514 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1515 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1516 | 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] | 1517 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1518 | |
| 1519 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1520 | seq_puts(m, "RC information inaccurate because somebody " |
| 1521 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1522 | } else { |
| 1523 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1524 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1525 | udelay(10); |
| 1526 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1527 | } |
| 1528 | |
Ville Syrjälä | 75aa3f6 | 2015-10-22 15:34:56 +0300 | [diff] [blame] | 1529 | gt_core_status = I915_READ_FW(GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1530 | 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] | 1531 | |
| 1532 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1533 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1534 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1535 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1536 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1537 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1538 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1539 | intel_runtime_pm_put(dev_priv); |
| 1540 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1541 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1542 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1543 | seq_printf(m, "HW control enabled: %s\n", |
| 1544 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1545 | seq_printf(m, "SW control enabled: %s\n", |
| 1546 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1547 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1548 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1549 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1550 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1551 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1552 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1553 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1554 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1555 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1556 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1557 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1558 | case GEN6_RC0: |
| 1559 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1560 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1561 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1562 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1563 | break; |
| 1564 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1565 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1566 | break; |
| 1567 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1568 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1569 | break; |
| 1570 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1571 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1572 | break; |
| 1573 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1574 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1575 | break; |
| 1576 | } |
| 1577 | |
| 1578 | seq_printf(m, "Core Power Down: %s\n", |
| 1579 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1580 | |
| 1581 | /* Not exactly sure what this is */ |
| 1582 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1583 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1584 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1585 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1586 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1587 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1588 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1589 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1590 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1591 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1592 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1593 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1594 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1595 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1596 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1597 | return 0; |
| 1598 | } |
| 1599 | |
| 1600 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1601 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1602 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1603 | struct drm_device *dev = node->minor->dev; |
| 1604 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1605 | if (IS_VALLEYVIEW(dev)) |
| 1606 | return vlv_drpc_info(m); |
Vedang Patel | ac66cf4 | 2014-08-26 10:42:51 -0700 | [diff] [blame] | 1607 | else if (INTEL_INFO(dev)->gen >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1608 | return gen6_drpc_info(m); |
| 1609 | else |
| 1610 | return ironlake_drpc_info(m); |
| 1611 | } |
| 1612 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1613 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1614 | { |
| 1615 | struct drm_info_node *node = m->private; |
| 1616 | struct drm_device *dev = node->minor->dev; |
| 1617 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1618 | |
| 1619 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1620 | dev_priv->fb_tracking.busy_bits); |
| 1621 | |
| 1622 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1623 | dev_priv->fb_tracking.flip_bits); |
| 1624 | |
| 1625 | return 0; |
| 1626 | } |
| 1627 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1628 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1629 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1630 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1631 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1632 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1633 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1634 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1635 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1636 | return 0; |
| 1637 | } |
| 1638 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1639 | intel_runtime_pm_get(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1640 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1641 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1642 | if (intel_fbc_is_active(dev_priv)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1643 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1644 | else |
| 1645 | seq_printf(m, "FBC disabled: %s\n", |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1646 | dev_priv->fbc.no_fbc_reason); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1647 | |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1648 | if (INTEL_INFO(dev_priv)->gen >= 7) |
| 1649 | seq_printf(m, "Compressing: %s\n", |
| 1650 | yesno(I915_READ(FBC_STATUS2) & |
| 1651 | FBC_COMPRESSION_MASK)); |
| 1652 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1653 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1654 | intel_runtime_pm_put(dev_priv); |
| 1655 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1656 | return 0; |
| 1657 | } |
| 1658 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1659 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1660 | { |
| 1661 | struct drm_device *dev = data; |
| 1662 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1663 | |
| 1664 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1665 | return -ENODEV; |
| 1666 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1667 | *val = dev_priv->fbc.false_color; |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1668 | |
| 1669 | return 0; |
| 1670 | } |
| 1671 | |
| 1672 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1673 | { |
| 1674 | struct drm_device *dev = data; |
| 1675 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1676 | u32 reg; |
| 1677 | |
| 1678 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1679 | return -ENODEV; |
| 1680 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1681 | mutex_lock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1682 | |
| 1683 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1684 | dev_priv->fbc.false_color = val; |
| 1685 | |
| 1686 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1687 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1688 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1689 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1690 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1691 | return 0; |
| 1692 | } |
| 1693 | |
| 1694 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1695 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1696 | "%llu\n"); |
| 1697 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1698 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1699 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1700 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1701 | struct drm_device *dev = node->minor->dev; |
| 1702 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1703 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1704 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1705 | seq_puts(m, "not supported\n"); |
| 1706 | return 0; |
| 1707 | } |
| 1708 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1709 | intel_runtime_pm_get(dev_priv); |
| 1710 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1711 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1712 | yesno(i915.enable_ips)); |
| 1713 | |
| 1714 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1715 | seq_puts(m, "Currently: unknown\n"); |
| 1716 | } else { |
| 1717 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1718 | seq_puts(m, "Currently: enabled\n"); |
| 1719 | else |
| 1720 | seq_puts(m, "Currently: disabled\n"); |
| 1721 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1722 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1723 | intel_runtime_pm_put(dev_priv); |
| 1724 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1725 | return 0; |
| 1726 | } |
| 1727 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1728 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1729 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1730 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1731 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1732 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1733 | bool sr_enabled = false; |
| 1734 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1735 | intel_runtime_pm_get(dev_priv); |
| 1736 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1737 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1738 | 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] | 1739 | else if (IS_CRESTLINE(dev) || IS_G4X(dev) || |
| 1740 | IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1741 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1742 | else if (IS_I915GM(dev)) |
| 1743 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1744 | else if (IS_PINEVIEW(dev)) |
| 1745 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
Ander Conselvan de Oliveira | 77b6455 | 2015-06-02 14:17:47 +0300 | [diff] [blame] | 1746 | else if (IS_VALLEYVIEW(dev)) |
| 1747 | sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1748 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1749 | intel_runtime_pm_put(dev_priv); |
| 1750 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1751 | seq_printf(m, "self-refresh: %s\n", |
| 1752 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1753 | |
| 1754 | return 0; |
| 1755 | } |
| 1756 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1757 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1758 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1759 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1760 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1761 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1762 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1763 | int ret; |
| 1764 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1765 | if (!IS_GEN5(dev)) |
| 1766 | return -ENODEV; |
| 1767 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1768 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1769 | if (ret) |
| 1770 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1771 | |
| 1772 | temp = i915_mch_val(dev_priv); |
| 1773 | chipset = i915_chipset_val(dev_priv); |
| 1774 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1775 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1776 | |
| 1777 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1778 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1779 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1780 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1781 | |
| 1782 | return 0; |
| 1783 | } |
| 1784 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1785 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1786 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1787 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1788 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1789 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1790 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1791 | int gpu_freq, ia_freq; |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1792 | unsigned int max_gpu_freq, min_gpu_freq; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1793 | |
Akash Goel | 97d3308 | 2015-06-29 14:50:23 +0530 | [diff] [blame] | 1794 | if (!HAS_CORE_RING_FREQ(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1795 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1796 | return 0; |
| 1797 | } |
| 1798 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1799 | intel_runtime_pm_get(dev_priv); |
| 1800 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1801 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1802 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1803 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1804 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1805 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1806 | |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1807 | if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) { |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1808 | /* Convert GT frequency to 50 HZ units */ |
| 1809 | min_gpu_freq = |
| 1810 | dev_priv->rps.min_freq_softlimit / GEN9_FREQ_SCALER; |
| 1811 | max_gpu_freq = |
| 1812 | dev_priv->rps.max_freq_softlimit / GEN9_FREQ_SCALER; |
| 1813 | } else { |
| 1814 | min_gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1815 | max_gpu_freq = dev_priv->rps.max_freq_softlimit; |
| 1816 | } |
| 1817 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1818 | 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] | 1819 | |
Akash Goel | f936ec3 | 2015-06-29 14:50:22 +0530 | [diff] [blame] | 1820 | 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] | 1821 | ia_freq = gpu_freq; |
| 1822 | sandybridge_pcode_read(dev_priv, |
| 1823 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1824 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1825 | 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] | 1826 | intel_gpu_freq(dev_priv, (gpu_freq * |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 1827 | (IS_SKYLAKE(dev) || IS_KABYLAKE(dev) ? |
| 1828 | GEN9_FREQ_SCALER : 1))), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1829 | ((ia_freq >> 0) & 0xff) * 100, |
| 1830 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1831 | } |
| 1832 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1833 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1834 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1835 | out: |
| 1836 | intel_runtime_pm_put(dev_priv); |
| 1837 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1838 | } |
| 1839 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1840 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1841 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1842 | struct drm_info_node *node = m->private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1843 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1844 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1845 | struct intel_opregion *opregion = &dev_priv->opregion; |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1846 | void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1847 | int ret; |
| 1848 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1849 | if (data == NULL) |
| 1850 | return -ENOMEM; |
| 1851 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1852 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1853 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1854 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1855 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1856 | if (opregion->header) { |
Williams, Dan J | 115719f | 2015-10-12 21:12:57 +0000 | [diff] [blame] | 1857 | memcpy(data, opregion->header, OPREGION_SIZE); |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1858 | seq_write(m, data, OPREGION_SIZE); |
| 1859 | } |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1860 | |
| 1861 | mutex_unlock(&dev->struct_mutex); |
| 1862 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1863 | out: |
| 1864 | kfree(data); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1865 | return 0; |
| 1866 | } |
| 1867 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1868 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1869 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1870 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1871 | struct drm_device *dev = node->minor->dev; |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1872 | struct intel_framebuffer *fbdev_fb = NULL; |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1873 | struct drm_framebuffer *drm_fb; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1874 | |
Daniel Vetter | 0695726 | 2015-08-10 13:34:08 +0200 | [diff] [blame] | 1875 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1876 | if (to_i915(dev)->fbdev) { |
| 1877 | fbdev_fb = to_intel_framebuffer(to_i915(dev)->fbdev->helper.fb); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1878 | |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1879 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", |
| 1880 | fbdev_fb->base.width, |
| 1881 | fbdev_fb->base.height, |
| 1882 | fbdev_fb->base.depth, |
| 1883 | fbdev_fb->base.bits_per_pixel, |
| 1884 | fbdev_fb->base.modifier[0], |
| 1885 | atomic_read(&fbdev_fb->base.refcount.refcount)); |
| 1886 | describe_obj(m, fbdev_fb->obj); |
| 1887 | seq_putc(m, '\n'); |
| 1888 | } |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1889 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1890 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1891 | mutex_lock(&dev->mode_config.fb_lock); |
Daniel Vetter | 3a58ee1 | 2015-07-10 19:02:51 +0200 | [diff] [blame] | 1892 | drm_for_each_fb(drm_fb, dev) { |
Namrta Salonie | b13b840 | 2015-11-27 13:43:11 +0530 | [diff] [blame] | 1893 | struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); |
| 1894 | if (fb == fbdev_fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1895 | continue; |
| 1896 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1897 | 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] | 1898 | fb->base.width, |
| 1899 | fb->base.height, |
| 1900 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1901 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1902 | fb->base.modifier[0], |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1903 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1904 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1905 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1906 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1907 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1908 | |
| 1909 | return 0; |
| 1910 | } |
| 1911 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1912 | static void describe_ctx_ringbuf(struct seq_file *m, |
| 1913 | struct intel_ringbuffer *ringbuf) |
| 1914 | { |
| 1915 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
| 1916 | ringbuf->space, ringbuf->head, ringbuf->tail, |
| 1917 | ringbuf->last_retired_head); |
| 1918 | } |
| 1919 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1920 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1921 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1922 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1923 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1924 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1925 | struct intel_engine_cs *ring; |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1926 | struct intel_context *ctx; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1927 | int ret, i; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1928 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1929 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1930 | if (ret) |
| 1931 | return ret; |
| 1932 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1933 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1934 | if (!i915.enable_execlists && |
| 1935 | ctx->legacy_hw_ctx.rcs_state == NULL) |
Chris Wilson | b77f699 | 2014-04-30 08:30:00 +0100 | [diff] [blame] | 1936 | continue; |
| 1937 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1938 | seq_puts(m, "HW context "); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 1939 | describe_ctx(m, ctx); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1940 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1941 | if (ring->default_context == ctx) |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1942 | seq_printf(m, "(default context %s) ", |
| 1943 | ring->name); |
| 1944 | } |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1945 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1946 | if (i915.enable_execlists) { |
| 1947 | seq_putc(m, '\n'); |
| 1948 | for_each_ring(ring, dev_priv, i) { |
| 1949 | struct drm_i915_gem_object *ctx_obj = |
| 1950 | ctx->engine[i].state; |
| 1951 | struct intel_ringbuffer *ringbuf = |
| 1952 | ctx->engine[i].ringbuf; |
| 1953 | |
| 1954 | seq_printf(m, "%s: ", ring->name); |
| 1955 | if (ctx_obj) |
| 1956 | describe_obj(m, ctx_obj); |
| 1957 | if (ringbuf) |
| 1958 | describe_ctx_ringbuf(m, ringbuf); |
| 1959 | seq_putc(m, '\n'); |
| 1960 | } |
| 1961 | } else { |
| 1962 | describe_obj(m, ctx->legacy_hw_ctx.rcs_state); |
| 1963 | } |
| 1964 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1965 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1966 | } |
| 1967 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1968 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1969 | |
| 1970 | return 0; |
| 1971 | } |
| 1972 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1973 | static void i915_dump_lrc_obj(struct seq_file *m, |
| 1974 | struct intel_engine_cs *ring, |
| 1975 | struct drm_i915_gem_object *ctx_obj) |
| 1976 | { |
| 1977 | struct page *page; |
| 1978 | uint32_t *reg_state; |
| 1979 | int j; |
| 1980 | unsigned long ggtt_offset = 0; |
| 1981 | |
| 1982 | if (ctx_obj == NULL) { |
| 1983 | seq_printf(m, "Context on %s with no gem object\n", |
| 1984 | ring->name); |
| 1985 | return; |
| 1986 | } |
| 1987 | |
| 1988 | seq_printf(m, "CONTEXT: %s %u\n", ring->name, |
| 1989 | intel_execlists_ctx_id(ctx_obj)); |
| 1990 | |
| 1991 | if (!i915_gem_obj_ggtt_bound(ctx_obj)) |
| 1992 | seq_puts(m, "\tNot bound in GGTT\n"); |
| 1993 | else |
| 1994 | ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj); |
| 1995 | |
| 1996 | if (i915_gem_object_get_pages(ctx_obj)) { |
| 1997 | seq_puts(m, "\tFailed to get pages for context object\n"); |
| 1998 | return; |
| 1999 | } |
| 2000 | |
Alex Dai | d167519 | 2015-08-12 15:43:43 +0100 | [diff] [blame] | 2001 | page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2002 | if (!WARN_ON(page == NULL)) { |
| 2003 | reg_state = kmap_atomic(page); |
| 2004 | |
| 2005 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 2006 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2007 | ggtt_offset + 4096 + (j * 4), |
| 2008 | reg_state[j], reg_state[j + 1], |
| 2009 | reg_state[j + 2], reg_state[j + 3]); |
| 2010 | } |
| 2011 | kunmap_atomic(reg_state); |
| 2012 | } |
| 2013 | |
| 2014 | seq_putc(m, '\n'); |
| 2015 | } |
| 2016 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2017 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 2018 | { |
| 2019 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2020 | struct drm_device *dev = node->minor->dev; |
| 2021 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2022 | struct intel_engine_cs *ring; |
| 2023 | struct intel_context *ctx; |
| 2024 | int ret, i; |
| 2025 | |
| 2026 | if (!i915.enable_execlists) { |
| 2027 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 2028 | return 0; |
| 2029 | } |
| 2030 | |
| 2031 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2032 | if (ret) |
| 2033 | return ret; |
| 2034 | |
| 2035 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
| 2036 | for_each_ring(ring, dev_priv, i) { |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2037 | if (ring->default_context != ctx) |
| 2038 | i915_dump_lrc_obj(m, ring, |
| 2039 | ctx->engine[i].state); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | mutex_unlock(&dev->struct_mutex); |
| 2044 | |
| 2045 | return 0; |
| 2046 | } |
| 2047 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2048 | static int i915_execlists(struct seq_file *m, void *data) |
| 2049 | { |
| 2050 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 2051 | struct drm_device *dev = node->minor->dev; |
| 2052 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2053 | struct intel_engine_cs *ring; |
| 2054 | u32 status_pointer; |
| 2055 | u8 read_pointer; |
| 2056 | u8 write_pointer; |
| 2057 | u32 status; |
| 2058 | u32 ctx_id; |
| 2059 | struct list_head *cursor; |
| 2060 | int ring_id, i; |
| 2061 | int ret; |
| 2062 | |
| 2063 | if (!i915.enable_execlists) { |
| 2064 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 2065 | return 0; |
| 2066 | } |
| 2067 | |
| 2068 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2069 | if (ret) |
| 2070 | return ret; |
| 2071 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2072 | intel_runtime_pm_get(dev_priv); |
| 2073 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2074 | for_each_ring(ring, dev_priv, ring_id) { |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2075 | struct drm_i915_gem_request *head_req = NULL; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2076 | int count = 0; |
| 2077 | unsigned long flags; |
| 2078 | |
| 2079 | seq_printf(m, "%s\n", ring->name); |
| 2080 | |
Ville Syrjälä | 83843d8 | 2015-09-18 20:03:15 +0300 | [diff] [blame] | 2081 | status = I915_READ(RING_EXECLIST_STATUS_LO(ring)); |
| 2082 | ctx_id = I915_READ(RING_EXECLIST_STATUS_HI(ring)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2083 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 2084 | status, ctx_id); |
| 2085 | |
| 2086 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring)); |
| 2087 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 2088 | |
| 2089 | read_pointer = ring->next_context_status_buffer; |
| 2090 | write_pointer = status_pointer & 0x07; |
| 2091 | if (read_pointer > write_pointer) |
| 2092 | write_pointer += 6; |
| 2093 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 2094 | read_pointer, write_pointer); |
| 2095 | |
| 2096 | for (i = 0; i < 6; i++) { |
Ville Syrjälä | 83843d8 | 2015-09-18 20:03:15 +0300 | [diff] [blame] | 2097 | status = I915_READ(RING_CONTEXT_STATUS_BUF_LO(ring, i)); |
| 2098 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF_HI(ring, i)); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2099 | |
| 2100 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 2101 | i, status, ctx_id); |
| 2102 | } |
| 2103 | |
| 2104 | spin_lock_irqsave(&ring->execlist_lock, flags); |
| 2105 | list_for_each(cursor, &ring->execlist_queue) |
| 2106 | count++; |
| 2107 | head_req = list_first_entry_or_null(&ring->execlist_queue, |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2108 | struct drm_i915_gem_request, execlist_link); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2109 | spin_unlock_irqrestore(&ring->execlist_lock, flags); |
| 2110 | |
| 2111 | seq_printf(m, "\t%d requests in queue\n", count); |
| 2112 | if (head_req) { |
| 2113 | struct drm_i915_gem_object *ctx_obj; |
| 2114 | |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2115 | ctx_obj = head_req->ctx->engine[ring_id].state; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2116 | seq_printf(m, "\tHead request id: %u\n", |
| 2117 | intel_execlists_ctx_id(ctx_obj)); |
| 2118 | seq_printf(m, "\tHead request tail: %u\n", |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2119 | head_req->tail); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2120 | } |
| 2121 | |
| 2122 | seq_putc(m, '\n'); |
| 2123 | } |
| 2124 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2125 | intel_runtime_pm_put(dev_priv); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2126 | mutex_unlock(&dev->struct_mutex); |
| 2127 | |
| 2128 | return 0; |
| 2129 | } |
| 2130 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2131 | static const char *swizzle_string(unsigned swizzle) |
| 2132 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2133 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2134 | case I915_BIT_6_SWIZZLE_NONE: |
| 2135 | return "none"; |
| 2136 | case I915_BIT_6_SWIZZLE_9: |
| 2137 | return "bit9"; |
| 2138 | case I915_BIT_6_SWIZZLE_9_10: |
| 2139 | return "bit9/bit10"; |
| 2140 | case I915_BIT_6_SWIZZLE_9_11: |
| 2141 | return "bit9/bit11"; |
| 2142 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2143 | return "bit9/bit10/bit11"; |
| 2144 | case I915_BIT_6_SWIZZLE_9_17: |
| 2145 | return "bit9/bit17"; |
| 2146 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2147 | return "bit9/bit10/bit17"; |
| 2148 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2149 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2150 | } |
| 2151 | |
| 2152 | return "bug"; |
| 2153 | } |
| 2154 | |
| 2155 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2156 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2157 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2158 | struct drm_device *dev = node->minor->dev; |
| 2159 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2160 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2161 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2162 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2163 | if (ret) |
| 2164 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2165 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2166 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2167 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2168 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2169 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2170 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2171 | |
| 2172 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 2173 | seq_printf(m, "DDC = 0x%08x\n", |
| 2174 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2175 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2176 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2177 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2178 | I915_READ16(C0DRB3)); |
| 2179 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2180 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2181 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2182 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2183 | I915_READ(MAD_DIMM_C0)); |
| 2184 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2185 | I915_READ(MAD_DIMM_C1)); |
| 2186 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2187 | I915_READ(MAD_DIMM_C2)); |
| 2188 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2189 | I915_READ(TILECTL)); |
Robert Beckett | 5907f5f | 2014-01-23 14:23:14 +0000 | [diff] [blame] | 2190 | if (INTEL_INFO(dev)->gen >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2191 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2192 | I915_READ(GAMTARBMODE)); |
| 2193 | else |
| 2194 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2195 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2196 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2197 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2198 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2199 | |
| 2200 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2201 | seq_puts(m, "L-shaped memory detected\n"); |
| 2202 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2203 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2204 | mutex_unlock(&dev->struct_mutex); |
| 2205 | |
| 2206 | return 0; |
| 2207 | } |
| 2208 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2209 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2210 | { |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 2211 | struct intel_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2212 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2213 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2214 | |
| 2215 | if (!ppgtt) { |
| 2216 | seq_printf(m, " no ppgtt for context %d\n", |
| 2217 | ctx->user_handle); |
| 2218 | return 0; |
| 2219 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2220 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2221 | if (i915_gem_context_is_default(ctx)) |
| 2222 | seq_puts(m, " default context:\n"); |
| 2223 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2224 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2225 | ppgtt->debug_dump(ppgtt, m); |
| 2226 | |
| 2227 | return 0; |
| 2228 | } |
| 2229 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2230 | 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] | 2231 | { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2232 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2233 | struct intel_engine_cs *ring; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2234 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2235 | int unused, i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2236 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2237 | if (!ppgtt) |
| 2238 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2239 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2240 | for_each_ring(ring, dev_priv, unused) { |
| 2241 | seq_printf(m, "%s\n", ring->name); |
| 2242 | for (i = 0; i < 4; i++) { |
Ville Syrjälä | d3a93cb | 2015-09-18 20:03:26 +0300 | [diff] [blame] | 2243 | u64 pdp = I915_READ(GEN8_RING_PDP_UDW(ring, i)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2244 | pdp <<= 32; |
Ville Syrjälä | d3a93cb | 2015-09-18 20:03:26 +0300 | [diff] [blame] | 2245 | pdp |= I915_READ(GEN8_RING_PDP_LDW(ring, i)); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2246 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2247 | } |
| 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2252 | { |
| 2253 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2254 | struct intel_engine_cs *ring; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2255 | int i; |
| 2256 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2257 | if (INTEL_INFO(dev)->gen == 6) |
| 2258 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2259 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 2260 | for_each_ring(ring, dev_priv, i) { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2261 | seq_printf(m, "%s\n", ring->name); |
| 2262 | if (INTEL_INFO(dev)->gen == 7) |
| 2263 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 2264 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 2265 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 2266 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 2267 | } |
| 2268 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2269 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2270 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2271 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2272 | 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] | 2273 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2274 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2275 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2276 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2277 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2278 | } |
| 2279 | |
| 2280 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2281 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2282 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2283 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2284 | struct drm_i915_private *dev_priv = dev->dev_private; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2285 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2286 | |
| 2287 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2288 | if (ret) |
| 2289 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2290 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2291 | |
| 2292 | if (INTEL_INFO(dev)->gen >= 8) |
| 2293 | gen8_ppgtt_info(m, dev); |
| 2294 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2295 | gen6_ppgtt_info(m, dev); |
| 2296 | |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2297 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2298 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2299 | struct task_struct *task; |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2300 | |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2301 | task = get_pid_task(file->pid, PIDTYPE_PID); |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2302 | if (!task) { |
| 2303 | ret = -ESRCH; |
| 2304 | goto out_put; |
| 2305 | } |
Geliang Tang | 7cb5dff | 2015-09-25 03:58:11 -0700 | [diff] [blame] | 2306 | seq_printf(m, "\nproc: %s\n", task->comm); |
| 2307 | put_task_struct(task); |
Michel Thierry | ea91e40 | 2015-07-29 17:23:57 +0100 | [diff] [blame] | 2308 | idr_for_each(&file_priv->context_idr, per_file_ctx, |
| 2309 | (void *)(unsigned long)m); |
| 2310 | } |
| 2311 | |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2312 | out_put: |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2313 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2314 | mutex_unlock(&dev->struct_mutex); |
| 2315 | |
Dan Carpenter | 0681276 | 2015-10-02 18:14:22 +0300 | [diff] [blame] | 2316 | return ret; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2317 | } |
| 2318 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2319 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2320 | { |
| 2321 | struct intel_engine_cs *ring; |
| 2322 | int count = 0; |
| 2323 | int i; |
| 2324 | |
| 2325 | for_each_ring(ring, i915, i) |
| 2326 | count += ring->irq_refcount; |
| 2327 | |
| 2328 | return count; |
| 2329 | } |
| 2330 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2331 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2332 | { |
| 2333 | struct drm_info_node *node = m->private; |
| 2334 | struct drm_device *dev = node->minor->dev; |
| 2335 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2336 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2337 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2338 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
| 2339 | seq_printf(m, "GPU busy? %d\n", dev_priv->mm.busy); |
| 2340 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
| 2341 | seq_printf(m, "Frequency requested %d; min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
| 2342 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq), |
| 2343 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2344 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2345 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2346 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2347 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2348 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2349 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2350 | struct task_struct *task; |
| 2351 | |
| 2352 | rcu_read_lock(); |
| 2353 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2354 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2355 | task ? task->comm : "<unknown>", |
| 2356 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2357 | file_priv->rps.boosts, |
| 2358 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2359 | rcu_read_unlock(); |
| 2360 | } |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2361 | seq_printf(m, "Semaphore boosts: %d%s\n", |
| 2362 | dev_priv->rps.semaphores.boosts, |
| 2363 | list_empty(&dev_priv->rps.semaphores.link) ? "" : ", active"); |
| 2364 | seq_printf(m, "MMIO flip boosts: %d%s\n", |
| 2365 | dev_priv->rps.mmioflips.boosts, |
| 2366 | list_empty(&dev_priv->rps.mmioflips.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2367 | seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2368 | spin_unlock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2369 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2370 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2371 | } |
| 2372 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2373 | static int i915_llc(struct seq_file *m, void *data) |
| 2374 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2375 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2376 | struct drm_device *dev = node->minor->dev; |
| 2377 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2378 | |
| 2379 | /* Size calculation for LLC is a bit of a pain. Ignore for now. */ |
| 2380 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
| 2381 | seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size); |
| 2382 | |
| 2383 | return 0; |
| 2384 | } |
| 2385 | |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2386 | static int i915_guc_load_status_info(struct seq_file *m, void *data) |
| 2387 | { |
| 2388 | struct drm_info_node *node = m->private; |
| 2389 | struct drm_i915_private *dev_priv = node->minor->dev->dev_private; |
| 2390 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
| 2391 | u32 tmp, i; |
| 2392 | |
| 2393 | if (!HAS_GUC_UCODE(dev_priv->dev)) |
| 2394 | return 0; |
| 2395 | |
| 2396 | seq_printf(m, "GuC firmware status:\n"); |
| 2397 | seq_printf(m, "\tpath: %s\n", |
| 2398 | guc_fw->guc_fw_path); |
| 2399 | seq_printf(m, "\tfetch: %s\n", |
| 2400 | intel_guc_fw_status_repr(guc_fw->guc_fw_fetch_status)); |
| 2401 | seq_printf(m, "\tload: %s\n", |
| 2402 | intel_guc_fw_status_repr(guc_fw->guc_fw_load_status)); |
| 2403 | seq_printf(m, "\tversion wanted: %d.%d\n", |
| 2404 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
| 2405 | seq_printf(m, "\tversion found: %d.%d\n", |
| 2406 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 2407 | seq_printf(m, "\theader: offset is %d; size = %d\n", |
| 2408 | guc_fw->header_offset, guc_fw->header_size); |
| 2409 | seq_printf(m, "\tuCode: offset is %d; size = %d\n", |
| 2410 | guc_fw->ucode_offset, guc_fw->ucode_size); |
| 2411 | seq_printf(m, "\tRSA: offset is %d; size = %d\n", |
| 2412 | guc_fw->rsa_offset, guc_fw->rsa_size); |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 2413 | |
| 2414 | tmp = I915_READ(GUC_STATUS); |
| 2415 | |
| 2416 | seq_printf(m, "\nGuC status 0x%08x:\n", tmp); |
| 2417 | seq_printf(m, "\tBootrom status = 0x%x\n", |
| 2418 | (tmp & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT); |
| 2419 | seq_printf(m, "\tuKernel status = 0x%x\n", |
| 2420 | (tmp & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT); |
| 2421 | seq_printf(m, "\tMIA Core status = 0x%x\n", |
| 2422 | (tmp & GS_MIA_MASK) >> GS_MIA_SHIFT); |
| 2423 | seq_puts(m, "\nScratch registers:\n"); |
| 2424 | for (i = 0; i < 16; i++) |
| 2425 | seq_printf(m, "\t%2d: \t0x%x\n", i, I915_READ(SOFT_SCRATCH(i))); |
| 2426 | |
| 2427 | return 0; |
| 2428 | } |
| 2429 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2430 | static void i915_guc_client_info(struct seq_file *m, |
| 2431 | struct drm_i915_private *dev_priv, |
| 2432 | struct i915_guc_client *client) |
| 2433 | { |
| 2434 | struct intel_engine_cs *ring; |
| 2435 | uint64_t tot = 0; |
| 2436 | uint32_t i; |
| 2437 | |
| 2438 | seq_printf(m, "\tPriority %d, GuC ctx index: %u, PD offset 0x%x\n", |
| 2439 | client->priority, client->ctx_index, client->proc_desc_offset); |
| 2440 | seq_printf(m, "\tDoorbell id %d, offset: 0x%x, cookie 0x%x\n", |
| 2441 | client->doorbell_id, client->doorbell_offset, client->cookie); |
| 2442 | seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n", |
| 2443 | client->wq_size, client->wq_offset, client->wq_tail); |
| 2444 | |
| 2445 | seq_printf(m, "\tFailed to queue: %u\n", client->q_fail); |
| 2446 | seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail); |
| 2447 | seq_printf(m, "\tLast submission result: %d\n", client->retcode); |
| 2448 | |
| 2449 | for_each_ring(ring, dev_priv, i) { |
| 2450 | seq_printf(m, "\tSubmissions: %llu %s\n", |
| 2451 | client->submissions[i], |
| 2452 | ring->name); |
| 2453 | tot += client->submissions[i]; |
| 2454 | } |
| 2455 | seq_printf(m, "\tTotal: %llu\n", tot); |
| 2456 | } |
| 2457 | |
| 2458 | static int i915_guc_info(struct seq_file *m, void *data) |
| 2459 | { |
| 2460 | struct drm_info_node *node = m->private; |
| 2461 | struct drm_device *dev = node->minor->dev; |
| 2462 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2463 | struct intel_guc guc; |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 2464 | struct i915_guc_client client = {}; |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2465 | struct intel_engine_cs *ring; |
| 2466 | enum intel_ring_id i; |
| 2467 | u64 total = 0; |
| 2468 | |
| 2469 | if (!HAS_GUC_SCHED(dev_priv->dev)) |
| 2470 | return 0; |
| 2471 | |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame^] | 2472 | if (mutex_lock_interruptible(&dev->struct_mutex)) |
| 2473 | return 0; |
| 2474 | |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2475 | /* 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] | 2476 | guc = dev_priv->guc; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame^] | 2477 | if (guc.execbuf_client) |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2478 | client = *guc.execbuf_client; |
Alex Dai | 5a84330 | 2015-12-02 16:56:29 -0800 | [diff] [blame^] | 2479 | |
| 2480 | mutex_unlock(&dev->struct_mutex); |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 2481 | |
| 2482 | seq_printf(m, "GuC total action count: %llu\n", guc.action_count); |
| 2483 | seq_printf(m, "GuC action failure count: %u\n", guc.action_fail); |
| 2484 | seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd); |
| 2485 | seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status); |
| 2486 | seq_printf(m, "GuC last action error code: %d\n", guc.action_err); |
| 2487 | |
| 2488 | seq_printf(m, "\nGuC submissions:\n"); |
| 2489 | for_each_ring(ring, dev_priv, i) { |
| 2490 | seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x %9d\n", |
| 2491 | ring->name, guc.submissions[i], |
| 2492 | guc.last_seqno[i], guc.last_seqno[i]); |
| 2493 | total += guc.submissions[i]; |
| 2494 | } |
| 2495 | seq_printf(m, "\t%s: %llu\n", "Total", total); |
| 2496 | |
| 2497 | seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client); |
| 2498 | i915_guc_client_info(m, dev_priv, &client); |
| 2499 | |
| 2500 | /* Add more as required ... */ |
| 2501 | |
| 2502 | return 0; |
| 2503 | } |
| 2504 | |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 2505 | static int i915_guc_log_dump(struct seq_file *m, void *data) |
| 2506 | { |
| 2507 | struct drm_info_node *node = m->private; |
| 2508 | struct drm_device *dev = node->minor->dev; |
| 2509 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2510 | struct drm_i915_gem_object *log_obj = dev_priv->guc.log_obj; |
| 2511 | u32 *log; |
| 2512 | int i = 0, pg; |
| 2513 | |
| 2514 | if (!log_obj) |
| 2515 | return 0; |
| 2516 | |
| 2517 | for (pg = 0; pg < log_obj->base.size / PAGE_SIZE; pg++) { |
| 2518 | log = kmap_atomic(i915_gem_object_get_page(log_obj, pg)); |
| 2519 | |
| 2520 | for (i = 0; i < PAGE_SIZE / sizeof(u32); i += 4) |
| 2521 | seq_printf(m, "0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 2522 | *(log + i), *(log + i + 1), |
| 2523 | *(log + i + 2), *(log + i + 3)); |
| 2524 | |
| 2525 | kunmap_atomic(log); |
| 2526 | } |
| 2527 | |
| 2528 | seq_putc(m, '\n'); |
| 2529 | |
| 2530 | return 0; |
| 2531 | } |
| 2532 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2533 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2534 | { |
| 2535 | struct drm_info_node *node = m->private; |
| 2536 | struct drm_device *dev = node->minor->dev; |
| 2537 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2538 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2539 | u32 stat[3]; |
| 2540 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2541 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2542 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2543 | if (!HAS_PSR(dev)) { |
| 2544 | seq_puts(m, "PSR not supported\n"); |
| 2545 | return 0; |
| 2546 | } |
| 2547 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2548 | intel_runtime_pm_get(dev_priv); |
| 2549 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2550 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2551 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2552 | 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] | 2553 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2554 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2555 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2556 | dev_priv->psr.busy_frontbuffer_bits); |
| 2557 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2558 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2559 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2560 | if (HAS_DDI(dev)) |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2561 | enabled = I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE; |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2562 | else { |
| 2563 | for_each_pipe(dev_priv, pipe) { |
| 2564 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2565 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2566 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2567 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2568 | enabled = true; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2569 | } |
| 2570 | } |
| 2571 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2572 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2573 | if (!HAS_DDI(dev)) |
| 2574 | for_each_pipe(dev_priv, pipe) { |
| 2575 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2576 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2577 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2578 | } |
| 2579 | seq_puts(m, "\n"); |
| 2580 | |
Rodrigo Vivi | 05eec3c | 2015-11-23 14:16:40 -0800 | [diff] [blame] | 2581 | /* |
| 2582 | * VLV/CHV PSR has no kind of performance counter |
| 2583 | * SKL+ Perf counter is reset to 0 everytime DC state is entered |
| 2584 | */ |
| 2585 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
Ville Syrjälä | 443a389 | 2015-11-11 20:34:15 +0200 | [diff] [blame] | 2586 | psrperf = I915_READ(EDP_PSR_PERF_CNT) & |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2587 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2588 | |
| 2589 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2590 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2591 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2592 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2593 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2594 | return 0; |
| 2595 | } |
| 2596 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2597 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2598 | { |
| 2599 | struct drm_info_node *node = m->private; |
| 2600 | struct drm_device *dev = node->minor->dev; |
| 2601 | struct intel_encoder *encoder; |
| 2602 | struct intel_connector *connector; |
| 2603 | struct intel_dp *intel_dp = NULL; |
| 2604 | int ret; |
| 2605 | u8 crc[6]; |
| 2606 | |
| 2607 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2608 | for_each_intel_connector(dev, connector) { |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2609 | |
| 2610 | if (connector->base.dpms != DRM_MODE_DPMS_ON) |
| 2611 | continue; |
| 2612 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2613 | if (!connector->base.encoder) |
| 2614 | continue; |
| 2615 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2616 | encoder = to_intel_encoder(connector->base.encoder); |
| 2617 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 2618 | continue; |
| 2619 | |
| 2620 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 2621 | |
| 2622 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2623 | if (ret) |
| 2624 | goto out; |
| 2625 | |
| 2626 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2627 | crc[0], crc[1], crc[2], |
| 2628 | crc[3], crc[4], crc[5]); |
| 2629 | goto out; |
| 2630 | } |
| 2631 | ret = -ENODEV; |
| 2632 | out: |
| 2633 | drm_modeset_unlock_all(dev); |
| 2634 | return ret; |
| 2635 | } |
| 2636 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2637 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2638 | { |
| 2639 | struct drm_info_node *node = m->private; |
| 2640 | struct drm_device *dev = node->minor->dev; |
| 2641 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2642 | u64 power; |
| 2643 | u32 units; |
| 2644 | |
| 2645 | if (INTEL_INFO(dev)->gen < 6) |
| 2646 | return -ENODEV; |
| 2647 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2648 | intel_runtime_pm_get(dev_priv); |
| 2649 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2650 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2651 | power = (power & 0x1f00) >> 8; |
| 2652 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2653 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2654 | power *= units; |
| 2655 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2656 | intel_runtime_pm_put(dev_priv); |
| 2657 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2658 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2659 | |
| 2660 | return 0; |
| 2661 | } |
| 2662 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2663 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2664 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2665 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2666 | struct drm_device *dev = node->minor->dev; |
| 2667 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2668 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2669 | if (!HAS_RUNTIME_PM(dev)) { |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2670 | seq_puts(m, "not supported\n"); |
| 2671 | return 0; |
| 2672 | } |
| 2673 | |
Paulo Zanoni | 86c4ec0 | 2014-02-21 13:52:24 -0300 | [diff] [blame] | 2674 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2675 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2676 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2677 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2678 | seq_printf(m, "Usage count: %d\n", |
| 2679 | atomic_read(&dev->dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2680 | #else |
| 2681 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2682 | #endif |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2683 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2684 | return 0; |
| 2685 | } |
| 2686 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2687 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2688 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2689 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2690 | struct drm_device *dev = node->minor->dev; |
| 2691 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2692 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2693 | int i; |
| 2694 | |
| 2695 | mutex_lock(&power_domains->lock); |
| 2696 | |
| 2697 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2698 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2699 | struct i915_power_well *power_well; |
| 2700 | enum intel_display_power_domain power_domain; |
| 2701 | |
| 2702 | power_well = &power_domains->power_wells[i]; |
| 2703 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2704 | power_well->count); |
| 2705 | |
| 2706 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2707 | power_domain++) { |
| 2708 | if (!(BIT(power_domain) & power_well->domains)) |
| 2709 | continue; |
| 2710 | |
| 2711 | seq_printf(m, " %-23s %d\n", |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 2712 | intel_display_power_domain_str(power_domain), |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2713 | power_domains->domain_use_count[power_domain]); |
| 2714 | } |
| 2715 | } |
| 2716 | |
| 2717 | mutex_unlock(&power_domains->lock); |
| 2718 | |
| 2719 | return 0; |
| 2720 | } |
| 2721 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2722 | static int i915_dmc_info(struct seq_file *m, void *unused) |
| 2723 | { |
| 2724 | struct drm_info_node *node = m->private; |
| 2725 | struct drm_device *dev = node->minor->dev; |
| 2726 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2727 | struct intel_csr *csr; |
| 2728 | |
| 2729 | if (!HAS_CSR(dev)) { |
| 2730 | seq_puts(m, "not supported\n"); |
| 2731 | return 0; |
| 2732 | } |
| 2733 | |
| 2734 | csr = &dev_priv->csr; |
| 2735 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2736 | intel_runtime_pm_get(dev_priv); |
| 2737 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2738 | seq_printf(m, "fw loaded: %s\n", yesno(csr->dmc_payload != NULL)); |
| 2739 | seq_printf(m, "path: %s\n", csr->fw_path); |
| 2740 | |
| 2741 | if (!csr->dmc_payload) |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2742 | goto out; |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2743 | |
| 2744 | seq_printf(m, "version: %d.%d\n", CSR_VERSION_MAJOR(csr->version), |
| 2745 | CSR_VERSION_MINOR(csr->version)); |
| 2746 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2747 | if (IS_SKYLAKE(dev) && csr->version >= CSR_VERSION(1, 6)) { |
| 2748 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2749 | I915_READ(SKL_CSR_DC3_DC5_COUNT)); |
| 2750 | seq_printf(m, "DC5 -> DC6 count: %d\n", |
| 2751 | I915_READ(SKL_CSR_DC5_DC6_COUNT)); |
Mika Kuoppala | 16e11b9 | 2015-10-27 14:47:03 +0200 | [diff] [blame] | 2752 | } else if (IS_BROXTON(dev) && csr->version >= CSR_VERSION(1, 4)) { |
| 2753 | seq_printf(m, "DC3 -> DC5 count: %d\n", |
| 2754 | I915_READ(BXT_CSR_DC3_DC5_COUNT)); |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2755 | } |
| 2756 | |
Mika Kuoppala | 6fb403d | 2015-10-30 17:54:47 +0200 | [diff] [blame] | 2757 | out: |
| 2758 | seq_printf(m, "program base: 0x%08x\n", I915_READ(CSR_PROGRAM(0))); |
| 2759 | seq_printf(m, "ssp base: 0x%08x\n", I915_READ(CSR_SSP_BASE)); |
| 2760 | seq_printf(m, "htp: 0x%08x\n", I915_READ(CSR_HTP_SKL)); |
| 2761 | |
Damien Lespiau | 8337206 | 2015-10-30 17:53:32 +0200 | [diff] [blame] | 2762 | intel_runtime_pm_put(dev_priv); |
| 2763 | |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 2764 | return 0; |
| 2765 | } |
| 2766 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2767 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2768 | struct drm_display_mode *mode) |
| 2769 | { |
| 2770 | int i; |
| 2771 | |
| 2772 | for (i = 0; i < tabs; i++) |
| 2773 | seq_putc(m, '\t'); |
| 2774 | |
| 2775 | 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", |
| 2776 | mode->base.id, mode->name, |
| 2777 | mode->vrefresh, mode->clock, |
| 2778 | mode->hdisplay, mode->hsync_start, |
| 2779 | mode->hsync_end, mode->htotal, |
| 2780 | mode->vdisplay, mode->vsync_start, |
| 2781 | mode->vsync_end, mode->vtotal, |
| 2782 | mode->type, mode->flags); |
| 2783 | } |
| 2784 | |
| 2785 | static void intel_encoder_info(struct seq_file *m, |
| 2786 | struct intel_crtc *intel_crtc, |
| 2787 | struct intel_encoder *intel_encoder) |
| 2788 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2789 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2790 | struct drm_device *dev = node->minor->dev; |
| 2791 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2792 | struct intel_connector *intel_connector; |
| 2793 | struct drm_encoder *encoder; |
| 2794 | |
| 2795 | encoder = &intel_encoder->base; |
| 2796 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2797 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2798 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2799 | struct drm_connector *connector = &intel_connector->base; |
| 2800 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2801 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2802 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2803 | drm_get_connector_status_name(connector->status)); |
| 2804 | if (connector->status == connector_status_connected) { |
| 2805 | struct drm_display_mode *mode = &crtc->mode; |
| 2806 | seq_printf(m, ", mode:\n"); |
| 2807 | intel_seq_print_mode(m, 2, mode); |
| 2808 | } else { |
| 2809 | seq_putc(m, '\n'); |
| 2810 | } |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2815 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2816 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2817 | struct drm_device *dev = node->minor->dev; |
| 2818 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2819 | struct intel_encoder *intel_encoder; |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2820 | struct drm_plane_state *plane_state = crtc->primary->state; |
| 2821 | struct drm_framebuffer *fb = plane_state->fb; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2822 | |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2823 | if (fb) |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2824 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
Maarten Lankhorst | 23a48d5 | 2015-09-10 16:07:57 +0200 | [diff] [blame] | 2825 | fb->base.id, plane_state->src_x >> 16, |
| 2826 | plane_state->src_y >> 16, fb->width, fb->height); |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2827 | else |
| 2828 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2829 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2830 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2831 | } |
| 2832 | |
| 2833 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2834 | { |
| 2835 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2836 | |
| 2837 | seq_printf(m, "\tfixed mode:\n"); |
| 2838 | intel_seq_print_mode(m, 2, mode); |
| 2839 | } |
| 2840 | |
| 2841 | static void intel_dp_info(struct seq_file *m, |
| 2842 | struct intel_connector *intel_connector) |
| 2843 | { |
| 2844 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2845 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2846 | |
| 2847 | 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] | 2848 | seq_printf(m, "\taudio support: %s\n", yesno(intel_dp->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2849 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2850 | intel_panel_info(m, &intel_connector->panel); |
| 2851 | } |
| 2852 | |
| 2853 | static void intel_hdmi_info(struct seq_file *m, |
| 2854 | struct intel_connector *intel_connector) |
| 2855 | { |
| 2856 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2857 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2858 | |
Jani Nikula | 742f491 | 2015-09-03 11:16:09 +0300 | [diff] [blame] | 2859 | seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2860 | } |
| 2861 | |
| 2862 | static void intel_lvds_info(struct seq_file *m, |
| 2863 | struct intel_connector *intel_connector) |
| 2864 | { |
| 2865 | intel_panel_info(m, &intel_connector->panel); |
| 2866 | } |
| 2867 | |
| 2868 | static void intel_connector_info(struct seq_file *m, |
| 2869 | struct drm_connector *connector) |
| 2870 | { |
| 2871 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2872 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2873 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2874 | |
| 2875 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2876 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2877 | drm_get_connector_status_name(connector->status)); |
| 2878 | if (connector->status == connector_status_connected) { |
| 2879 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2880 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2881 | connector->display_info.width_mm, |
| 2882 | connector->display_info.height_mm); |
| 2883 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2884 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2885 | seq_printf(m, "\tCEA rev: %d\n", |
| 2886 | connector->display_info.cea_rev); |
| 2887 | } |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2888 | if (intel_encoder) { |
| 2889 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2890 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2891 | intel_dp_info(m, intel_connector); |
| 2892 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2893 | intel_hdmi_info(m, intel_connector); |
| 2894 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2895 | intel_lvds_info(m, intel_connector); |
| 2896 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2897 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2898 | seq_printf(m, "\tmodes:\n"); |
| 2899 | list_for_each_entry(mode, &connector->modes, head) |
| 2900 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2901 | } |
| 2902 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2903 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 2904 | { |
| 2905 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2906 | u32 state; |
| 2907 | |
| 2908 | if (IS_845G(dev) || IS_I865G(dev)) |
Ville Syrjälä | 0b87c24 | 2015-09-22 19:47:51 +0300 | [diff] [blame] | 2909 | state = I915_READ(CURCNTR(PIPE_A)) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2910 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2911 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2912 | |
| 2913 | return state; |
| 2914 | } |
| 2915 | |
| 2916 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 2917 | { |
| 2918 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2919 | u32 pos; |
| 2920 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2921 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2922 | |
| 2923 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2924 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2925 | *x = -*x; |
| 2926 | |
| 2927 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2928 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2929 | *y = -*y; |
| 2930 | |
| 2931 | return cursor_active(dev, pipe); |
| 2932 | } |
| 2933 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 2934 | static const char *plane_type(enum drm_plane_type type) |
| 2935 | { |
| 2936 | switch (type) { |
| 2937 | case DRM_PLANE_TYPE_OVERLAY: |
| 2938 | return "OVL"; |
| 2939 | case DRM_PLANE_TYPE_PRIMARY: |
| 2940 | return "PRI"; |
| 2941 | case DRM_PLANE_TYPE_CURSOR: |
| 2942 | return "CUR"; |
| 2943 | /* |
| 2944 | * Deliberately omitting default: to generate compiler warnings |
| 2945 | * when a new drm_plane_type gets added. |
| 2946 | */ |
| 2947 | } |
| 2948 | |
| 2949 | return "unknown"; |
| 2950 | } |
| 2951 | |
| 2952 | static const char *plane_rotation(unsigned int rotation) |
| 2953 | { |
| 2954 | static char buf[48]; |
| 2955 | /* |
| 2956 | * According to doc only one DRM_ROTATE_ is allowed but this |
| 2957 | * will print them all to visualize if the values are misused |
| 2958 | */ |
| 2959 | snprintf(buf, sizeof(buf), |
| 2960 | "%s%s%s%s%s%s(0x%08x)", |
| 2961 | (rotation & BIT(DRM_ROTATE_0)) ? "0 " : "", |
| 2962 | (rotation & BIT(DRM_ROTATE_90)) ? "90 " : "", |
| 2963 | (rotation & BIT(DRM_ROTATE_180)) ? "180 " : "", |
| 2964 | (rotation & BIT(DRM_ROTATE_270)) ? "270 " : "", |
| 2965 | (rotation & BIT(DRM_REFLECT_X)) ? "FLIPX " : "", |
| 2966 | (rotation & BIT(DRM_REFLECT_Y)) ? "FLIPY " : "", |
| 2967 | rotation); |
| 2968 | |
| 2969 | return buf; |
| 2970 | } |
| 2971 | |
| 2972 | static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2973 | { |
| 2974 | struct drm_info_node *node = m->private; |
| 2975 | struct drm_device *dev = node->minor->dev; |
| 2976 | struct intel_plane *intel_plane; |
| 2977 | |
| 2978 | for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { |
| 2979 | struct drm_plane_state *state; |
| 2980 | struct drm_plane *plane = &intel_plane->base; |
| 2981 | |
| 2982 | if (!plane->state) { |
| 2983 | seq_puts(m, "plane->state is NULL!\n"); |
| 2984 | continue; |
| 2985 | } |
| 2986 | |
| 2987 | state = plane->state; |
| 2988 | |
| 2989 | 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", |
| 2990 | plane->base.id, |
| 2991 | plane_type(intel_plane->base.type), |
| 2992 | state->crtc_x, state->crtc_y, |
| 2993 | state->crtc_w, state->crtc_h, |
| 2994 | (state->src_x >> 16), |
| 2995 | ((state->src_x & 0xffff) * 15625) >> 10, |
| 2996 | (state->src_y >> 16), |
| 2997 | ((state->src_y & 0xffff) * 15625) >> 10, |
| 2998 | (state->src_w >> 16), |
| 2999 | ((state->src_w & 0xffff) * 15625) >> 10, |
| 3000 | (state->src_h >> 16), |
| 3001 | ((state->src_h & 0xffff) * 15625) >> 10, |
| 3002 | state->fb ? drm_get_format_name(state->fb->pixel_format) : "N/A", |
| 3003 | plane_rotation(state->rotation)); |
| 3004 | } |
| 3005 | } |
| 3006 | |
| 3007 | static void intel_scaler_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 3008 | { |
| 3009 | struct intel_crtc_state *pipe_config; |
| 3010 | int num_scalers = intel_crtc->num_scalers; |
| 3011 | int i; |
| 3012 | |
| 3013 | pipe_config = to_intel_crtc_state(intel_crtc->base.state); |
| 3014 | |
| 3015 | /* Not all platformas have a scaler */ |
| 3016 | if (num_scalers) { |
| 3017 | seq_printf(m, "\tnum_scalers=%d, scaler_users=%x scaler_id=%d", |
| 3018 | num_scalers, |
| 3019 | pipe_config->scaler_state.scaler_users, |
| 3020 | pipe_config->scaler_state.scaler_id); |
| 3021 | |
| 3022 | for (i = 0; i < SKL_NUM_SCALERS; i++) { |
| 3023 | struct intel_scaler *sc = |
| 3024 | &pipe_config->scaler_state.scalers[i]; |
| 3025 | |
| 3026 | seq_printf(m, ", scalers[%d]: use=%s, mode=%x", |
| 3027 | i, yesno(sc->in_use), sc->mode); |
| 3028 | } |
| 3029 | seq_puts(m, "\n"); |
| 3030 | } else { |
| 3031 | seq_puts(m, "\tNo scalers available on this platform\n"); |
| 3032 | } |
| 3033 | } |
| 3034 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3035 | static int i915_display_info(struct seq_file *m, void *unused) |
| 3036 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 3037 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3038 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3039 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3040 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3041 | struct drm_connector *connector; |
| 3042 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3043 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3044 | drm_modeset_lock_all(dev); |
| 3045 | seq_printf(m, "CRTC info\n"); |
| 3046 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 3047 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3048 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3049 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3050 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3051 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3052 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3053 | |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3054 | 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] | 3055 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3056 | yesno(pipe_config->base.active), |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3057 | pipe_config->pipe_src_w, pipe_config->pipe_src_h, |
| 3058 | yesno(pipe_config->dither), pipe_config->pipe_bpp); |
| 3059 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3060 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 3061 | intel_crtc_info(m, crtc); |
| 3062 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3063 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3064 | 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] | 3065 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 3066 | x, y, crtc->base.cursor->state->crtc_w, |
| 3067 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 3068 | crtc->cursor_addr, yesno(active)); |
Robert Fekete | 3abc4e0 | 2015-10-27 16:58:32 +0100 | [diff] [blame] | 3069 | intel_scaler_info(m, crtc); |
| 3070 | intel_plane_info(m, crtc); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 3071 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 3072 | |
| 3073 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 3074 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 3075 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3076 | } |
| 3077 | |
| 3078 | seq_printf(m, "\n"); |
| 3079 | seq_printf(m, "Connector info\n"); |
| 3080 | seq_printf(m, "--------------\n"); |
| 3081 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 3082 | intel_connector_info(m, connector); |
| 3083 | } |
| 3084 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 3085 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 3086 | |
| 3087 | return 0; |
| 3088 | } |
| 3089 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3090 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 3091 | { |
| 3092 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3093 | struct drm_device *dev = node->minor->dev; |
| 3094 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3095 | struct intel_engine_cs *ring; |
| 3096 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
| 3097 | int i, j, ret; |
| 3098 | |
| 3099 | if (!i915_semaphore_is_enabled(dev)) { |
| 3100 | seq_puts(m, "Semaphores are disabled\n"); |
| 3101 | return 0; |
| 3102 | } |
| 3103 | |
| 3104 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3105 | if (ret) |
| 3106 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3107 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3108 | |
| 3109 | if (IS_BROADWELL(dev)) { |
| 3110 | struct page *page; |
| 3111 | uint64_t *seqno; |
| 3112 | |
| 3113 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 3114 | |
| 3115 | seqno = (uint64_t *)kmap_atomic(page); |
| 3116 | for_each_ring(ring, dev_priv, i) { |
| 3117 | uint64_t offset; |
| 3118 | |
| 3119 | seq_printf(m, "%s\n", ring->name); |
| 3120 | |
| 3121 | seq_puts(m, " Last signal:"); |
| 3122 | for (j = 0; j < num_rings; j++) { |
| 3123 | offset = i * I915_NUM_RINGS + j; |
| 3124 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3125 | seqno[offset], offset * 8); |
| 3126 | } |
| 3127 | seq_putc(m, '\n'); |
| 3128 | |
| 3129 | seq_puts(m, " Last wait: "); |
| 3130 | for (j = 0; j < num_rings; j++) { |
| 3131 | offset = i + (j * I915_NUM_RINGS); |
| 3132 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 3133 | seqno[offset], offset * 8); |
| 3134 | } |
| 3135 | seq_putc(m, '\n'); |
| 3136 | |
| 3137 | } |
| 3138 | kunmap_atomic(seqno); |
| 3139 | } else { |
| 3140 | seq_puts(m, " Last signal:"); |
| 3141 | for_each_ring(ring, dev_priv, i) |
| 3142 | for (j = 0; j < num_rings; j++) |
| 3143 | seq_printf(m, "0x%08x\n", |
| 3144 | I915_READ(ring->semaphore.mbox.signal[j])); |
| 3145 | seq_putc(m, '\n'); |
| 3146 | } |
| 3147 | |
| 3148 | seq_puts(m, "\nSync seqno:\n"); |
| 3149 | for_each_ring(ring, dev_priv, i) { |
| 3150 | for (j = 0; j < num_rings; j++) { |
| 3151 | seq_printf(m, " 0x%08x ", ring->semaphore.sync_seqno[j]); |
| 3152 | } |
| 3153 | seq_putc(m, '\n'); |
| 3154 | } |
| 3155 | seq_putc(m, '\n'); |
| 3156 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 3157 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 3158 | mutex_unlock(&dev->struct_mutex); |
| 3159 | return 0; |
| 3160 | } |
| 3161 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3162 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 3163 | { |
| 3164 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3165 | struct drm_device *dev = node->minor->dev; |
| 3166 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3167 | int i; |
| 3168 | |
| 3169 | drm_modeset_lock_all(dev); |
| 3170 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 3171 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 3172 | |
| 3173 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); |
Ander Conselvan de Oliveira | 1e6f2dd | 2014-10-29 11:32:31 +0200 | [diff] [blame] | 3174 | seq_printf(m, " crtc_mask: 0x%08x, active: %d, on: %s\n", |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3175 | pll->config.crtc_mask, pll->active, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3176 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 3177 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 3178 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 3179 | pll->config.hw_state.dpll_md); |
| 3180 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 3181 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 3182 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 3183 | } |
| 3184 | drm_modeset_unlock_all(dev); |
| 3185 | |
| 3186 | return 0; |
| 3187 | } |
| 3188 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 3189 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3190 | { |
| 3191 | int i; |
| 3192 | int ret; |
| 3193 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3194 | struct drm_device *dev = node->minor->dev; |
| 3195 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3196 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3197 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3198 | if (ret) |
| 3199 | return ret; |
| 3200 | |
| 3201 | intel_runtime_pm_get(dev_priv); |
| 3202 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 3203 | seq_printf(m, "Workarounds applied: %d\n", dev_priv->workarounds.count); |
| 3204 | for (i = 0; i < dev_priv->workarounds.count; ++i) { |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 3205 | i915_reg_t addr; |
| 3206 | u32 mask, value, read; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3207 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3208 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 3209 | addr = dev_priv->workarounds.reg[i].addr; |
| 3210 | mask = dev_priv->workarounds.reg[i].mask; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 3211 | value = dev_priv->workarounds.reg[i].value; |
| 3212 | read = I915_READ(addr); |
| 3213 | ok = (value & mask) == (read & mask); |
| 3214 | 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] | 3215 | i915_mmio_reg_offset(addr), value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 3216 | } |
| 3217 | |
| 3218 | intel_runtime_pm_put(dev_priv); |
| 3219 | mutex_unlock(&dev->struct_mutex); |
| 3220 | |
| 3221 | return 0; |
| 3222 | } |
| 3223 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3224 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 3225 | { |
| 3226 | struct drm_info_node *node = m->private; |
| 3227 | struct drm_device *dev = node->minor->dev; |
| 3228 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3229 | struct skl_ddb_allocation *ddb; |
| 3230 | struct skl_ddb_entry *entry; |
| 3231 | enum pipe pipe; |
| 3232 | int plane; |
| 3233 | |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 3234 | if (INTEL_INFO(dev)->gen < 9) |
| 3235 | return 0; |
| 3236 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3237 | drm_modeset_lock_all(dev); |
| 3238 | |
| 3239 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 3240 | |
| 3241 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 3242 | |
| 3243 | for_each_pipe(dev_priv, pipe) { |
| 3244 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 3245 | |
Damien Lespiau | dd74078 | 2015-02-28 14:54:08 +0000 | [diff] [blame] | 3246 | for_each_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3247 | entry = &ddb->plane[pipe][plane]; |
| 3248 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 3249 | entry->start, entry->end, |
| 3250 | skl_ddb_entry_size(entry)); |
| 3251 | } |
| 3252 | |
Matt Roper | 4969d33 | 2015-09-24 15:53:10 -0700 | [diff] [blame] | 3253 | entry = &ddb->plane[pipe][PLANE_CURSOR]; |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 3254 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 3255 | entry->end, skl_ddb_entry_size(entry)); |
| 3256 | } |
| 3257 | |
| 3258 | drm_modeset_unlock_all(dev); |
| 3259 | |
| 3260 | return 0; |
| 3261 | } |
| 3262 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3263 | static void drrs_status_per_crtc(struct seq_file *m, |
| 3264 | struct drm_device *dev, struct intel_crtc *intel_crtc) |
| 3265 | { |
| 3266 | struct intel_encoder *intel_encoder; |
| 3267 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3268 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 3269 | int vrefresh = 0; |
| 3270 | |
| 3271 | for_each_encoder_on_crtc(dev, &intel_crtc->base, intel_encoder) { |
| 3272 | /* Encoder connected on this CRTC */ |
| 3273 | switch (intel_encoder->type) { |
| 3274 | case INTEL_OUTPUT_EDP: |
| 3275 | seq_puts(m, "eDP:\n"); |
| 3276 | break; |
| 3277 | case INTEL_OUTPUT_DSI: |
| 3278 | seq_puts(m, "DSI:\n"); |
| 3279 | break; |
| 3280 | case INTEL_OUTPUT_HDMI: |
| 3281 | seq_puts(m, "HDMI:\n"); |
| 3282 | break; |
| 3283 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3284 | seq_puts(m, "DP:\n"); |
| 3285 | break; |
| 3286 | default: |
| 3287 | seq_printf(m, "Other encoder (id=%d).\n", |
| 3288 | intel_encoder->type); |
| 3289 | return; |
| 3290 | } |
| 3291 | } |
| 3292 | |
| 3293 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3294 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3295 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3296 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3297 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3298 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3299 | else |
| 3300 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3301 | |
| 3302 | seq_puts(m, "\n\n"); |
| 3303 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3304 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3305 | struct intel_panel *panel; |
| 3306 | |
| 3307 | mutex_lock(&drrs->mutex); |
| 3308 | /* DRRS Supported */ |
| 3309 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3310 | |
| 3311 | /* disable_drrs() will make drrs->dp NULL */ |
| 3312 | if (!drrs->dp) { |
| 3313 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3314 | mutex_unlock(&drrs->mutex); |
| 3315 | return; |
| 3316 | } |
| 3317 | |
| 3318 | panel = &drrs->dp->attached_connector->panel; |
| 3319 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3320 | drrs->busy_frontbuffer_bits); |
| 3321 | |
| 3322 | seq_puts(m, "\n\t\t"); |
| 3323 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3324 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3325 | vrefresh = panel->fixed_mode->vrefresh; |
| 3326 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3327 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3328 | vrefresh = panel->downclock_mode->vrefresh; |
| 3329 | } else { |
| 3330 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3331 | drrs->refresh_rate_type); |
| 3332 | mutex_unlock(&drrs->mutex); |
| 3333 | return; |
| 3334 | } |
| 3335 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3336 | |
| 3337 | seq_puts(m, "\n\t\t"); |
| 3338 | mutex_unlock(&drrs->mutex); |
| 3339 | } else { |
| 3340 | /* DRRS not supported. Print the VBT parameter*/ |
| 3341 | seq_puts(m, "\tDRRS Supported : No"); |
| 3342 | } |
| 3343 | seq_puts(m, "\n"); |
| 3344 | } |
| 3345 | |
| 3346 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3347 | { |
| 3348 | struct drm_info_node *node = m->private; |
| 3349 | struct drm_device *dev = node->minor->dev; |
| 3350 | struct intel_crtc *intel_crtc; |
| 3351 | int active_crtc_cnt = 0; |
| 3352 | |
| 3353 | for_each_intel_crtc(dev, intel_crtc) { |
| 3354 | drm_modeset_lock(&intel_crtc->base.mutex, NULL); |
| 3355 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3356 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3357 | active_crtc_cnt++; |
| 3358 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3359 | |
| 3360 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3361 | } |
| 3362 | |
| 3363 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 3364 | } |
| 3365 | |
| 3366 | if (!active_crtc_cnt) |
| 3367 | seq_puts(m, "No active crtc found\n"); |
| 3368 | |
| 3369 | return 0; |
| 3370 | } |
| 3371 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3372 | struct pipe_crc_info { |
| 3373 | const char *name; |
| 3374 | struct drm_device *dev; |
| 3375 | enum pipe pipe; |
| 3376 | }; |
| 3377 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3378 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3379 | { |
| 3380 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3381 | struct drm_device *dev = node->minor->dev; |
| 3382 | struct drm_encoder *encoder; |
| 3383 | struct intel_encoder *intel_encoder; |
| 3384 | struct intel_digital_port *intel_dig_port; |
| 3385 | drm_modeset_lock_all(dev); |
| 3386 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 3387 | intel_encoder = to_intel_encoder(encoder); |
| 3388 | if (intel_encoder->type != INTEL_OUTPUT_DISPLAYPORT) |
| 3389 | continue; |
| 3390 | intel_dig_port = enc_to_dig_port(encoder); |
| 3391 | if (!intel_dig_port->dp.can_mst) |
| 3392 | continue; |
| 3393 | |
| 3394 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3395 | } |
| 3396 | drm_modeset_unlock_all(dev); |
| 3397 | return 0; |
| 3398 | } |
| 3399 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3400 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3401 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3402 | struct pipe_crc_info *info = inode->i_private; |
| 3403 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 3404 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3405 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 3406 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 3407 | return -ENODEV; |
| 3408 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3409 | spin_lock_irq(&pipe_crc->lock); |
| 3410 | |
| 3411 | if (pipe_crc->opened) { |
| 3412 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3413 | return -EBUSY; /* already open */ |
| 3414 | } |
| 3415 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3416 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3417 | filep->private_data = inode->i_private; |
| 3418 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3419 | spin_unlock_irq(&pipe_crc->lock); |
| 3420 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3421 | return 0; |
| 3422 | } |
| 3423 | |
| 3424 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 3425 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3426 | struct pipe_crc_info *info = inode->i_private; |
| 3427 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 3428 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3429 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3430 | spin_lock_irq(&pipe_crc->lock); |
| 3431 | pipe_crc->opened = false; |
| 3432 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3433 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3434 | return 0; |
| 3435 | } |
| 3436 | |
| 3437 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 3438 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 3439 | /* account for \'0' */ |
| 3440 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 3441 | |
| 3442 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 3443 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3444 | assert_spin_locked(&pipe_crc->lock); |
| 3445 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3446 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3447 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3448 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3449 | static ssize_t |
| 3450 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 3451 | loff_t *pos) |
| 3452 | { |
| 3453 | struct pipe_crc_info *info = filep->private_data; |
| 3454 | struct drm_device *dev = info->dev; |
| 3455 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3456 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3457 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3458 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3459 | ssize_t bytes_read; |
| 3460 | |
| 3461 | /* |
| 3462 | * Don't allow user space to provide buffers not big enough to hold |
| 3463 | * a line of data. |
| 3464 | */ |
| 3465 | if (count < PIPE_CRC_LINE_LEN) |
| 3466 | return -EINVAL; |
| 3467 | |
| 3468 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 3469 | return 0; |
| 3470 | |
| 3471 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3472 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3473 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3474 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3475 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3476 | if (filep->f_flags & O_NONBLOCK) { |
| 3477 | spin_unlock_irq(&pipe_crc->lock); |
| 3478 | return -EAGAIN; |
| 3479 | } |
| 3480 | |
| 3481 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 3482 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 3483 | if (ret) { |
| 3484 | spin_unlock_irq(&pipe_crc->lock); |
| 3485 | return ret; |
| 3486 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3487 | } |
| 3488 | |
| 3489 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3490 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3491 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3492 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3493 | while (n_entries > 0) { |
| 3494 | struct intel_pipe_crc_entry *entry = |
| 3495 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3496 | int ret; |
| 3497 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3498 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3499 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3500 | break; |
| 3501 | |
| 3502 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3503 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3504 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3505 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3506 | "%8u %8x %8x %8x %8x %8x\n", |
| 3507 | entry->frame, entry->crc[0], |
| 3508 | entry->crc[1], entry->crc[2], |
| 3509 | entry->crc[3], entry->crc[4]); |
| 3510 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3511 | spin_unlock_irq(&pipe_crc->lock); |
| 3512 | |
| 3513 | ret = copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3514 | if (ret == PIPE_CRC_LINE_LEN) |
| 3515 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3516 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3517 | user_buf += PIPE_CRC_LINE_LEN; |
| 3518 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3519 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3520 | spin_lock_irq(&pipe_crc->lock); |
| 3521 | } |
| 3522 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3523 | spin_unlock_irq(&pipe_crc->lock); |
| 3524 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3525 | return bytes_read; |
| 3526 | } |
| 3527 | |
| 3528 | static const struct file_operations i915_pipe_crc_fops = { |
| 3529 | .owner = THIS_MODULE, |
| 3530 | .open = i915_pipe_crc_open, |
| 3531 | .read = i915_pipe_crc_read, |
| 3532 | .release = i915_pipe_crc_release, |
| 3533 | }; |
| 3534 | |
| 3535 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3536 | { |
| 3537 | .name = "i915_pipe_A_crc", |
| 3538 | .pipe = PIPE_A, |
| 3539 | }, |
| 3540 | { |
| 3541 | .name = "i915_pipe_B_crc", |
| 3542 | .pipe = PIPE_B, |
| 3543 | }, |
| 3544 | { |
| 3545 | .name = "i915_pipe_C_crc", |
| 3546 | .pipe = PIPE_C, |
| 3547 | }, |
| 3548 | }; |
| 3549 | |
| 3550 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3551 | enum pipe pipe) |
| 3552 | { |
| 3553 | struct drm_device *dev = minor->dev; |
| 3554 | struct dentry *ent; |
| 3555 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3556 | |
| 3557 | info->dev = dev; |
| 3558 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3559 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3560 | if (!ent) |
| 3561 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3562 | |
| 3563 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3564 | } |
| 3565 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3566 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3567 | "none", |
| 3568 | "plane1", |
| 3569 | "plane2", |
| 3570 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3571 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3572 | "TV", |
| 3573 | "DP-B", |
| 3574 | "DP-C", |
| 3575 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3576 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3577 | }; |
| 3578 | |
| 3579 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3580 | { |
| 3581 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3582 | return pipe_crc_sources[source]; |
| 3583 | } |
| 3584 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3585 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3586 | { |
| 3587 | struct drm_device *dev = m->private; |
| 3588 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3589 | int i; |
| 3590 | |
| 3591 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3592 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3593 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3594 | |
| 3595 | return 0; |
| 3596 | } |
| 3597 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3598 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3599 | { |
| 3600 | struct drm_device *dev = inode->i_private; |
| 3601 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3602 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3603 | } |
| 3604 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3605 | 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] | 3606 | uint32_t *val) |
| 3607 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3608 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3609 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3610 | |
| 3611 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3612 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3613 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3614 | break; |
| 3615 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3616 | *val = 0; |
| 3617 | break; |
| 3618 | default: |
| 3619 | return -EINVAL; |
| 3620 | } |
| 3621 | |
| 3622 | return 0; |
| 3623 | } |
| 3624 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3625 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 3626 | enum intel_pipe_crc_source *source) |
| 3627 | { |
| 3628 | struct intel_encoder *encoder; |
| 3629 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3630 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3631 | int ret = 0; |
| 3632 | |
| 3633 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3634 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3635 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3636 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3637 | if (!encoder->base.crtc) |
| 3638 | continue; |
| 3639 | |
| 3640 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3641 | |
| 3642 | if (crtc->pipe != pipe) |
| 3643 | continue; |
| 3644 | |
| 3645 | switch (encoder->type) { |
| 3646 | case INTEL_OUTPUT_TVOUT: |
| 3647 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3648 | break; |
| 3649 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3650 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3651 | dig_port = enc_to_dig_port(&encoder->base); |
| 3652 | switch (dig_port->port) { |
| 3653 | case PORT_B: |
| 3654 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3655 | break; |
| 3656 | case PORT_C: |
| 3657 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3658 | break; |
| 3659 | case PORT_D: |
| 3660 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3661 | break; |
| 3662 | default: |
| 3663 | WARN(1, "nonexisting DP port %c\n", |
| 3664 | port_name(dig_port->port)); |
| 3665 | break; |
| 3666 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3667 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3668 | default: |
| 3669 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3670 | } |
| 3671 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3672 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3673 | |
| 3674 | return ret; |
| 3675 | } |
| 3676 | |
| 3677 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3678 | enum pipe pipe, |
| 3679 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3680 | uint32_t *val) |
| 3681 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3682 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3683 | bool need_stable_symbols = false; |
| 3684 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3685 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3686 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3687 | if (ret) |
| 3688 | return ret; |
| 3689 | } |
| 3690 | |
| 3691 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3692 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3693 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3694 | break; |
| 3695 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3696 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3697 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3698 | break; |
| 3699 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3700 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3701 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3702 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3703 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3704 | if (!IS_CHERRYVIEW(dev)) |
| 3705 | return -EINVAL; |
| 3706 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3707 | need_stable_symbols = true; |
| 3708 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3709 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3710 | *val = 0; |
| 3711 | break; |
| 3712 | default: |
| 3713 | return -EINVAL; |
| 3714 | } |
| 3715 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3716 | /* |
| 3717 | * When the pipe CRC tap point is after the transcoders we need |
| 3718 | * to tweak symbol-level features to produce a deterministic series of |
| 3719 | * symbols for a given frame. We need to reset those features only once |
| 3720 | * a frame (instead of every nth symbol): |
| 3721 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3722 | * link (SDVO) |
| 3723 | * - DisplayPort scrambling: used for EMI reduction |
| 3724 | */ |
| 3725 | if (need_stable_symbols) { |
| 3726 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3727 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3728 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3729 | switch (pipe) { |
| 3730 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3731 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3732 | break; |
| 3733 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3734 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3735 | break; |
| 3736 | case PIPE_C: |
| 3737 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3738 | break; |
| 3739 | default: |
| 3740 | return -EINVAL; |
| 3741 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3742 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3743 | } |
| 3744 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3745 | return 0; |
| 3746 | } |
| 3747 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3748 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3749 | enum pipe pipe, |
| 3750 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3751 | uint32_t *val) |
| 3752 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3753 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3754 | bool need_stable_symbols = false; |
| 3755 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3756 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3757 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3758 | if (ret) |
| 3759 | return ret; |
| 3760 | } |
| 3761 | |
| 3762 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3763 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3764 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3765 | break; |
| 3766 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 3767 | if (!SUPPORTS_TV(dev)) |
| 3768 | return -EINVAL; |
| 3769 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3770 | break; |
| 3771 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3772 | if (!IS_G4X(dev)) |
| 3773 | return -EINVAL; |
| 3774 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3775 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3776 | break; |
| 3777 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3778 | if (!IS_G4X(dev)) |
| 3779 | return -EINVAL; |
| 3780 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3781 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3782 | break; |
| 3783 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3784 | if (!IS_G4X(dev)) |
| 3785 | return -EINVAL; |
| 3786 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3787 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3788 | break; |
| 3789 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3790 | *val = 0; |
| 3791 | break; |
| 3792 | default: |
| 3793 | return -EINVAL; |
| 3794 | } |
| 3795 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3796 | /* |
| 3797 | * When the pipe CRC tap point is after the transcoders we need |
| 3798 | * to tweak symbol-level features to produce a deterministic series of |
| 3799 | * symbols for a given frame. We need to reset those features only once |
| 3800 | * a frame (instead of every nth symbol): |
| 3801 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3802 | * link (SDVO) |
| 3803 | * - DisplayPort scrambling: used for EMI reduction |
| 3804 | */ |
| 3805 | if (need_stable_symbols) { |
| 3806 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3807 | |
| 3808 | WARN_ON(!IS_G4X(dev)); |
| 3809 | |
| 3810 | I915_WRITE(PORT_DFT_I9XX, |
| 3811 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3812 | |
| 3813 | if (pipe == PIPE_A) |
| 3814 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3815 | else |
| 3816 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3817 | |
| 3818 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3819 | } |
| 3820 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3821 | return 0; |
| 3822 | } |
| 3823 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3824 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3825 | enum pipe pipe) |
| 3826 | { |
| 3827 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3828 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3829 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3830 | switch (pipe) { |
| 3831 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3832 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3833 | break; |
| 3834 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3835 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3836 | break; |
| 3837 | case PIPE_C: |
| 3838 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 3839 | break; |
| 3840 | default: |
| 3841 | return; |
| 3842 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3843 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3844 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3845 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3846 | |
| 3847 | } |
| 3848 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3849 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3850 | enum pipe pipe) |
| 3851 | { |
| 3852 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3853 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3854 | |
| 3855 | if (pipe == PIPE_A) |
| 3856 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3857 | else |
| 3858 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3859 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3860 | |
| 3861 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3862 | I915_WRITE(PORT_DFT_I9XX, |
| 3863 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3864 | } |
| 3865 | } |
| 3866 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3867 | 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] | 3868 | uint32_t *val) |
| 3869 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3870 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3871 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3872 | |
| 3873 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3874 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3875 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 3876 | break; |
| 3877 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3878 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 3879 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3880 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3881 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 3882 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3883 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3884 | *val = 0; |
| 3885 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3886 | default: |
| 3887 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3888 | } |
| 3889 | |
| 3890 | return 0; |
| 3891 | } |
| 3892 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3893 | 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] | 3894 | { |
| 3895 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3896 | struct intel_crtc *crtc = |
| 3897 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3898 | struct intel_crtc_state *pipe_config; |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3899 | struct drm_atomic_state *state; |
| 3900 | int ret = 0; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3901 | |
| 3902 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3903 | state = drm_atomic_state_alloc(dev); |
| 3904 | if (!state) { |
| 3905 | ret = -ENOMEM; |
| 3906 | goto out; |
| 3907 | } |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3908 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3909 | state->acquire_ctx = drm_modeset_legacy_acquire_ctx(&crtc->base); |
| 3910 | pipe_config = intel_atomic_get_crtc_state(state, crtc); |
| 3911 | if (IS_ERR(pipe_config)) { |
| 3912 | ret = PTR_ERR(pipe_config); |
| 3913 | goto out; |
| 3914 | } |
| 3915 | |
| 3916 | pipe_config->pch_pfit.force_thru = enable; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3917 | if (pipe_config->cpu_transcoder == TRANSCODER_EDP && |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3918 | pipe_config->pch_pfit.enabled != enable) |
| 3919 | pipe_config->base.connectors_changed = true; |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3920 | |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3921 | ret = drm_atomic_commit(state); |
| 3922 | out: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3923 | drm_modeset_unlock_all(dev); |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3924 | WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret); |
| 3925 | if (ret) |
| 3926 | drm_atomic_state_free(state); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3927 | } |
| 3928 | |
| 3929 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3930 | enum pipe pipe, |
| 3931 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3932 | uint32_t *val) |
| 3933 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3934 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3935 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 3936 | |
| 3937 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3938 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3939 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 3940 | break; |
| 3941 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3942 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 3943 | break; |
| 3944 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3945 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 3946 | hsw_trans_edp_pipe_A_crc_wa(dev, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3947 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3948 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 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 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3960 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 3961 | enum intel_pipe_crc_source source) |
| 3962 | { |
| 3963 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3964 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3965 | struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, |
| 3966 | pipe)); |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 3967 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3968 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3969 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3970 | if (pipe_crc->source == source) |
| 3971 | return 0; |
| 3972 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 3973 | /* forbid changing the source without going back to 'none' */ |
| 3974 | if (pipe_crc->source && source) |
| 3975 | return -EINVAL; |
| 3976 | |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 3977 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PIPE(pipe))) { |
| 3978 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 3979 | return -EIO; |
| 3980 | } |
| 3981 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3982 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3983 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3984 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3985 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3986 | else if (IS_VALLEYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3987 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3988 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3989 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3990 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3991 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3992 | |
| 3993 | if (ret != 0) |
| 3994 | return ret; |
| 3995 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3996 | /* none -> real source transition */ |
| 3997 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3998 | struct intel_pipe_crc_entry *entries; |
| 3999 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4000 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 4001 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 4002 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 4003 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 4004 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4005 | GFP_KERNEL); |
| 4006 | if (!entries) |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4007 | return -ENOMEM; |
| 4008 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4009 | /* |
| 4010 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 4011 | * enabled and disabled dynamically based on package C states, |
| 4012 | * user space can't make reliable use of the CRCs, so let's just |
| 4013 | * completely disable it. |
| 4014 | */ |
| 4015 | hsw_disable_ips(crtc); |
| 4016 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4017 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 4018 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 4019 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4020 | pipe_crc->head = 0; |
| 4021 | pipe_crc->tail = 0; |
| 4022 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 4023 | } |
| 4024 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 4025 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4026 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4027 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 4028 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 4029 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4030 | /* real source -> none transition */ |
| 4031 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4032 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4033 | struct intel_crtc *crtc = |
| 4034 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4035 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 4036 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 4037 | pipe_name(pipe)); |
| 4038 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4039 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 4040 | if (crtc->base.state->active) |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 4041 | intel_wait_for_vblank(dev, pipe); |
| 4042 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 4043 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4044 | spin_lock_irq(&pipe_crc->lock); |
| 4045 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4046 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 4047 | pipe_crc->head = 0; |
| 4048 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4049 | spin_unlock_irq(&pipe_crc->lock); |
| 4050 | |
| 4051 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 4052 | |
| 4053 | if (IS_G4X(dev)) |
| 4054 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 4055 | else if (IS_VALLEYVIEW(dev)) |
| 4056 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 4057 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
Maarten Lankhorst | c4e2d04 | 2015-08-05 12:36:59 +0200 | [diff] [blame] | 4058 | hsw_trans_edp_pipe_A_crc_wa(dev, false); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 4059 | |
| 4060 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 4061 | } |
| 4062 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4063 | return 0; |
| 4064 | } |
| 4065 | |
| 4066 | /* |
| 4067 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4068 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 4069 | * object: 'pipe' |
| 4070 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4071 | * source: (none | plane1 | plane2 | pf) |
| 4072 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 4073 | * |
| 4074 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4075 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 4076 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4077 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4078 | 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] | 4079 | { |
| 4080 | int n_words = 0; |
| 4081 | |
| 4082 | while (*buf) { |
| 4083 | char *end; |
| 4084 | |
| 4085 | /* skip leading white space */ |
| 4086 | buf = skip_spaces(buf); |
| 4087 | if (!*buf) |
| 4088 | break; /* end of buffer */ |
| 4089 | |
| 4090 | /* find end of word */ |
| 4091 | for (end = buf; *end && !isspace(*end); end++) |
| 4092 | ; |
| 4093 | |
| 4094 | if (n_words == max_words) { |
| 4095 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 4096 | max_words); |
| 4097 | return -EINVAL; /* ran out of words[] before bytes */ |
| 4098 | } |
| 4099 | |
| 4100 | if (*end) |
| 4101 | *end++ = '\0'; |
| 4102 | words[n_words++] = buf; |
| 4103 | buf = end; |
| 4104 | } |
| 4105 | |
| 4106 | return n_words; |
| 4107 | } |
| 4108 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4109 | enum intel_pipe_crc_object { |
| 4110 | PIPE_CRC_OBJECT_PIPE, |
| 4111 | }; |
| 4112 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 4113 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4114 | "pipe", |
| 4115 | }; |
| 4116 | |
| 4117 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4118 | 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] | 4119 | { |
| 4120 | int i; |
| 4121 | |
| 4122 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 4123 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4124 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4125 | return 0; |
| 4126 | } |
| 4127 | |
| 4128 | return -EINVAL; |
| 4129 | } |
| 4130 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4131 | 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] | 4132 | { |
| 4133 | const char name = buf[0]; |
| 4134 | |
| 4135 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 4136 | return -EINVAL; |
| 4137 | |
| 4138 | *pipe = name - 'A'; |
| 4139 | |
| 4140 | return 0; |
| 4141 | } |
| 4142 | |
| 4143 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4144 | 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] | 4145 | { |
| 4146 | int i; |
| 4147 | |
| 4148 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 4149 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4150 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4151 | return 0; |
| 4152 | } |
| 4153 | |
| 4154 | return -EINVAL; |
| 4155 | } |
| 4156 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4157 | 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] | 4158 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4159 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4160 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4161 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4162 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4163 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4164 | enum intel_pipe_crc_source source; |
| 4165 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4166 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4167 | if (n_words != N_WORDS) { |
| 4168 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 4169 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4170 | return -EINVAL; |
| 4171 | } |
| 4172 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4173 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4174 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4175 | return -EINVAL; |
| 4176 | } |
| 4177 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4178 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4179 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 4180 | return -EINVAL; |
| 4181 | } |
| 4182 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4183 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 4184 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4185 | return -EINVAL; |
| 4186 | } |
| 4187 | |
| 4188 | return pipe_crc_set_source(dev, pipe, source); |
| 4189 | } |
| 4190 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4191 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 4192 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4193 | { |
| 4194 | struct seq_file *m = file->private_data; |
| 4195 | struct drm_device *dev = m->private; |
| 4196 | char *tmpbuf; |
| 4197 | int ret; |
| 4198 | |
| 4199 | if (len == 0) |
| 4200 | return 0; |
| 4201 | |
| 4202 | if (len > PAGE_SIZE - 1) { |
| 4203 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 4204 | PAGE_SIZE); |
| 4205 | return -E2BIG; |
| 4206 | } |
| 4207 | |
| 4208 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 4209 | if (!tmpbuf) |
| 4210 | return -ENOMEM; |
| 4211 | |
| 4212 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 4213 | ret = -EFAULT; |
| 4214 | goto out; |
| 4215 | } |
| 4216 | tmpbuf[len] = '\0'; |
| 4217 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4218 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4219 | |
| 4220 | out: |
| 4221 | kfree(tmpbuf); |
| 4222 | if (ret < 0) |
| 4223 | return ret; |
| 4224 | |
| 4225 | *offp += len; |
| 4226 | return len; |
| 4227 | } |
| 4228 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4229 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4230 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4231 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4232 | .read = seq_read, |
| 4233 | .llseek = seq_lseek, |
| 4234 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4235 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 4236 | }; |
| 4237 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4238 | static ssize_t i915_displayport_test_active_write(struct file *file, |
| 4239 | const char __user *ubuf, |
| 4240 | size_t len, loff_t *offp) |
| 4241 | { |
| 4242 | char *input_buffer; |
| 4243 | int status = 0; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4244 | struct drm_device *dev; |
| 4245 | struct drm_connector *connector; |
| 4246 | struct list_head *connector_list; |
| 4247 | struct intel_dp *intel_dp; |
| 4248 | int val = 0; |
| 4249 | |
Sudip Mukherjee | 9aaffa3 | 2015-07-21 17:36:45 +0530 | [diff] [blame] | 4250 | dev = ((struct seq_file *)file->private_data)->private; |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4251 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4252 | connector_list = &dev->mode_config.connector_list; |
| 4253 | |
| 4254 | if (len == 0) |
| 4255 | return 0; |
| 4256 | |
| 4257 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 4258 | if (!input_buffer) |
| 4259 | return -ENOMEM; |
| 4260 | |
| 4261 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 4262 | status = -EFAULT; |
| 4263 | goto out; |
| 4264 | } |
| 4265 | |
| 4266 | input_buffer[len] = '\0'; |
| 4267 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 4268 | |
| 4269 | list_for_each_entry(connector, connector_list, head) { |
| 4270 | |
| 4271 | if (connector->connector_type != |
| 4272 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4273 | continue; |
| 4274 | |
Sudip Mukherjee | b8bb08e | 2015-07-21 17:36:46 +0530 | [diff] [blame] | 4275 | if (connector->status == connector_status_connected && |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4276 | connector->encoder != NULL) { |
| 4277 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4278 | status = kstrtoint(input_buffer, 10, &val); |
| 4279 | if (status < 0) |
| 4280 | goto out; |
| 4281 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 4282 | /* To prevent erroneous activation of the compliance |
| 4283 | * testing code, only accept an actual value of 1 here |
| 4284 | */ |
| 4285 | if (val == 1) |
| 4286 | intel_dp->compliance_test_active = 1; |
| 4287 | else |
| 4288 | intel_dp->compliance_test_active = 0; |
| 4289 | } |
| 4290 | } |
| 4291 | out: |
| 4292 | kfree(input_buffer); |
| 4293 | if (status < 0) |
| 4294 | return status; |
| 4295 | |
| 4296 | *offp += len; |
| 4297 | return len; |
| 4298 | } |
| 4299 | |
| 4300 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 4301 | { |
| 4302 | struct drm_device *dev = m->private; |
| 4303 | struct drm_connector *connector; |
| 4304 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4305 | struct intel_dp *intel_dp; |
| 4306 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4307 | list_for_each_entry(connector, connector_list, head) { |
| 4308 | |
| 4309 | if (connector->connector_type != |
| 4310 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4311 | continue; |
| 4312 | |
| 4313 | if (connector->status == connector_status_connected && |
| 4314 | connector->encoder != NULL) { |
| 4315 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4316 | if (intel_dp->compliance_test_active) |
| 4317 | seq_puts(m, "1"); |
| 4318 | else |
| 4319 | seq_puts(m, "0"); |
| 4320 | } else |
| 4321 | seq_puts(m, "0"); |
| 4322 | } |
| 4323 | |
| 4324 | return 0; |
| 4325 | } |
| 4326 | |
| 4327 | static int i915_displayport_test_active_open(struct inode *inode, |
| 4328 | struct file *file) |
| 4329 | { |
| 4330 | struct drm_device *dev = inode->i_private; |
| 4331 | |
| 4332 | return single_open(file, i915_displayport_test_active_show, dev); |
| 4333 | } |
| 4334 | |
| 4335 | static const struct file_operations i915_displayport_test_active_fops = { |
| 4336 | .owner = THIS_MODULE, |
| 4337 | .open = i915_displayport_test_active_open, |
| 4338 | .read = seq_read, |
| 4339 | .llseek = seq_lseek, |
| 4340 | .release = single_release, |
| 4341 | .write = i915_displayport_test_active_write |
| 4342 | }; |
| 4343 | |
| 4344 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 4345 | { |
| 4346 | struct drm_device *dev = m->private; |
| 4347 | struct drm_connector *connector; |
| 4348 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4349 | struct intel_dp *intel_dp; |
| 4350 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4351 | list_for_each_entry(connector, connector_list, head) { |
| 4352 | |
| 4353 | if (connector->connector_type != |
| 4354 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4355 | continue; |
| 4356 | |
| 4357 | if (connector->status == connector_status_connected && |
| 4358 | connector->encoder != NULL) { |
| 4359 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4360 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 4361 | } else |
| 4362 | seq_puts(m, "0"); |
| 4363 | } |
| 4364 | |
| 4365 | return 0; |
| 4366 | } |
| 4367 | static int i915_displayport_test_data_open(struct inode *inode, |
| 4368 | struct file *file) |
| 4369 | { |
| 4370 | struct drm_device *dev = inode->i_private; |
| 4371 | |
| 4372 | return single_open(file, i915_displayport_test_data_show, dev); |
| 4373 | } |
| 4374 | |
| 4375 | static const struct file_operations i915_displayport_test_data_fops = { |
| 4376 | .owner = THIS_MODULE, |
| 4377 | .open = i915_displayport_test_data_open, |
| 4378 | .read = seq_read, |
| 4379 | .llseek = seq_lseek, |
| 4380 | .release = single_release |
| 4381 | }; |
| 4382 | |
| 4383 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 4384 | { |
| 4385 | struct drm_device *dev = m->private; |
| 4386 | struct drm_connector *connector; |
| 4387 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4388 | struct intel_dp *intel_dp; |
| 4389 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 4390 | list_for_each_entry(connector, connector_list, head) { |
| 4391 | |
| 4392 | if (connector->connector_type != |
| 4393 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4394 | continue; |
| 4395 | |
| 4396 | if (connector->status == connector_status_connected && |
| 4397 | connector->encoder != NULL) { |
| 4398 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4399 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 4400 | } else |
| 4401 | seq_puts(m, "0"); |
| 4402 | } |
| 4403 | |
| 4404 | return 0; |
| 4405 | } |
| 4406 | |
| 4407 | static int i915_displayport_test_type_open(struct inode *inode, |
| 4408 | struct file *file) |
| 4409 | { |
| 4410 | struct drm_device *dev = inode->i_private; |
| 4411 | |
| 4412 | return single_open(file, i915_displayport_test_type_show, dev); |
| 4413 | } |
| 4414 | |
| 4415 | static const struct file_operations i915_displayport_test_type_fops = { |
| 4416 | .owner = THIS_MODULE, |
| 4417 | .open = i915_displayport_test_type_open, |
| 4418 | .read = seq_read, |
| 4419 | .llseek = seq_lseek, |
| 4420 | .release = single_release |
| 4421 | }; |
| 4422 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4423 | 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] | 4424 | { |
| 4425 | struct drm_device *dev = m->private; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4426 | int level; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4427 | int num_levels; |
| 4428 | |
| 4429 | if (IS_CHERRYVIEW(dev)) |
| 4430 | num_levels = 3; |
| 4431 | else if (IS_VALLEYVIEW(dev)) |
| 4432 | num_levels = 1; |
| 4433 | else |
| 4434 | num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4435 | |
| 4436 | drm_modeset_lock_all(dev); |
| 4437 | |
| 4438 | for (level = 0; level < num_levels; level++) { |
| 4439 | unsigned int latency = wm[level]; |
| 4440 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4441 | /* |
| 4442 | * - WM1+ latency values in 0.5us units |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4443 | * - latencies are in us on gen9/vlv/chv |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4444 | */ |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4445 | if (INTEL_INFO(dev)->gen >= 9 || IS_VALLEYVIEW(dev)) |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4446 | latency *= 10; |
| 4447 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4448 | latency *= 5; |
| 4449 | |
| 4450 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4451 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4452 | } |
| 4453 | |
| 4454 | drm_modeset_unlock_all(dev); |
| 4455 | } |
| 4456 | |
| 4457 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 4458 | { |
| 4459 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4460 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4461 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4462 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4463 | if (INTEL_INFO(dev)->gen >= 9) |
| 4464 | latencies = dev_priv->wm.skl_latency; |
| 4465 | else |
| 4466 | latencies = to_i915(dev)->wm.pri_latency; |
| 4467 | |
| 4468 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4469 | |
| 4470 | return 0; |
| 4471 | } |
| 4472 | |
| 4473 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4474 | { |
| 4475 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4476 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4477 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4478 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4479 | if (INTEL_INFO(dev)->gen >= 9) |
| 4480 | latencies = dev_priv->wm.skl_latency; |
| 4481 | else |
| 4482 | latencies = to_i915(dev)->wm.spr_latency; |
| 4483 | |
| 4484 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4485 | |
| 4486 | return 0; |
| 4487 | } |
| 4488 | |
| 4489 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4490 | { |
| 4491 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4492 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4493 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4494 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4495 | if (INTEL_INFO(dev)->gen >= 9) |
| 4496 | latencies = dev_priv->wm.skl_latency; |
| 4497 | else |
| 4498 | latencies = to_i915(dev)->wm.cur_latency; |
| 4499 | |
| 4500 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4501 | |
| 4502 | return 0; |
| 4503 | } |
| 4504 | |
| 4505 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4506 | { |
| 4507 | struct drm_device *dev = inode->i_private; |
| 4508 | |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4509 | if (INTEL_INFO(dev)->gen < 5) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4510 | return -ENODEV; |
| 4511 | |
| 4512 | return single_open(file, pri_wm_latency_show, dev); |
| 4513 | } |
| 4514 | |
| 4515 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4516 | { |
| 4517 | struct drm_device *dev = inode->i_private; |
| 4518 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4519 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4520 | return -ENODEV; |
| 4521 | |
| 4522 | return single_open(file, spr_wm_latency_show, dev); |
| 4523 | } |
| 4524 | |
| 4525 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4526 | { |
| 4527 | struct drm_device *dev = inode->i_private; |
| 4528 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4529 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4530 | return -ENODEV; |
| 4531 | |
| 4532 | return single_open(file, cur_wm_latency_show, dev); |
| 4533 | } |
| 4534 | |
| 4535 | 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] | 4536 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4537 | { |
| 4538 | struct seq_file *m = file->private_data; |
| 4539 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4540 | uint16_t new[8] = { 0 }; |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4541 | int num_levels; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4542 | int level; |
| 4543 | int ret; |
| 4544 | char tmp[32]; |
| 4545 | |
Ville Syrjälä | de38b95 | 2015-06-24 22:00:09 +0300 | [diff] [blame] | 4546 | if (IS_CHERRYVIEW(dev)) |
| 4547 | num_levels = 3; |
| 4548 | else if (IS_VALLEYVIEW(dev)) |
| 4549 | num_levels = 1; |
| 4550 | else |
| 4551 | num_levels = ilk_wm_max_level(dev) + 1; |
| 4552 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4553 | if (len >= sizeof(tmp)) |
| 4554 | return -EINVAL; |
| 4555 | |
| 4556 | if (copy_from_user(tmp, ubuf, len)) |
| 4557 | return -EFAULT; |
| 4558 | |
| 4559 | tmp[len] = '\0'; |
| 4560 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4561 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4562 | &new[0], &new[1], &new[2], &new[3], |
| 4563 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4564 | if (ret != num_levels) |
| 4565 | return -EINVAL; |
| 4566 | |
| 4567 | drm_modeset_lock_all(dev); |
| 4568 | |
| 4569 | for (level = 0; level < num_levels; level++) |
| 4570 | wm[level] = new[level]; |
| 4571 | |
| 4572 | drm_modeset_unlock_all(dev); |
| 4573 | |
| 4574 | return len; |
| 4575 | } |
| 4576 | |
| 4577 | |
| 4578 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4579 | size_t len, loff_t *offp) |
| 4580 | { |
| 4581 | struct seq_file *m = file->private_data; |
| 4582 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4583 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4584 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4585 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4586 | if (INTEL_INFO(dev)->gen >= 9) |
| 4587 | latencies = dev_priv->wm.skl_latency; |
| 4588 | else |
| 4589 | latencies = to_i915(dev)->wm.pri_latency; |
| 4590 | |
| 4591 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4592 | } |
| 4593 | |
| 4594 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4595 | size_t len, loff_t *offp) |
| 4596 | { |
| 4597 | struct seq_file *m = file->private_data; |
| 4598 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4599 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4600 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4601 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4602 | if (INTEL_INFO(dev)->gen >= 9) |
| 4603 | latencies = dev_priv->wm.skl_latency; |
| 4604 | else |
| 4605 | latencies = to_i915(dev)->wm.spr_latency; |
| 4606 | |
| 4607 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4608 | } |
| 4609 | |
| 4610 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4611 | size_t len, loff_t *offp) |
| 4612 | { |
| 4613 | struct seq_file *m = file->private_data; |
| 4614 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4615 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4616 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4617 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4618 | if (INTEL_INFO(dev)->gen >= 9) |
| 4619 | latencies = dev_priv->wm.skl_latency; |
| 4620 | else |
| 4621 | latencies = to_i915(dev)->wm.cur_latency; |
| 4622 | |
| 4623 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4624 | } |
| 4625 | |
| 4626 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4627 | .owner = THIS_MODULE, |
| 4628 | .open = pri_wm_latency_open, |
| 4629 | .read = seq_read, |
| 4630 | .llseek = seq_lseek, |
| 4631 | .release = single_release, |
| 4632 | .write = pri_wm_latency_write |
| 4633 | }; |
| 4634 | |
| 4635 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4636 | .owner = THIS_MODULE, |
| 4637 | .open = spr_wm_latency_open, |
| 4638 | .read = seq_read, |
| 4639 | .llseek = seq_lseek, |
| 4640 | .release = single_release, |
| 4641 | .write = spr_wm_latency_write |
| 4642 | }; |
| 4643 | |
| 4644 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4645 | .owner = THIS_MODULE, |
| 4646 | .open = cur_wm_latency_open, |
| 4647 | .read = seq_read, |
| 4648 | .llseek = seq_lseek, |
| 4649 | .release = single_release, |
| 4650 | .write = cur_wm_latency_write |
| 4651 | }; |
| 4652 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4653 | static int |
| 4654 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4655 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4656 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4657 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4658 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4659 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4660 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4661 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4662 | } |
| 4663 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4664 | static int |
| 4665 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4666 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4667 | struct drm_device *dev = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4668 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4669 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4670 | /* |
| 4671 | * There is no safeguard against this debugfs entry colliding |
| 4672 | * with the hangcheck calling same i915_handle_error() in |
| 4673 | * parallel, causing an explosion. For now we assume that the |
| 4674 | * test harness is responsible enough not to inject gpu hangs |
| 4675 | * while it is writing to 'i915_wedged' |
| 4676 | */ |
| 4677 | |
| 4678 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
| 4679 | return -EAGAIN; |
| 4680 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4681 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4682 | |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4683 | i915_handle_error(dev, val, |
| 4684 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4685 | |
| 4686 | intel_runtime_pm_put(dev_priv); |
| 4687 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4688 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4689 | } |
| 4690 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4691 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4692 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4693 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4694 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4695 | static int |
| 4696 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4697 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4698 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4699 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4700 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4701 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4702 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4703 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4704 | } |
| 4705 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4706 | static int |
| 4707 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4708 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4709 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4710 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4711 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4712 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4713 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4714 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4715 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4716 | if (ret) |
| 4717 | return ret; |
| 4718 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 4719 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4720 | mutex_unlock(&dev->struct_mutex); |
| 4721 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4722 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4723 | } |
| 4724 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4725 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 4726 | i915_ring_stop_get, i915_ring_stop_set, |
| 4727 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 4728 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4729 | static int |
| 4730 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4731 | { |
| 4732 | struct drm_device *dev = data; |
| 4733 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4734 | |
| 4735 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4736 | return 0; |
| 4737 | } |
| 4738 | |
| 4739 | static int |
| 4740 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4741 | { |
| 4742 | struct drm_device *dev = data; |
| 4743 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4744 | int ret; |
| 4745 | |
| 4746 | /* Lock against concurrent debugfs callers */ |
| 4747 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4748 | if (ret) |
| 4749 | return ret; |
| 4750 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4751 | mutex_unlock(&dev->struct_mutex); |
| 4752 | |
| 4753 | return 0; |
| 4754 | } |
| 4755 | |
| 4756 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4757 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4758 | "0x%08llx\n"); |
| 4759 | |
| 4760 | static int |
| 4761 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4762 | { |
| 4763 | struct drm_device *dev = data; |
| 4764 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4765 | |
| 4766 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4767 | |
| 4768 | return 0; |
| 4769 | } |
| 4770 | |
| 4771 | static int |
| 4772 | i915_ring_test_irq_set(void *data, u64 val) |
| 4773 | { |
| 4774 | struct drm_device *dev = data; |
| 4775 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4776 | int ret; |
| 4777 | |
| 4778 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 4779 | |
| 4780 | /* Lock against concurrent debugfs callers */ |
| 4781 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4782 | if (ret) |
| 4783 | return ret; |
| 4784 | |
| 4785 | dev_priv->gpu_error.test_irq_rings = val; |
| 4786 | mutex_unlock(&dev->struct_mutex); |
| 4787 | |
| 4788 | return 0; |
| 4789 | } |
| 4790 | |
| 4791 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4792 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4793 | "0x%08llx\n"); |
| 4794 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4795 | #define DROP_UNBOUND 0x1 |
| 4796 | #define DROP_BOUND 0x2 |
| 4797 | #define DROP_RETIRE 0x4 |
| 4798 | #define DROP_ACTIVE 0x8 |
| 4799 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4800 | DROP_BOUND | \ |
| 4801 | DROP_RETIRE | \ |
| 4802 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4803 | static int |
| 4804 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4805 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4806 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4807 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4808 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4809 | } |
| 4810 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4811 | static int |
| 4812 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4813 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4814 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4815 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4816 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4817 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4818 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4819 | |
| 4820 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4821 | * on ioctls on -EAGAIN. */ |
| 4822 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4823 | if (ret) |
| 4824 | return ret; |
| 4825 | |
| 4826 | if (val & DROP_ACTIVE) { |
| 4827 | ret = i915_gpu_idle(dev); |
| 4828 | if (ret) |
| 4829 | goto unlock; |
| 4830 | } |
| 4831 | |
| 4832 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 4833 | i915_gem_retire_requests(dev); |
| 4834 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4835 | if (val & DROP_BOUND) |
| 4836 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4837 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4838 | if (val & DROP_UNBOUND) |
| 4839 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4840 | |
| 4841 | unlock: |
| 4842 | mutex_unlock(&dev->struct_mutex); |
| 4843 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4844 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4845 | } |
| 4846 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4847 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4848 | i915_drop_caches_get, i915_drop_caches_set, |
| 4849 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4850 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4851 | static int |
| 4852 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4853 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4854 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4855 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4856 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4857 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4858 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4859 | return -ENODEV; |
| 4860 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4861 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4862 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4863 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4864 | if (ret) |
| 4865 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4866 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4867 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4868 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4869 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4870 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4871 | } |
| 4872 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4873 | static int |
| 4874 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4875 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4876 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4877 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4878 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4879 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4880 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4881 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4882 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4883 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4884 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4885 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4886 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4887 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4888 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4889 | if (ret) |
| 4890 | return ret; |
| 4891 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4892 | /* |
| 4893 | * Turbo will still be enabled, but won't go above the set value. |
| 4894 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4895 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4896 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4897 | hw_max = dev_priv->rps.max_freq; |
| 4898 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4899 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4900 | 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] | 4901 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4902 | return -EINVAL; |
| 4903 | } |
| 4904 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4905 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4906 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4907 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4908 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4909 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4910 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4911 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4912 | } |
| 4913 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4914 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4915 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4916 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4917 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4918 | static int |
| 4919 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4920 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4921 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4922 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4923 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4924 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4925 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4926 | return -ENODEV; |
| 4927 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4928 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4929 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4930 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4931 | if (ret) |
| 4932 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4933 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4934 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4935 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4936 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4937 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4938 | } |
| 4939 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4940 | static int |
| 4941 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4942 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4943 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4944 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4945 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4946 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4947 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4948 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4949 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4950 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4951 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4952 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4953 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4954 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4955 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4956 | if (ret) |
| 4957 | return ret; |
| 4958 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4959 | /* |
| 4960 | * Turbo will still be enabled, but won't go below the set value. |
| 4961 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4962 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4963 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4964 | hw_max = dev_priv->rps.max_freq; |
| 4965 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4966 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4967 | 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] | 4968 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4969 | return -EINVAL; |
| 4970 | } |
| 4971 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4972 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4973 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4974 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4975 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4976 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4977 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4978 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4979 | } |
| 4980 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4981 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4982 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4983 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4984 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4985 | static int |
| 4986 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4987 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4988 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4989 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4990 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4991 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4992 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4993 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4994 | return -ENODEV; |
| 4995 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4996 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4997 | if (ret) |
| 4998 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4999 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 5000 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5001 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5002 | |
| 5003 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5004 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 5005 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5006 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5007 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5008 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5009 | } |
| 5010 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5011 | static int |
| 5012 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5013 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5014 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5015 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5016 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5017 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 5018 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 5019 | return -ENODEV; |
| 5020 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5021 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5022 | return -EINVAL; |
| 5023 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5024 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5025 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5026 | |
| 5027 | /* Update the cache sharing policy here as well */ |
| 5028 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 5029 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 5030 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 5031 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 5032 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 5033 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5034 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5035 | } |
| 5036 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 5037 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 5038 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 5039 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5040 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5041 | struct sseu_dev_status { |
| 5042 | unsigned int slice_total; |
| 5043 | unsigned int subslice_total; |
| 5044 | unsigned int subslice_per_slice; |
| 5045 | unsigned int eu_total; |
| 5046 | unsigned int eu_per_subslice; |
| 5047 | }; |
| 5048 | |
| 5049 | static void cherryview_sseu_device_status(struct drm_device *dev, |
| 5050 | struct sseu_dev_status *stat) |
| 5051 | { |
| 5052 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 0a0b457 | 2015-08-21 20:45:27 +0300 | [diff] [blame] | 5053 | int ss_max = 2; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5054 | int ss; |
| 5055 | u32 sig1[ss_max], sig2[ss_max]; |
| 5056 | |
| 5057 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 5058 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 5059 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 5060 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 5061 | |
| 5062 | for (ss = 0; ss < ss_max; ss++) { |
| 5063 | unsigned int eu_cnt; |
| 5064 | |
| 5065 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 5066 | /* skip disabled subslice */ |
| 5067 | continue; |
| 5068 | |
| 5069 | stat->slice_total = 1; |
| 5070 | stat->subslice_per_slice++; |
| 5071 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 5072 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 5073 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 5074 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
| 5075 | stat->eu_total += eu_cnt; |
| 5076 | stat->eu_per_subslice = max(stat->eu_per_subslice, eu_cnt); |
| 5077 | } |
| 5078 | stat->subslice_total = stat->subslice_per_slice; |
| 5079 | } |
| 5080 | |
| 5081 | static void gen9_sseu_device_status(struct drm_device *dev, |
| 5082 | struct sseu_dev_status *stat) |
| 5083 | { |
| 5084 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5085 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5086 | int s, ss; |
| 5087 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 5088 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5089 | /* BXT has a single slice and at most 3 subslices. */ |
| 5090 | if (IS_BROXTON(dev)) { |
| 5091 | s_max = 1; |
| 5092 | ss_max = 3; |
| 5093 | } |
| 5094 | |
| 5095 | for (s = 0; s < s_max; s++) { |
| 5096 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 5097 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 5098 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 5099 | } |
| 5100 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5101 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 5102 | GEN9_PGCTL_SSA_EU19_ACK | |
| 5103 | GEN9_PGCTL_SSA_EU210_ACK | |
| 5104 | GEN9_PGCTL_SSA_EU311_ACK; |
| 5105 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 5106 | GEN9_PGCTL_SSB_EU19_ACK | |
| 5107 | GEN9_PGCTL_SSB_EU210_ACK | |
| 5108 | GEN9_PGCTL_SSB_EU311_ACK; |
| 5109 | |
| 5110 | for (s = 0; s < s_max; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5111 | unsigned int ss_cnt = 0; |
| 5112 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5113 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 5114 | /* skip disabled slice */ |
| 5115 | continue; |
| 5116 | |
| 5117 | stat->slice_total++; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5118 | |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 5119 | if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5120 | ss_cnt = INTEL_INFO(dev)->subslice_per_slice; |
| 5121 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5122 | for (ss = 0; ss < ss_max; ss++) { |
| 5123 | unsigned int eu_cnt; |
| 5124 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5125 | if (IS_BROXTON(dev) && |
| 5126 | !(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 5127 | /* skip disabled subslice */ |
| 5128 | continue; |
| 5129 | |
| 5130 | if (IS_BROXTON(dev)) |
| 5131 | ss_cnt++; |
| 5132 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5133 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 5134 | eu_mask[ss%2]); |
| 5135 | stat->eu_total += eu_cnt; |
| 5136 | stat->eu_per_subslice = max(stat->eu_per_subslice, |
| 5137 | eu_cnt); |
| 5138 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5139 | |
| 5140 | stat->subslice_total += ss_cnt; |
| 5141 | stat->subslice_per_slice = max(stat->subslice_per_slice, |
| 5142 | ss_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5143 | } |
| 5144 | } |
| 5145 | |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5146 | static void broadwell_sseu_device_status(struct drm_device *dev, |
| 5147 | struct sseu_dev_status *stat) |
| 5148 | { |
| 5149 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 5150 | int s; |
| 5151 | u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO); |
| 5152 | |
| 5153 | stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK); |
| 5154 | |
| 5155 | if (stat->slice_total) { |
| 5156 | stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice; |
| 5157 | stat->subslice_total = stat->slice_total * |
| 5158 | stat->subslice_per_slice; |
| 5159 | stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice; |
| 5160 | stat->eu_total = stat->eu_per_subslice * stat->subslice_total; |
| 5161 | |
| 5162 | /* subtract fused off EU(s) from enabled slice(s) */ |
| 5163 | for (s = 0; s < stat->slice_total; s++) { |
| 5164 | u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s]; |
| 5165 | |
| 5166 | stat->eu_total -= hweight8(subslice_7eu); |
| 5167 | } |
| 5168 | } |
| 5169 | } |
| 5170 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5171 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 5172 | { |
| 5173 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 5174 | struct drm_device *dev = node->minor->dev; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5175 | struct sseu_dev_status stat; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5176 | |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5177 | if (INTEL_INFO(dev)->gen < 8) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5178 | return -ENODEV; |
| 5179 | |
| 5180 | seq_puts(m, "SSEU Device Info\n"); |
| 5181 | seq_printf(m, " Available Slice Total: %u\n", |
| 5182 | INTEL_INFO(dev)->slice_total); |
| 5183 | seq_printf(m, " Available Subslice Total: %u\n", |
| 5184 | INTEL_INFO(dev)->subslice_total); |
| 5185 | seq_printf(m, " Available Subslice Per Slice: %u\n", |
| 5186 | INTEL_INFO(dev)->subslice_per_slice); |
| 5187 | seq_printf(m, " Available EU Total: %u\n", |
| 5188 | INTEL_INFO(dev)->eu_total); |
| 5189 | seq_printf(m, " Available EU Per Subslice: %u\n", |
| 5190 | INTEL_INFO(dev)->eu_per_subslice); |
| 5191 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 5192 | yesno(INTEL_INFO(dev)->has_slice_pg)); |
| 5193 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 5194 | yesno(INTEL_INFO(dev)->has_subslice_pg)); |
| 5195 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 5196 | yesno(INTEL_INFO(dev)->has_eu_pg)); |
| 5197 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5198 | seq_puts(m, "SSEU Device Status\n"); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5199 | memset(&stat, 0, sizeof(stat)); |
Jeff McGee | 5575f03 | 2015-02-27 10:22:32 -0800 | [diff] [blame] | 5200 | if (IS_CHERRYVIEW(dev)) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5201 | cherryview_sseu_device_status(dev, &stat); |
Łukasz Daniluk | 91bedd3 | 2015-09-25 11:54:58 +0200 | [diff] [blame] | 5202 | } else if (IS_BROADWELL(dev)) { |
| 5203 | broadwell_sseu_device_status(dev, &stat); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 5204 | } else if (INTEL_INFO(dev)->gen >= 9) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5205 | gen9_sseu_device_status(dev, &stat); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5206 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 5207 | seq_printf(m, " Enabled Slice Total: %u\n", |
| 5208 | stat.slice_total); |
| 5209 | seq_printf(m, " Enabled Subslice Total: %u\n", |
| 5210 | stat.subslice_total); |
| 5211 | seq_printf(m, " Enabled Subslice Per Slice: %u\n", |
| 5212 | stat.subslice_per_slice); |
| 5213 | seq_printf(m, " Enabled EU Total: %u\n", |
| 5214 | stat.eu_total); |
| 5215 | seq_printf(m, " Enabled EU Per Subslice: %u\n", |
| 5216 | stat.eu_per_subslice); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 5217 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5218 | return 0; |
| 5219 | } |
| 5220 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5221 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 5222 | { |
| 5223 | struct drm_device *dev = inode->i_private; |
| 5224 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5225 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 5226 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5227 | return 0; |
| 5228 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5229 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5230 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5231 | |
| 5232 | return 0; |
| 5233 | } |
| 5234 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 5235 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5236 | { |
| 5237 | struct drm_device *dev = inode->i_private; |
| 5238 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 5239 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 5240 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5241 | return 0; |
| 5242 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 5243 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 5244 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5245 | |
| 5246 | return 0; |
| 5247 | } |
| 5248 | |
| 5249 | static const struct file_operations i915_forcewake_fops = { |
| 5250 | .owner = THIS_MODULE, |
| 5251 | .open = i915_forcewake_open, |
| 5252 | .release = i915_forcewake_release, |
| 5253 | }; |
| 5254 | |
| 5255 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 5256 | { |
| 5257 | struct drm_device *dev = minor->dev; |
| 5258 | struct dentry *ent; |
| 5259 | |
| 5260 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5261 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5262 | root, dev, |
| 5263 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5264 | if (!ent) |
| 5265 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5266 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5267 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5268 | } |
| 5269 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5270 | static int i915_debugfs_create(struct dentry *root, |
| 5271 | struct drm_minor *minor, |
| 5272 | const char *name, |
| 5273 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5274 | { |
| 5275 | struct drm_device *dev = minor->dev; |
| 5276 | struct dentry *ent; |
| 5277 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5278 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5279 | S_IRUGO | S_IWUSR, |
| 5280 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5281 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5282 | if (!ent) |
| 5283 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5284 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5285 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5286 | } |
| 5287 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5288 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 5289 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 5290 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 5291 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 5292 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5293 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5294 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 5295 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 5296 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5297 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 5298 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 5299 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5300 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 5301 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 5302 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 5303 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 5304 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 5305 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Dave Gordon | 8b417c2 | 2015-08-12 15:43:44 +0100 | [diff] [blame] | 5306 | {"i915_guc_info", i915_guc_info, 0}, |
Alex Dai | fdf5d35 | 2015-08-12 15:43:37 +0100 | [diff] [blame] | 5307 | {"i915_guc_load_status", i915_guc_load_status_info, 0}, |
Alex Dai | 4c7e77f | 2015-08-12 15:43:40 +0100 | [diff] [blame] | 5308 | {"i915_guc_log_dump", i915_guc_log_dump, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 5309 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 5310 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 5311 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 5312 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 5313 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 5314 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 5315 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 5316 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 5317 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 5318 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 5319 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 5320 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 5321 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 5322 | {"i915_execlists", i915_execlists, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 5323 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 5324 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 5325 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 5326 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 5327 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 5328 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 5329 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 5330 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 5331 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Damien Lespiau | b7cec66 | 2015-10-27 14:47:01 +0200 | [diff] [blame] | 5332 | {"i915_dmc_info", i915_dmc_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 5333 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 5334 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 5335 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 5336 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 5337 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 5338 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5339 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 5340 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 5341 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5342 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5343 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5344 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5345 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5346 | const char *name; |
| 5347 | const struct file_operations *fops; |
| 5348 | } i915_debugfs_files[] = { |
| 5349 | {"i915_wedged", &i915_wedged_fops}, |
| 5350 | {"i915_max_freq", &i915_max_freq_fops}, |
| 5351 | {"i915_min_freq", &i915_min_freq_fops}, |
| 5352 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 5353 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 5354 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 5355 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5356 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 5357 | {"i915_error_state", &i915_error_state_fops}, |
| 5358 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 5359 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 5360 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 5361 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 5362 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 5363 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 5364 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 5365 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
| 5366 | {"i915_dp_test_active", &i915_displayport_test_active_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5367 | }; |
| 5368 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5369 | void intel_display_crc_init(struct drm_device *dev) |
| 5370 | { |
| 5371 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5372 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5373 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 5374 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5375 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5376 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 5377 | pipe_crc->opened = false; |
| 5378 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5379 | init_waitqueue_head(&pipe_crc->wq); |
| 5380 | } |
| 5381 | } |
| 5382 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5383 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5384 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5385 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 5386 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5387 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 5388 | if (ret) |
| 5389 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5390 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5391 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 5392 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 5393 | if (ret) |
| 5394 | return ret; |
| 5395 | } |
| 5396 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5397 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5398 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 5399 | i915_debugfs_files[i].name, |
| 5400 | i915_debugfs_files[i].fops); |
| 5401 | if (ret) |
| 5402 | return ret; |
| 5403 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 5404 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5405 | return drm_debugfs_create_files(i915_debugfs_list, |
| 5406 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5407 | minor->debugfs_root, minor); |
| 5408 | } |
| 5409 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5410 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5411 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5412 | int i; |
| 5413 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5414 | drm_debugfs_remove_files(i915_debugfs_list, |
| 5415 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5416 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5417 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 5418 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5419 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 5420 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5421 | struct drm_info_list *info_list = |
| 5422 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 5423 | |
| 5424 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5425 | } |
| 5426 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5427 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5428 | struct drm_info_list *info_list = |
| 5429 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 5430 | |
| 5431 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5432 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5433 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5434 | |
| 5435 | struct dpcd_block { |
| 5436 | /* DPCD dump start address. */ |
| 5437 | unsigned int offset; |
| 5438 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 5439 | unsigned int end; |
| 5440 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 5441 | size_t size; |
| 5442 | /* Only valid for eDP. */ |
| 5443 | bool edp; |
| 5444 | }; |
| 5445 | |
| 5446 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 5447 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 5448 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 5449 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 5450 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 5451 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 5452 | { .offset = DP_SET_POWER }, |
| 5453 | { .offset = DP_EDP_DPCD_REV }, |
| 5454 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 5455 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 5456 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 5457 | }; |
| 5458 | |
| 5459 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 5460 | { |
| 5461 | struct drm_connector *connector = m->private; |
| 5462 | struct intel_dp *intel_dp = |
| 5463 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5464 | uint8_t buf[16]; |
| 5465 | ssize_t err; |
| 5466 | int i; |
| 5467 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 5468 | if (connector->status != connector_status_connected) |
| 5469 | return -ENODEV; |
| 5470 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5471 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 5472 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 5473 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 5474 | |
| 5475 | if (b->edp && |
| 5476 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 5477 | continue; |
| 5478 | |
| 5479 | /* low tech for now */ |
| 5480 | if (WARN_ON(size > sizeof(buf))) |
| 5481 | continue; |
| 5482 | |
| 5483 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 5484 | if (err <= 0) { |
| 5485 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 5486 | size, b->offset, err); |
| 5487 | continue; |
| 5488 | } |
| 5489 | |
| 5490 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 5491 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5492 | |
| 5493 | return 0; |
| 5494 | } |
| 5495 | |
| 5496 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5497 | { |
| 5498 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5499 | } |
| 5500 | |
| 5501 | static const struct file_operations i915_dpcd_fops = { |
| 5502 | .owner = THIS_MODULE, |
| 5503 | .open = i915_dpcd_open, |
| 5504 | .read = seq_read, |
| 5505 | .llseek = seq_lseek, |
| 5506 | .release = single_release, |
| 5507 | }; |
| 5508 | |
| 5509 | /** |
| 5510 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5511 | * @connector: pointer to a registered drm_connector |
| 5512 | * |
| 5513 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5514 | * drm_debugfs_connector_remove(). |
| 5515 | * |
| 5516 | * Returns 0 on success, negative error codes on error. |
| 5517 | */ |
| 5518 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5519 | { |
| 5520 | struct dentry *root = connector->debugfs_entry; |
| 5521 | |
| 5522 | /* The connector must have been registered beforehands. */ |
| 5523 | if (!root) |
| 5524 | return -ENODEV; |
| 5525 | |
| 5526 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5527 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5528 | debugfs_create_file("i915_dpcd", S_IRUGO, root, connector, |
| 5529 | &i915_dpcd_fops); |
| 5530 | |
| 5531 | return 0; |
| 5532 | } |