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 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 49 | static const char *yesno(int v) |
| 50 | { |
| 51 | return v ? "yes" : "no"; |
| 52 | } |
| 53 | |
Damien Lespiau | 497666d | 2013-10-15 18:55:39 +0100 | [diff] [blame] | 54 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 55 | * allocated we need to hook into the minor for release. */ |
| 56 | static int |
| 57 | drm_add_fake_info_node(struct drm_minor *minor, |
| 58 | struct dentry *ent, |
| 59 | const void *key) |
| 60 | { |
| 61 | struct drm_info_node *node; |
| 62 | |
| 63 | node = kmalloc(sizeof(*node), GFP_KERNEL); |
| 64 | if (node == NULL) { |
| 65 | debugfs_remove(ent); |
| 66 | return -ENOMEM; |
| 67 | } |
| 68 | |
| 69 | node->minor = minor; |
| 70 | node->dent = ent; |
| 71 | node->info_ent = (void *) key; |
| 72 | |
| 73 | mutex_lock(&minor->debugfs_lock); |
| 74 | list_add(&node->list, &minor->debugfs_list); |
| 75 | mutex_unlock(&minor->debugfs_lock); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 80 | static int i915_capabilities(struct seq_file *m, void *data) |
| 81 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 82 | struct drm_info_node *node = m->private; |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 83 | struct drm_device *dev = node->minor->dev; |
| 84 | const struct intel_device_info *info = INTEL_INFO(dev); |
| 85 | |
| 86 | seq_printf(m, "gen: %d\n", info->gen); |
Paulo Zanoni | 03d00ac | 2011-10-14 18:17:41 -0300 | [diff] [blame] | 87 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev)); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 88 | #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
| 89 | #define SEP_SEMICOLON ; |
| 90 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON); |
| 91 | #undef PRINT_FLAG |
| 92 | #undef SEP_SEMICOLON |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 93 | |
| 94 | return 0; |
| 95 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 96 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 97 | static const char *get_pin_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 98 | { |
Chris Wilson | baaa5cf | 2015-04-15 16:42:46 +0100 | [diff] [blame] | 99 | if (obj->pin_display) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 100 | return "p"; |
| 101 | else |
| 102 | return " "; |
| 103 | } |
| 104 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 105 | static const char *get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 106 | { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 107 | switch (obj->tiling_mode) { |
| 108 | default: |
| 109 | case I915_TILING_NONE: return " "; |
| 110 | case I915_TILING_X: return "X"; |
| 111 | case I915_TILING_Y: return "Y"; |
| 112 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 115 | static inline const char *get_global_flag(struct drm_i915_gem_object *obj) |
| 116 | { |
Tvrtko Ursulin | aff4376 | 2014-10-24 12:42:33 +0100 | [diff] [blame] | 117 | return i915_gem_obj_to_ggtt(obj) ? "g" : " "; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 120 | static void |
| 121 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 122 | { |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 123 | struct drm_i915_private *dev_priv = to_i915(obj->base.dev); |
| 124 | struct intel_engine_cs *ring; |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 125 | struct i915_vma *vma; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 126 | int pin_count = 0; |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 127 | int i; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 128 | |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 129 | seq_printf(m, "%pK: %s%s%s%s %8zdKiB %02x %02x [ ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 130 | &obj->base, |
Chris Wilson | 481a3d4 | 2015-04-07 16:20:39 +0100 | [diff] [blame] | 131 | obj->active ? "*" : " ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 132 | get_pin_flag(obj), |
| 133 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 134 | get_global_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 135 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 136 | obj->base.read_domains, |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 137 | obj->base.write_domain); |
| 138 | for_each_ring(ring, dev_priv, i) |
| 139 | seq_printf(m, "%x ", |
| 140 | i915_gem_request_get_seqno(obj->last_read_req[i])); |
| 141 | seq_printf(m, "] %x %x%s%s%s", |
John Harrison | 97b2a6a | 2014-11-24 18:49:26 +0000 | [diff] [blame] | 142 | i915_gem_request_get_seqno(obj->last_write_req), |
| 143 | i915_gem_request_get_seqno(obj->last_fenced_req), |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 144 | i915_cache_level_str(to_i915(obj->base.dev), obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 145 | obj->dirty ? " dirty" : "", |
| 146 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 147 | if (obj->base.name) |
| 148 | seq_printf(m, " (name: %d)", obj->base.name); |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 149 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 150 | if (vma->pin_count > 0) |
| 151 | pin_count++; |
Dan Carpenter | ba0635ff | 2015-02-25 16:17:48 +0300 | [diff] [blame] | 152 | } |
| 153 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 154 | if (obj->pin_display) |
| 155 | seq_printf(m, " (display)"); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 156 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 157 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 158 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 159 | seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", |
| 160 | i915_is_ggtt(vma->vm) ? "g" : "pp", |
| 161 | vma->node.start, vma->node.size); |
| 162 | if (i915_is_ggtt(vma->vm)) |
| 163 | seq_printf(m, ", type: %u)", vma->ggtt_view.type); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 164 | else |
Tvrtko Ursulin | 8d2fdc3 | 2015-05-27 10:52:32 +0100 | [diff] [blame] | 165 | seq_puts(m, ")"); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 166 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 167 | if (obj->stolen) |
Thierry Reding | 440fd52 | 2015-01-23 09:05:06 +0100 | [diff] [blame] | 168 | seq_printf(m, " (stolen: %08llx)", obj->stolen->start); |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 169 | if (obj->pin_display || obj->fault_mappable) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 170 | char s[3], *t = s; |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 171 | if (obj->pin_display) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 172 | *t++ = 'p'; |
| 173 | if (obj->fault_mappable) |
| 174 | *t++ = 'f'; |
| 175 | *t = '\0'; |
| 176 | seq_printf(m, " (%s mappable)", s); |
| 177 | } |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 178 | if (obj->last_write_req != NULL) |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 179 | seq_printf(m, " (%s)", |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 180 | i915_gem_request_get_ring(obj->last_write_req)->name); |
Daniel Vetter | d5a81ef | 2014-06-18 14:46:49 +0200 | [diff] [blame] | 181 | if (obj->frontbuffer_bits) |
| 182 | seq_printf(m, " (frontbuffer: 0x%03x)", obj->frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 183 | } |
| 184 | |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 185 | static void describe_ctx(struct seq_file *m, struct intel_context *ctx) |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 186 | { |
Oscar Mateo | ea0c76f | 2014-07-03 16:27:59 +0100 | [diff] [blame] | 187 | seq_putc(m, ctx->legacy_hw_ctx.initialized ? 'I' : 'i'); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 188 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 189 | seq_putc(m, ' '); |
| 190 | } |
| 191 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 192 | 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] | 193 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 194 | struct drm_info_node *node = m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 195 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 196 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 197 | struct drm_device *dev = node->minor->dev; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 198 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 199 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 200 | struct i915_vma *vma; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 201 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 202 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 203 | |
| 204 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 205 | if (ret) |
| 206 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 207 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 208 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 209 | switch (list) { |
| 210 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 211 | seq_puts(m, "Active:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 212 | head = &vm->active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 213 | break; |
| 214 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 215 | seq_puts(m, "Inactive:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 216 | head = &vm->inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 217 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 218 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 219 | mutex_unlock(&dev->struct_mutex); |
| 220 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 221 | } |
| 222 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 223 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 224 | list_for_each_entry(vma, head, mm_list) { |
| 225 | seq_printf(m, " "); |
| 226 | describe_obj(m, vma->obj); |
| 227 | seq_printf(m, "\n"); |
| 228 | total_obj_size += vma->obj->base.size; |
| 229 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 230 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 231 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 232 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 233 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 234 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 235 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 236 | return 0; |
| 237 | } |
| 238 | |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 239 | static int obj_rank_by_stolen(void *priv, |
| 240 | struct list_head *A, struct list_head *B) |
| 241 | { |
| 242 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 243 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 244 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 245 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 246 | |
| 247 | return a->stolen->start - b->stolen->start; |
| 248 | } |
| 249 | |
| 250 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 251 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 252 | struct drm_info_node *node = m->private; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 253 | struct drm_device *dev = node->minor->dev; |
| 254 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 255 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 256 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 257 | LIST_HEAD(stolen); |
| 258 | int count, ret; |
| 259 | |
| 260 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 261 | if (ret) |
| 262 | return ret; |
| 263 | |
| 264 | total_obj_size = total_gtt_size = count = 0; |
| 265 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 266 | if (obj->stolen == NULL) |
| 267 | continue; |
| 268 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 269 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 270 | |
| 271 | total_obj_size += obj->base.size; |
| 272 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
| 273 | count++; |
| 274 | } |
| 275 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 276 | if (obj->stolen == NULL) |
| 277 | continue; |
| 278 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 279 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | |
| 281 | total_obj_size += obj->base.size; |
| 282 | count++; |
| 283 | } |
| 284 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 285 | seq_puts(m, "Stolen:\n"); |
| 286 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 287 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 288 | seq_puts(m, " "); |
| 289 | describe_obj(m, obj); |
| 290 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 291 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 292 | } |
| 293 | mutex_unlock(&dev->struct_mutex); |
| 294 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 295 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 296 | count, total_obj_size, total_gtt_size); |
| 297 | return 0; |
| 298 | } |
| 299 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 300 | #define count_objects(list, member) do { \ |
| 301 | list_for_each_entry(obj, list, member) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 302 | size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 303 | ++count; \ |
| 304 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 305 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 306 | ++mappable_count; \ |
| 307 | } \ |
| 308 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 309 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 310 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 311 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 312 | struct drm_i915_file_private *file_priv; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 313 | unsigned long count; |
| 314 | u64 total, unbound; |
| 315 | u64 global, shared; |
| 316 | u64 active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 317 | }; |
| 318 | |
| 319 | static int per_file_stats(int id, void *ptr, void *data) |
| 320 | { |
| 321 | struct drm_i915_gem_object *obj = ptr; |
| 322 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 323 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 324 | |
| 325 | stats->count++; |
| 326 | stats->total += obj->base.size; |
| 327 | |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 328 | if (obj->base.name || obj->base.dma_buf) |
| 329 | stats->shared += obj->base.size; |
| 330 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 331 | if (USES_FULL_PPGTT(obj->base.dev)) { |
| 332 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 333 | struct i915_hw_ppgtt *ppgtt; |
| 334 | |
| 335 | if (!drm_mm_node_allocated(&vma->node)) |
| 336 | continue; |
| 337 | |
| 338 | if (i915_is_ggtt(vma->vm)) { |
| 339 | stats->global += obj->base.size; |
| 340 | continue; |
| 341 | } |
| 342 | |
| 343 | ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base); |
Daniel Vetter | 4d88470 | 2014-08-06 15:04:47 +0200 | [diff] [blame] | 344 | if (ppgtt->file_priv != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 345 | continue; |
| 346 | |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 347 | if (obj->active) /* XXX per-vma statistic */ |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 348 | stats->active += obj->base.size; |
| 349 | else |
| 350 | stats->inactive += obj->base.size; |
| 351 | |
| 352 | return 0; |
| 353 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 354 | } else { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 355 | if (i915_gem_obj_ggtt_bound(obj)) { |
| 356 | stats->global += obj->base.size; |
John Harrison | 41c5241 | 2014-11-24 18:49:43 +0000 | [diff] [blame] | 357 | if (obj->active) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 358 | stats->active += obj->base.size; |
| 359 | else |
| 360 | stats->inactive += obj->base.size; |
| 361 | return 0; |
| 362 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 363 | } |
| 364 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 365 | if (!list_empty(&obj->global_list)) |
| 366 | stats->unbound += obj->base.size; |
| 367 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 368 | return 0; |
| 369 | } |
| 370 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 371 | #define print_file_stats(m, name, stats) do { \ |
| 372 | if (stats.count) \ |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 373 | 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] | 374 | name, \ |
| 375 | stats.count, \ |
| 376 | stats.total, \ |
| 377 | stats.active, \ |
| 378 | stats.inactive, \ |
| 379 | stats.global, \ |
| 380 | stats.shared, \ |
| 381 | stats.unbound); \ |
| 382 | } while (0) |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 383 | |
| 384 | static void print_batch_pool_stats(struct seq_file *m, |
| 385 | struct drm_i915_private *dev_priv) |
| 386 | { |
| 387 | struct drm_i915_gem_object *obj; |
| 388 | struct file_stats stats; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 389 | struct intel_engine_cs *ring; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 390 | int i, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 391 | |
| 392 | memset(&stats, 0, sizeof(stats)); |
| 393 | |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 394 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 395 | for (j = 0; j < ARRAY_SIZE(ring->batch_pool.cache_list); j++) { |
| 396 | list_for_each_entry(obj, |
| 397 | &ring->batch_pool.cache_list[j], |
| 398 | batch_pool_link) |
| 399 | per_file_stats(0, obj, &stats); |
| 400 | } |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 401 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 402 | |
Chris Wilson | b0da1b7 | 2015-04-07 16:20:40 +0100 | [diff] [blame] | 403 | print_file_stats(m, "[k]batch pool", stats); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 406 | #define count_vmas(list, member) do { \ |
| 407 | list_for_each_entry(vma, list, member) { \ |
| 408 | size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 409 | ++count; \ |
| 410 | if (vma->obj->map_and_fenceable) { \ |
| 411 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 412 | ++mappable_count; \ |
| 413 | } \ |
| 414 | } \ |
| 415 | } while (0) |
| 416 | |
| 417 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 418 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 419 | struct drm_info_node *node = m->private; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 420 | struct drm_device *dev = node->minor->dev; |
| 421 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 422 | u32 count, mappable_count, purgeable_count; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 423 | u64 size, mappable_size, purgeable_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 424 | struct drm_i915_gem_object *obj; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 425 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 426 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 427 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 428 | int ret; |
| 429 | |
| 430 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 431 | if (ret) |
| 432 | return ret; |
| 433 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 434 | seq_printf(m, "%u objects, %zu bytes\n", |
| 435 | dev_priv->mm.object_count, |
| 436 | dev_priv->mm.object_memory); |
| 437 | |
| 438 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 439 | count_objects(&dev_priv->mm.bound_list, global_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 440 | seq_printf(m, "%u [%u] objects, %llu [%llu] bytes in gtt\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 441 | count, mappable_count, size, mappable_size); |
| 442 | |
| 443 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 444 | count_vmas(&vm->active_list, mm_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 445 | seq_printf(m, " %u [%u] active objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 446 | count, mappable_count, size, mappable_size); |
| 447 | |
| 448 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 449 | count_vmas(&vm->inactive_list, mm_list); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 450 | seq_printf(m, " %u [%u] inactive objects, %llu [%llu] bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 451 | count, mappable_count, size, mappable_size); |
| 452 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 453 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 454 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 455 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 456 | if (obj->madv == I915_MADV_DONTNEED) |
| 457 | purgeable_size += obj->base.size, ++purgeable_count; |
| 458 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 459 | seq_printf(m, "%u unbound objects, %llu bytes\n", count, size); |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 460 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 461 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 462 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 463 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 464 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 465 | ++count; |
| 466 | } |
Chris Wilson | 3015465 | 2015-04-07 17:28:24 +0100 | [diff] [blame] | 467 | if (obj->pin_display) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 468 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 469 | ++mappable_count; |
| 470 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 471 | if (obj->madv == I915_MADV_DONTNEED) { |
| 472 | purgeable_size += obj->base.size; |
| 473 | ++purgeable_count; |
| 474 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 475 | } |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 476 | seq_printf(m, "%u purgeable objects, %llu bytes\n", |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 477 | purgeable_count, purgeable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 478 | seq_printf(m, "%u pinned mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 479 | mappable_count, mappable_size); |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 480 | seq_printf(m, "%u fault mappable objects, %llu bytes\n", |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 481 | count, size); |
| 482 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 483 | seq_printf(m, "%llu [%llu] gtt total\n", |
Ben Widawsky | 853ba5d | 2013-07-16 16:50:05 -0700 | [diff] [blame] | 484 | dev_priv->gtt.base.total, |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 485 | (u64)dev_priv->gtt.mappable_end - dev_priv->gtt.base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 486 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 487 | seq_putc(m, '\n'); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 488 | print_batch_pool_stats(m, dev_priv); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 489 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 490 | struct file_stats stats; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 491 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 492 | |
| 493 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 494 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 495 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 496 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 497 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 498 | /* |
| 499 | * Although we have a valid reference on file->pid, that does |
| 500 | * not guarantee that the task_struct who called get_pid() is |
| 501 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 502 | * Therefore, we need to protect this ->comm access using RCU. |
| 503 | */ |
| 504 | rcu_read_lock(); |
| 505 | task = pid_task(file->pid, PIDTYPE_PID); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 506 | print_file_stats(m, task ? task->comm : "<unknown>", stats); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 507 | rcu_read_unlock(); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 508 | } |
| 509 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 510 | mutex_unlock(&dev->struct_mutex); |
| 511 | |
| 512 | return 0; |
| 513 | } |
| 514 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 515 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 516 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 517 | struct drm_info_node *node = m->private; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 518 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 519 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 520 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 521 | struct drm_i915_gem_object *obj; |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 522 | u64 total_obj_size, total_gtt_size; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 523 | int count, ret; |
| 524 | |
| 525 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 526 | if (ret) |
| 527 | return ret; |
| 528 | |
| 529 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 530 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 531 | if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj)) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 532 | continue; |
| 533 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 534 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 535 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 536 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 537 | total_obj_size += obj->base.size; |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 538 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 539 | count++; |
| 540 | } |
| 541 | |
| 542 | mutex_unlock(&dev->struct_mutex); |
| 543 | |
Mika Kuoppala | c44ef60 | 2015-06-25 18:35:05 +0300 | [diff] [blame] | 544 | seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n", |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 545 | count, total_obj_size, total_gtt_size); |
| 546 | |
| 547 | return 0; |
| 548 | } |
| 549 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 550 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 551 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 552 | struct drm_info_node *node = m->private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 553 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 554 | struct drm_i915_private *dev_priv = dev->dev_private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 555 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 556 | int ret; |
| 557 | |
| 558 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 559 | if (ret) |
| 560 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 561 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 562 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 563 | const char pipe = pipe_name(crtc->pipe); |
| 564 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 565 | struct intel_unpin_work *work; |
| 566 | |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 567 | spin_lock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 568 | work = crtc->unpin_work; |
| 569 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 570 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 571 | pipe, plane); |
| 572 | } else { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 573 | u32 addr; |
| 574 | |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 575 | if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 576 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 577 | pipe, plane); |
| 578 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 579 | 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] | 580 | pipe, plane); |
| 581 | } |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 582 | if (work->flip_queued_req) { |
| 583 | struct intel_engine_cs *ring = |
| 584 | i915_gem_request_get_ring(work->flip_queued_req); |
| 585 | |
Mika Kuoppala | 20e28fb | 2015-01-26 18:03:06 +0200 | [diff] [blame] | 586 | 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] | 587 | ring->name, |
John Harrison | f06cc1b | 2014-11-24 18:49:37 +0000 | [diff] [blame] | 588 | i915_gem_request_get_seqno(work->flip_queued_req), |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 589 | dev_priv->next_seqno, |
Daniel Vetter | 3a8a946 | 2014-11-26 14:39:48 +0100 | [diff] [blame] | 590 | ring->get_seqno(ring, true), |
John Harrison | 1b5a433 | 2014-11-24 18:49:42 +0000 | [diff] [blame] | 591 | i915_gem_request_completed(work->flip_queued_req, true)); |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 592 | } else |
| 593 | seq_printf(m, "Flip not associated with any ring\n"); |
| 594 | seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n", |
| 595 | work->flip_queued_vblank, |
| 596 | work->flip_ready_vblank, |
Daniel Vetter | 1e3feef | 2015-02-13 21:03:45 +0100 | [diff] [blame] | 597 | drm_crtc_vblank_count(&crtc->base)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 598 | if (work->enable_stall_check) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 599 | seq_puts(m, "Stall check enabled, "); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 600 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 601 | seq_puts(m, "Stall check waiting for page flip ioctl, "); |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 602 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 603 | |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 604 | if (INTEL_INFO(dev)->gen >= 4) |
| 605 | addr = I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane))); |
| 606 | else |
| 607 | addr = I915_READ(DSPADDR(crtc->plane)); |
| 608 | seq_printf(m, "Current scanout address 0x%08x\n", addr); |
| 609 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 610 | if (work->pending_flip_obj) { |
Chris Wilson | d6bbafa | 2014-09-05 07:13:24 +0100 | [diff] [blame] | 611 | seq_printf(m, "New framebuffer address 0x%08lx\n", (long)work->gtt_offset); |
| 612 | seq_printf(m, "MMIO update completed? %d\n", addr == work->gtt_offset); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 613 | } |
| 614 | } |
Daniel Vetter | 5e2d7af | 2014-09-15 14:55:22 +0200 | [diff] [blame] | 615 | spin_unlock_irq(&dev->event_lock); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 616 | } |
| 617 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 618 | mutex_unlock(&dev->struct_mutex); |
| 619 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 620 | return 0; |
| 621 | } |
| 622 | |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 623 | static int i915_gem_batch_pool_info(struct seq_file *m, void *data) |
| 624 | { |
| 625 | struct drm_info_node *node = m->private; |
| 626 | struct drm_device *dev = node->minor->dev; |
| 627 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 628 | struct drm_i915_gem_object *obj; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 629 | struct intel_engine_cs *ring; |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 630 | int total = 0; |
| 631 | int ret, i, j; |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 632 | |
| 633 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 634 | if (ret) |
| 635 | return ret; |
| 636 | |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 637 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 638 | for (j = 0; j < ARRAY_SIZE(ring->batch_pool.cache_list); j++) { |
| 639 | int count; |
| 640 | |
| 641 | count = 0; |
| 642 | list_for_each_entry(obj, |
| 643 | &ring->batch_pool.cache_list[j], |
| 644 | batch_pool_link) |
| 645 | count++; |
| 646 | seq_printf(m, "%s cache[%d]: %d objects\n", |
| 647 | ring->name, j, count); |
| 648 | |
| 649 | list_for_each_entry(obj, |
| 650 | &ring->batch_pool.cache_list[j], |
| 651 | batch_pool_link) { |
| 652 | seq_puts(m, " "); |
| 653 | describe_obj(m, obj); |
| 654 | seq_putc(m, '\n'); |
| 655 | } |
| 656 | |
| 657 | total += count; |
Chris Wilson | 06fbca7 | 2015-04-07 16:20:36 +0100 | [diff] [blame] | 658 | } |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 659 | } |
| 660 | |
Chris Wilson | 8d9d574 | 2015-04-07 16:20:38 +0100 | [diff] [blame] | 661 | seq_printf(m, "total: %d\n", total); |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 662 | |
| 663 | mutex_unlock(&dev->struct_mutex); |
| 664 | |
| 665 | return 0; |
| 666 | } |
| 667 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 668 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 669 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 670 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 671 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 672 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 673 | struct intel_engine_cs *ring; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 674 | struct drm_i915_gem_request *req; |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 675 | int ret, any, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 676 | |
| 677 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 678 | if (ret) |
| 679 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 680 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 681 | any = 0; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 682 | for_each_ring(ring, dev_priv, i) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 683 | int count; |
| 684 | |
| 685 | count = 0; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 686 | list_for_each_entry(req, &ring->request_list, list) |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 687 | count++; |
| 688 | if (count == 0) |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 689 | continue; |
| 690 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 691 | seq_printf(m, "%s requests: %d\n", ring->name, count); |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 692 | list_for_each_entry(req, &ring->request_list, list) { |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 693 | struct task_struct *task; |
| 694 | |
| 695 | rcu_read_lock(); |
| 696 | task = NULL; |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 697 | if (req->pid) |
| 698 | task = pid_task(req->pid, PIDTYPE_PID); |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 699 | seq_printf(m, " %x @ %d: %s [%d]\n", |
Daniel Vetter | eed29a5 | 2015-05-21 14:21:25 +0200 | [diff] [blame] | 700 | req->seqno, |
| 701 | (int) (jiffies - req->emitted_jiffies), |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 702 | task ? task->comm : "<unknown>", |
| 703 | task ? task->pid : -1); |
| 704 | rcu_read_unlock(); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 705 | } |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 706 | |
| 707 | any++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 708 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 709 | mutex_unlock(&dev->struct_mutex); |
| 710 | |
Chris Wilson | 2d1070b | 2015-04-01 10:36:56 +0100 | [diff] [blame] | 711 | if (any == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 712 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 713 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 714 | return 0; |
| 715 | } |
| 716 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 717 | static void i915_ring_seqno_info(struct seq_file *m, |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 718 | struct intel_engine_cs *ring) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 719 | { |
| 720 | if (ring->get_seqno) { |
Mika Kuoppala | 20e28fb | 2015-01-26 18:03:06 +0200 | [diff] [blame] | 721 | seq_printf(m, "Current sequence (%s): %x\n", |
Chris Wilson | b2eadbc | 2012-08-09 10:58:30 +0100 | [diff] [blame] | 722 | ring->name, ring->get_seqno(ring, false)); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 726 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 727 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 728 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 729 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 730 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 731 | struct intel_engine_cs *ring; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 732 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 733 | |
| 734 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 735 | if (ret) |
| 736 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 737 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 738 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 739 | for_each_ring(ring, dev_priv, i) |
| 740 | i915_ring_seqno_info(m, ring); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 741 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 742 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 743 | mutex_unlock(&dev->struct_mutex); |
| 744 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | |
| 749 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 750 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 751 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 752 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 753 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 754 | struct intel_engine_cs *ring; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 755 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 756 | |
| 757 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 758 | if (ret) |
| 759 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 760 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 761 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 762 | if (IS_CHERRYVIEW(dev)) { |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 763 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 764 | I915_READ(GEN8_MASTER_IRQ)); |
| 765 | |
| 766 | seq_printf(m, "Display IER:\t%08x\n", |
| 767 | I915_READ(VLV_IER)); |
| 768 | seq_printf(m, "Display IIR:\t%08x\n", |
| 769 | I915_READ(VLV_IIR)); |
| 770 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 771 | I915_READ(VLV_IIR_RW)); |
| 772 | seq_printf(m, "Display IMR:\t%08x\n", |
| 773 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 774 | for_each_pipe(dev_priv, pipe) |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 775 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 776 | pipe_name(pipe), |
| 777 | I915_READ(PIPESTAT(pipe))); |
| 778 | |
| 779 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 780 | I915_READ(PORT_HOTPLUG_EN)); |
| 781 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 782 | I915_READ(VLV_DPFLIPSTAT)); |
| 783 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 784 | I915_READ(DPINVGTT)); |
| 785 | |
| 786 | for (i = 0; i < 4; i++) { |
| 787 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 788 | i, I915_READ(GEN8_GT_IMR(i))); |
| 789 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 790 | i, I915_READ(GEN8_GT_IIR(i))); |
| 791 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 792 | i, I915_READ(GEN8_GT_IER(i))); |
| 793 | } |
| 794 | |
| 795 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 796 | I915_READ(GEN8_PCU_IMR)); |
| 797 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 798 | I915_READ(GEN8_PCU_IIR)); |
| 799 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 800 | I915_READ(GEN8_PCU_IER)); |
| 801 | } else if (INTEL_INFO(dev)->gen >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 802 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 803 | I915_READ(GEN8_MASTER_IRQ)); |
| 804 | |
| 805 | for (i = 0; i < 4; i++) { |
| 806 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 807 | i, I915_READ(GEN8_GT_IMR(i))); |
| 808 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 809 | i, I915_READ(GEN8_GT_IIR(i))); |
| 810 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 811 | i, I915_READ(GEN8_GT_IER(i))); |
| 812 | } |
| 813 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 814 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 815 | if (!intel_display_power_is_enabled(dev_priv, |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 816 | POWER_DOMAIN_PIPE(pipe))) { |
| 817 | seq_printf(m, "Pipe %c power disabled\n", |
| 818 | pipe_name(pipe)); |
| 819 | continue; |
| 820 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 821 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 822 | pipe_name(pipe), |
| 823 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 824 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 825 | pipe_name(pipe), |
| 826 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 827 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 828 | pipe_name(pipe), |
| 829 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 833 | I915_READ(GEN8_DE_PORT_IMR)); |
| 834 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 835 | I915_READ(GEN8_DE_PORT_IIR)); |
| 836 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 837 | I915_READ(GEN8_DE_PORT_IER)); |
| 838 | |
| 839 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 840 | I915_READ(GEN8_DE_MISC_IMR)); |
| 841 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 842 | I915_READ(GEN8_DE_MISC_IIR)); |
| 843 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 844 | I915_READ(GEN8_DE_MISC_IER)); |
| 845 | |
| 846 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 847 | I915_READ(GEN8_PCU_IMR)); |
| 848 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 849 | I915_READ(GEN8_PCU_IIR)); |
| 850 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 851 | I915_READ(GEN8_PCU_IER)); |
| 852 | } else if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 853 | seq_printf(m, "Display IER:\t%08x\n", |
| 854 | I915_READ(VLV_IER)); |
| 855 | seq_printf(m, "Display IIR:\t%08x\n", |
| 856 | I915_READ(VLV_IIR)); |
| 857 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 858 | I915_READ(VLV_IIR_RW)); |
| 859 | seq_printf(m, "Display IMR:\t%08x\n", |
| 860 | I915_READ(VLV_IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 861 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 862 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 863 | pipe_name(pipe), |
| 864 | I915_READ(PIPESTAT(pipe))); |
| 865 | |
| 866 | seq_printf(m, "Master IER:\t%08x\n", |
| 867 | I915_READ(VLV_MASTER_IER)); |
| 868 | |
| 869 | seq_printf(m, "Render IER:\t%08x\n", |
| 870 | I915_READ(GTIER)); |
| 871 | seq_printf(m, "Render IIR:\t%08x\n", |
| 872 | I915_READ(GTIIR)); |
| 873 | seq_printf(m, "Render IMR:\t%08x\n", |
| 874 | I915_READ(GTIMR)); |
| 875 | |
| 876 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 877 | I915_READ(GEN6_PMIER)); |
| 878 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 879 | I915_READ(GEN6_PMIIR)); |
| 880 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 881 | I915_READ(GEN6_PMIMR)); |
| 882 | |
| 883 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 884 | I915_READ(PORT_HOTPLUG_EN)); |
| 885 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 886 | I915_READ(VLV_DPFLIPSTAT)); |
| 887 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 888 | I915_READ(DPINVGTT)); |
| 889 | |
| 890 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 891 | seq_printf(m, "Interrupt enable: %08x\n", |
| 892 | I915_READ(IER)); |
| 893 | seq_printf(m, "Interrupt identity: %08x\n", |
| 894 | I915_READ(IIR)); |
| 895 | seq_printf(m, "Interrupt mask: %08x\n", |
| 896 | I915_READ(IMR)); |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 897 | for_each_pipe(dev_priv, pipe) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 898 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 899 | pipe_name(pipe), |
| 900 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 901 | } else { |
| 902 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 903 | I915_READ(DEIER)); |
| 904 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 905 | I915_READ(DEIIR)); |
| 906 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 907 | I915_READ(DEIMR)); |
| 908 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 909 | I915_READ(SDEIER)); |
| 910 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 911 | I915_READ(SDEIIR)); |
| 912 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 913 | I915_READ(SDEIMR)); |
| 914 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 915 | I915_READ(GTIER)); |
| 916 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 917 | I915_READ(GTIIR)); |
| 918 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 919 | I915_READ(GTIMR)); |
| 920 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 921 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 922 | if (INTEL_INFO(dev)->gen >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 923 | seq_printf(m, |
| 924 | "Graphics Interrupt mask (%s): %08x\n", |
| 925 | ring->name, I915_READ_IMR(ring)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 926 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 927 | i915_ring_seqno_info(m, ring); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 928 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 929 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 930 | mutex_unlock(&dev->struct_mutex); |
| 931 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 932 | return 0; |
| 933 | } |
| 934 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 935 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 936 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 937 | struct drm_info_node *node = m->private; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 938 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 939 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 940 | int i, ret; |
| 941 | |
| 942 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 943 | if (ret) |
| 944 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 945 | |
| 946 | seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start); |
| 947 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 948 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 949 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 950 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 951 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 952 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 953 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 954 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 955 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 956 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 957 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 958 | } |
| 959 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 960 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 961 | return 0; |
| 962 | } |
| 963 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 964 | static int i915_hws_info(struct seq_file *m, void *data) |
| 965 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 966 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 967 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 968 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 969 | struct intel_engine_cs *ring; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 970 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 971 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 972 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 973 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 974 | hws = ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 975 | if (hws == NULL) |
| 976 | return 0; |
| 977 | |
| 978 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 979 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 980 | i * 4, |
| 981 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 982 | } |
| 983 | return 0; |
| 984 | } |
| 985 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 986 | static ssize_t |
| 987 | i915_error_state_write(struct file *filp, |
| 988 | const char __user *ubuf, |
| 989 | size_t cnt, |
| 990 | loff_t *ppos) |
| 991 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 992 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 993 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 994 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 995 | |
| 996 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 997 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 998 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 999 | if (ret) |
| 1000 | return ret; |
| 1001 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1002 | i915_destroy_error_state(dev); |
| 1003 | mutex_unlock(&dev->struct_mutex); |
| 1004 | |
| 1005 | return cnt; |
| 1006 | } |
| 1007 | |
| 1008 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 1009 | { |
| 1010 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1011 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1012 | |
| 1013 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 1014 | if (!error_priv) |
| 1015 | return -ENOMEM; |
| 1016 | |
| 1017 | error_priv->dev = dev; |
| 1018 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1019 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1020 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1021 | file->private_data = error_priv; |
| 1022 | |
| 1023 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 1027 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1028 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1029 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 1030 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1031 | kfree(error_priv); |
| 1032 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1033 | return 0; |
| 1034 | } |
| 1035 | |
| 1036 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 1037 | size_t count, loff_t *pos) |
| 1038 | { |
| 1039 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 1040 | struct drm_i915_error_state_buf error_str; |
| 1041 | loff_t tmp_pos = 0; |
| 1042 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1043 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1044 | |
Chris Wilson | 0a4cd7c | 2014-08-22 14:41:39 +0100 | [diff] [blame] | 1045 | 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] | 1046 | if (ret) |
| 1047 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1048 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 1049 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1050 | if (ret) |
| 1051 | goto out; |
| 1052 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1053 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 1054 | error_str.buf, |
| 1055 | error_str.bytes); |
| 1056 | |
| 1057 | if (ret_count < 0) |
| 1058 | ret = ret_count; |
| 1059 | else |
| 1060 | *pos = error_str.start + ret_count; |
| 1061 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 1062 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1063 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1064 | } |
| 1065 | |
| 1066 | static const struct file_operations i915_error_state_fops = { |
| 1067 | .owner = THIS_MODULE, |
| 1068 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 1069 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 1070 | .write = i915_error_state_write, |
| 1071 | .llseek = default_llseek, |
| 1072 | .release = i915_error_state_release, |
| 1073 | }; |
| 1074 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1075 | static int |
| 1076 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1077 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1078 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1079 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1080 | int ret; |
| 1081 | |
| 1082 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1083 | if (ret) |
| 1084 | return ret; |
| 1085 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1086 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1087 | mutex_unlock(&dev->struct_mutex); |
| 1088 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1089 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1090 | } |
| 1091 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1092 | static int |
| 1093 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1094 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1095 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1096 | int ret; |
| 1097 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1098 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1099 | if (ret) |
| 1100 | return ret; |
| 1101 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 1102 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1103 | mutex_unlock(&dev->struct_mutex); |
| 1104 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1105 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1106 | } |
| 1107 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1108 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1109 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1110 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1111 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1112 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1113 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1114 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1115 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1116 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1117 | int ret = 0; |
| 1118 | |
| 1119 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1120 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1121 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1122 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1123 | if (IS_GEN5(dev)) { |
| 1124 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1125 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1126 | |
| 1127 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1128 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1129 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1130 | MEMSTAT_VID_SHIFT); |
| 1131 | seq_printf(m, "Current P-state: %d\n", |
| 1132 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1133 | } else if (IS_GEN6(dev) || (IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) || |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1134 | IS_BROADWELL(dev) || IS_GEN9(dev)) { |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame^] | 1135 | u32 rp_state_limits; |
| 1136 | u32 gt_perf_status; |
| 1137 | u32 rp_state_cap; |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1138 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1139 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1140 | u32 rpupei, rpcurup, rpprevup; |
| 1141 | u32 rpdownei, rpcurdown, rpprevdown; |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1142 | u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1143 | int max_freq; |
| 1144 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame^] | 1145 | rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 1146 | if (IS_BROXTON(dev)) { |
| 1147 | rp_state_cap = I915_READ(BXT_RP_STATE_CAP); |
| 1148 | gt_perf_status = I915_READ(BXT_GT_PERF_STATUS); |
| 1149 | } else { |
| 1150 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
| 1151 | gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1152 | } |
| 1153 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1154 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1155 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1156 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1157 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1158 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1159 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1160 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1161 | reqf = I915_READ(GEN6_RPNSWREQ); |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1162 | if (IS_GEN9(dev)) |
| 1163 | reqf >>= 23; |
| 1164 | else { |
| 1165 | reqf &= ~GEN6_TURBO_DISABLE; |
| 1166 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
| 1167 | reqf >>= 24; |
| 1168 | else |
| 1169 | reqf >>= 25; |
| 1170 | } |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1171 | reqf = intel_gpu_freq(dev_priv, reqf); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1172 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1173 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1174 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1175 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1176 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1177 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 1178 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 1179 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 1180 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 1181 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 1182 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 1183 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1184 | if (IS_GEN9(dev)) |
| 1185 | cagf = (rpstat & GEN9_CAGF_MASK) >> GEN9_CAGF_SHIFT; |
| 1186 | else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1187 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1188 | else |
| 1189 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1190 | cagf = intel_gpu_freq(dev_priv, cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1191 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 1192 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1193 | mutex_unlock(&dev->struct_mutex); |
| 1194 | |
Paulo Zanoni | 9dd3c60 | 2014-08-01 18:14:48 -0300 | [diff] [blame] | 1195 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1196 | pm_ier = I915_READ(GEN6_PMIER); |
| 1197 | pm_imr = I915_READ(GEN6_PMIMR); |
| 1198 | pm_isr = I915_READ(GEN6_PMISR); |
| 1199 | pm_iir = I915_READ(GEN6_PMIIR); |
| 1200 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1201 | } else { |
| 1202 | pm_ier = I915_READ(GEN8_GT_IER(2)); |
| 1203 | pm_imr = I915_READ(GEN8_GT_IMR(2)); |
| 1204 | pm_isr = I915_READ(GEN8_GT_ISR(2)); |
| 1205 | pm_iir = I915_READ(GEN8_GT_IIR(2)); |
| 1206 | pm_mask = I915_READ(GEN6_PMINTRMSK); |
| 1207 | } |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1208 | 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] | 1209 | pm_ier, pm_imr, pm_isr, pm_iir, pm_mask); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1210 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1211 | seq_printf(m, "Render p-state ratio: %d\n", |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1212 | (gt_perf_status & (IS_GEN9(dev) ? 0x1ff00 : 0xff00)) >> 8); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1213 | seq_printf(m, "Render p-state VID: %d\n", |
| 1214 | gt_perf_status & 0xff); |
| 1215 | seq_printf(m, "Render p-state limit: %d\n", |
| 1216 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1217 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1218 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1219 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1220 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1221 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1222 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1223 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 1224 | GEN6_CURICONT_MASK); |
| 1225 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 1226 | GEN6_CURBSYTAVG_MASK); |
| 1227 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 1228 | GEN6_CURBSYTAVG_MASK); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1229 | seq_printf(m, "Up threshold: %d%%\n", |
| 1230 | dev_priv->rps.up_threshold); |
| 1231 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1232 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 1233 | GEN6_CURIAVG_MASK); |
| 1234 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 1235 | GEN6_CURBSYTAVG_MASK); |
| 1236 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 1237 | GEN6_CURBSYTAVG_MASK); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1238 | seq_printf(m, "Down threshold: %d%%\n", |
| 1239 | dev_priv->rps.down_threshold); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1240 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame^] | 1241 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 0 : |
| 1242 | rp_state_cap >> 16) & 0xff; |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1243 | max_freq *= (IS_SKYLAKE(dev) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1244 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1245 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1246 | |
| 1247 | max_freq = (rp_state_cap & 0xff00) >> 8; |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1248 | max_freq *= (IS_SKYLAKE(dev) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1249 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1250 | intel_gpu_freq(dev_priv, max_freq)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1251 | |
Bob Paauwe | 3504056 | 2015-06-25 14:54:07 -0700 | [diff] [blame^] | 1252 | max_freq = (IS_BROXTON(dev) ? rp_state_cap >> 16 : |
| 1253 | rp_state_cap >> 0) & 0xff; |
Akash Goel | 60260a5 | 2015-03-06 11:07:21 +0530 | [diff] [blame] | 1254 | max_freq *= (IS_SKYLAKE(dev) ? GEN9_FREQ_SCALER : 1); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1255 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1256 | intel_gpu_freq(dev_priv, max_freq)); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1257 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1258 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1259 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1260 | seq_printf(m, "Current freq: %d MHz\n", |
| 1261 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1262 | seq_printf(m, "Actual freq: %d MHz\n", cagf); |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1263 | seq_printf(m, "Idle freq: %d MHz\n", |
| 1264 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1265 | seq_printf(m, "Min freq: %d MHz\n", |
| 1266 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
| 1267 | seq_printf(m, "Max freq: %d MHz\n", |
| 1268 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
| 1269 | seq_printf(m, |
| 1270 | "efficient (RPe) frequency: %d MHz\n", |
| 1271 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1272 | } else if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1273 | u32 freq_sts; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1274 | |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1275 | mutex_lock(&dev_priv->rps.hw_lock); |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 1276 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1277 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1278 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1279 | |
Chris Wilson | d86ed34 | 2015-04-27 13:41:19 +0100 | [diff] [blame] | 1280 | seq_printf(m, "actual GPU freq: %d MHz\n", |
| 1281 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
| 1282 | |
| 1283 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 1284 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq)); |
| 1285 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1286 | seq_printf(m, "max GPU freq: %d MHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1287 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1288 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1289 | seq_printf(m, "min GPU freq: %d MHz\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1290 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1291 | |
Chris Wilson | aed242f | 2015-03-18 09:48:21 +0000 | [diff] [blame] | 1292 | seq_printf(m, "idle GPU freq: %d MHz\n", |
| 1293 | intel_gpu_freq(dev_priv, dev_priv->rps.idle_freq)); |
| 1294 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1295 | seq_printf(m, |
| 1296 | "efficient (RPe) frequency: %d MHz\n", |
| 1297 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1298 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1299 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1300 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1301 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1302 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1303 | out: |
| 1304 | intel_runtime_pm_put(dev_priv); |
| 1305 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1306 | } |
| 1307 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1308 | static int i915_hangcheck_info(struct seq_file *m, void *unused) |
| 1309 | { |
| 1310 | struct drm_info_node *node = m->private; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1311 | struct drm_device *dev = node->minor->dev; |
| 1312 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1313 | struct intel_engine_cs *ring; |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1314 | u64 acthd[I915_NUM_RINGS]; |
| 1315 | u32 seqno[I915_NUM_RINGS]; |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1316 | int i; |
| 1317 | |
| 1318 | if (!i915.enable_hangcheck) { |
| 1319 | seq_printf(m, "Hangcheck disabled\n"); |
| 1320 | return 0; |
| 1321 | } |
| 1322 | |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1323 | intel_runtime_pm_get(dev_priv); |
| 1324 | |
| 1325 | for_each_ring(ring, dev_priv, i) { |
| 1326 | seqno[i] = ring->get_seqno(ring, false); |
| 1327 | acthd[i] = intel_ring_get_active_head(ring); |
| 1328 | } |
| 1329 | |
| 1330 | intel_runtime_pm_put(dev_priv); |
| 1331 | |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1332 | if (delayed_work_pending(&dev_priv->gpu_error.hangcheck_work)) { |
| 1333 | seq_printf(m, "Hangcheck active, fires in %dms\n", |
| 1334 | jiffies_to_msecs(dev_priv->gpu_error.hangcheck_work.timer.expires - |
| 1335 | jiffies)); |
| 1336 | } else |
| 1337 | seq_printf(m, "Hangcheck inactive\n"); |
| 1338 | |
| 1339 | for_each_ring(ring, dev_priv, i) { |
| 1340 | seq_printf(m, "%s:\n", ring->name); |
| 1341 | seq_printf(m, "\tseqno = %x [current %x]\n", |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1342 | ring->hangcheck.seqno, seqno[i]); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1343 | seq_printf(m, "\tACTHD = 0x%08llx [current 0x%08llx]\n", |
| 1344 | (long long)ring->hangcheck.acthd, |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1345 | (long long)acthd[i]); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1346 | seq_printf(m, "\tmax ACTHD = 0x%08llx\n", |
| 1347 | (long long)ring->hangcheck.max_acthd); |
Mika Kuoppala | ebbc754 | 2015-02-05 18:41:48 +0200 | [diff] [blame] | 1348 | seq_printf(m, "\tscore = %d\n", ring->hangcheck.score); |
| 1349 | seq_printf(m, "\taction = %d\n", ring->hangcheck.action); |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | return 0; |
| 1353 | } |
| 1354 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1355 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1356 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1357 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1358 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1359 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1360 | u32 rgvmodectl, rstdbyctl; |
| 1361 | u16 crstandvid; |
| 1362 | int ret; |
| 1363 | |
| 1364 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1365 | if (ret) |
| 1366 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1367 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1368 | |
| 1369 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1370 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1371 | crstandvid = I915_READ16(CRSTANDVID); |
| 1372 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1373 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1374 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1375 | |
| 1376 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1377 | "yes" : "no"); |
| 1378 | seq_printf(m, "Boost freq: %d\n", |
| 1379 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1380 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1381 | seq_printf(m, "HW control enabled: %s\n", |
| 1382 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1383 | seq_printf(m, "SW control enabled: %s\n", |
| 1384 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1385 | seq_printf(m, "Gated voltage change: %s\n", |
| 1386 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1387 | seq_printf(m, "Starting frequency: P%d\n", |
| 1388 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1389 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1390 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1391 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1392 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1393 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1394 | seq_printf(m, "Render standby enabled: %s\n", |
| 1395 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1396 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1397 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1398 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1399 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1400 | break; |
| 1401 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1402 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1403 | break; |
| 1404 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1405 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1406 | break; |
| 1407 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1408 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1409 | break; |
| 1410 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1411 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1412 | break; |
| 1413 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1414 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1415 | break; |
| 1416 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1417 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1418 | break; |
| 1419 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1420 | |
| 1421 | return 0; |
| 1422 | } |
| 1423 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1424 | static int i915_forcewake_domains(struct seq_file *m, void *data) |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1425 | { |
| 1426 | struct drm_info_node *node = m->private; |
| 1427 | struct drm_device *dev = node->minor->dev; |
| 1428 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1429 | struct intel_uncore_forcewake_domain *fw_domain; |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1430 | int i; |
| 1431 | |
| 1432 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1433 | for_each_fw_domain(fw_domain, dev_priv, i) { |
| 1434 | seq_printf(m, "%s.wake_count = %u\n", |
Mika Kuoppala | 05a2fb1 | 2015-01-19 16:20:43 +0200 | [diff] [blame] | 1435 | intel_uncore_forcewake_domain_to_str(i), |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1436 | fw_domain->wake_count); |
| 1437 | } |
| 1438 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1439 | |
| 1440 | return 0; |
| 1441 | } |
| 1442 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1443 | static int vlv_drpc_info(struct seq_file *m) |
| 1444 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1445 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1446 | struct drm_device *dev = node->minor->dev; |
| 1447 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1448 | u32 rpmodectl1, rcctl1, pw_status; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1449 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1450 | intel_runtime_pm_get(dev_priv); |
| 1451 | |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1452 | pw_status = I915_READ(VLV_GTLC_PW_STATUS); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1453 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1454 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1455 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1456 | intel_runtime_pm_put(dev_priv); |
| 1457 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1458 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1459 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1460 | seq_printf(m, "Turbo enabled: %s\n", |
| 1461 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1462 | seq_printf(m, "HW control enabled: %s\n", |
| 1463 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1464 | seq_printf(m, "SW control enabled: %s\n", |
| 1465 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1466 | GEN6_RP_MEDIA_SW_MODE)); |
| 1467 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1468 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1469 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1470 | seq_printf(m, "Render Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1471 | (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1472 | seq_printf(m, "Media Power Well: %s\n", |
Ville Syrjälä | 6b312cd | 2014-11-19 20:07:42 +0200 | [diff] [blame] | 1473 | (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1474 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1475 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1476 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1477 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1478 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1479 | |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 1480 | return i915_forcewake_domains(m, NULL); |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1481 | } |
| 1482 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1483 | static int gen6_drpc_info(struct seq_file *m) |
| 1484 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1485 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1486 | struct drm_device *dev = node->minor->dev; |
| 1487 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1488 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1489 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1490 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1491 | |
| 1492 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1493 | if (ret) |
| 1494 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1495 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1496 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1497 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | b2cff0d | 2015-01-16 11:34:37 +0200 | [diff] [blame] | 1498 | 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] | 1499 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1500 | |
| 1501 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1502 | seq_puts(m, "RC information inaccurate because somebody " |
| 1503 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1504 | } else { |
| 1505 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1506 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1507 | udelay(10); |
| 1508 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1509 | } |
| 1510 | |
| 1511 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1512 | 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] | 1513 | |
| 1514 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1515 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1516 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1517 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1518 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1519 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1520 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1521 | intel_runtime_pm_put(dev_priv); |
| 1522 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1523 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1524 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1525 | seq_printf(m, "HW control enabled: %s\n", |
| 1526 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1527 | seq_printf(m, "SW control enabled: %s\n", |
| 1528 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1529 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1530 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1531 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1532 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1533 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1534 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1535 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1536 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1537 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1538 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1539 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1540 | case GEN6_RC0: |
| 1541 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1542 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1543 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1544 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1545 | break; |
| 1546 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1547 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1548 | break; |
| 1549 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1550 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1551 | break; |
| 1552 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1553 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1554 | break; |
| 1555 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1556 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1557 | break; |
| 1558 | } |
| 1559 | |
| 1560 | seq_printf(m, "Core Power Down: %s\n", |
| 1561 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1562 | |
| 1563 | /* Not exactly sure what this is */ |
| 1564 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1565 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1566 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1567 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1568 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1569 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1570 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1571 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1572 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1573 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1574 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1575 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1576 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1577 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1578 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1579 | return 0; |
| 1580 | } |
| 1581 | |
| 1582 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1583 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1584 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1585 | struct drm_device *dev = node->minor->dev; |
| 1586 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1587 | if (IS_VALLEYVIEW(dev)) |
| 1588 | return vlv_drpc_info(m); |
Vedang Patel | ac66cf4 | 2014-08-26 10:42:51 -0700 | [diff] [blame] | 1589 | else if (INTEL_INFO(dev)->gen >= 6) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1590 | return gen6_drpc_info(m); |
| 1591 | else |
| 1592 | return ironlake_drpc_info(m); |
| 1593 | } |
| 1594 | |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 1595 | static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) |
| 1596 | { |
| 1597 | struct drm_info_node *node = m->private; |
| 1598 | struct drm_device *dev = node->minor->dev; |
| 1599 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1600 | |
| 1601 | seq_printf(m, "FB tracking busy bits: 0x%08x\n", |
| 1602 | dev_priv->fb_tracking.busy_bits); |
| 1603 | |
| 1604 | seq_printf(m, "FB tracking flip bits: 0x%08x\n", |
| 1605 | dev_priv->fb_tracking.flip_bits); |
| 1606 | |
| 1607 | return 0; |
| 1608 | } |
| 1609 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1610 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1611 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1612 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1613 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1614 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1615 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1616 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1617 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1618 | return 0; |
| 1619 | } |
| 1620 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1621 | intel_runtime_pm_get(dev_priv); |
| 1622 | |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1623 | if (intel_fbc_enabled(dev)) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1624 | seq_puts(m, "FBC enabled\n"); |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 1625 | else |
| 1626 | seq_printf(m, "FBC disabled: %s\n", |
| 1627 | intel_no_fbc_reason_str(dev_priv->fbc.no_fbc_reason)); |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1628 | |
Paulo Zanoni | 31b9df1 | 2015-06-12 14:36:18 -0300 | [diff] [blame] | 1629 | if (INTEL_INFO(dev_priv)->gen >= 7) |
| 1630 | seq_printf(m, "Compressing: %s\n", |
| 1631 | yesno(I915_READ(FBC_STATUS2) & |
| 1632 | FBC_COMPRESSION_MASK)); |
| 1633 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1634 | intel_runtime_pm_put(dev_priv); |
| 1635 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1636 | return 0; |
| 1637 | } |
| 1638 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1639 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1640 | { |
| 1641 | struct drm_device *dev = data; |
| 1642 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1643 | |
| 1644 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1645 | return -ENODEV; |
| 1646 | |
| 1647 | drm_modeset_lock_all(dev); |
| 1648 | *val = dev_priv->fbc.false_color; |
| 1649 | drm_modeset_unlock_all(dev); |
| 1650 | |
| 1651 | return 0; |
| 1652 | } |
| 1653 | |
| 1654 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1655 | { |
| 1656 | struct drm_device *dev = data; |
| 1657 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1658 | u32 reg; |
| 1659 | |
| 1660 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1661 | return -ENODEV; |
| 1662 | |
| 1663 | drm_modeset_lock_all(dev); |
| 1664 | |
| 1665 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1666 | dev_priv->fbc.false_color = val; |
| 1667 | |
| 1668 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1669 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1670 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1671 | |
| 1672 | drm_modeset_unlock_all(dev); |
| 1673 | return 0; |
| 1674 | } |
| 1675 | |
| 1676 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1677 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1678 | "%llu\n"); |
| 1679 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1680 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1681 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1682 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1683 | struct drm_device *dev = node->minor->dev; |
| 1684 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1685 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1686 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1687 | seq_puts(m, "not supported\n"); |
| 1688 | return 0; |
| 1689 | } |
| 1690 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1691 | intel_runtime_pm_get(dev_priv); |
| 1692 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1693 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1694 | yesno(i915.enable_ips)); |
| 1695 | |
| 1696 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1697 | seq_puts(m, "Currently: unknown\n"); |
| 1698 | } else { |
| 1699 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1700 | seq_puts(m, "Currently: enabled\n"); |
| 1701 | else |
| 1702 | seq_puts(m, "Currently: disabled\n"); |
| 1703 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1704 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1705 | intel_runtime_pm_put(dev_priv); |
| 1706 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1707 | return 0; |
| 1708 | } |
| 1709 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1710 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1711 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1712 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1713 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1714 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1715 | bool sr_enabled = false; |
| 1716 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1717 | intel_runtime_pm_get(dev_priv); |
| 1718 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1719 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1720 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1721 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1722 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1723 | else if (IS_I915GM(dev)) |
| 1724 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1725 | else if (IS_PINEVIEW(dev)) |
| 1726 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1727 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1728 | intel_runtime_pm_put(dev_priv); |
| 1729 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1730 | seq_printf(m, "self-refresh: %s\n", |
| 1731 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1732 | |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1736 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1737 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1738 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1739 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1740 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1741 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1742 | int ret; |
| 1743 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1744 | if (!IS_GEN5(dev)) |
| 1745 | return -ENODEV; |
| 1746 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1747 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1748 | if (ret) |
| 1749 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1750 | |
| 1751 | temp = i915_mch_val(dev_priv); |
| 1752 | chipset = i915_chipset_val(dev_priv); |
| 1753 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1754 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1755 | |
| 1756 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1757 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1758 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1759 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1760 | |
| 1761 | return 0; |
| 1762 | } |
| 1763 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1764 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1765 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1766 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1767 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1768 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1769 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1770 | int gpu_freq, ia_freq; |
| 1771 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1772 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1773 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1774 | return 0; |
| 1775 | } |
| 1776 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1777 | intel_runtime_pm_get(dev_priv); |
| 1778 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1779 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1780 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1781 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1782 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1783 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1784 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1785 | 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] | 1786 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1787 | for (gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1788 | gpu_freq <= dev_priv->rps.max_freq_softlimit; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1789 | gpu_freq++) { |
Ben Widawsky | 42c0526 | 2012-09-26 10:34:00 -0700 | [diff] [blame] | 1790 | ia_freq = gpu_freq; |
| 1791 | sandybridge_pcode_read(dev_priv, |
| 1792 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1793 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1794 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 1795 | intel_gpu_freq(dev_priv, gpu_freq), |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1796 | ((ia_freq >> 0) & 0xff) * 100, |
| 1797 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1798 | } |
| 1799 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1800 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1801 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1802 | out: |
| 1803 | intel_runtime_pm_put(dev_priv); |
| 1804 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1805 | } |
| 1806 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1807 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1808 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1809 | struct drm_info_node *node = m->private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1810 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1811 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1812 | struct intel_opregion *opregion = &dev_priv->opregion; |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1813 | void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1814 | int ret; |
| 1815 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1816 | if (data == NULL) |
| 1817 | return -ENOMEM; |
| 1818 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1819 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1820 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1821 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1822 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1823 | if (opregion->header) { |
| 1824 | memcpy_fromio(data, opregion->header, OPREGION_SIZE); |
| 1825 | seq_write(m, data, OPREGION_SIZE); |
| 1826 | } |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1827 | |
| 1828 | mutex_unlock(&dev->struct_mutex); |
| 1829 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1830 | out: |
| 1831 | kfree(data); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1832 | return 0; |
| 1833 | } |
| 1834 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1835 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1836 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1837 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1838 | struct drm_device *dev = node->minor->dev; |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1839 | struct intel_fbdev *ifbdev = NULL; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1840 | struct intel_framebuffer *fb; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1841 | |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1842 | #ifdef CONFIG_DRM_I915_FBDEV |
| 1843 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1844 | |
| 1845 | ifbdev = dev_priv->fbdev; |
| 1846 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1847 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1848 | seq_printf(m, "fbcon 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] | 1849 | fb->base.width, |
| 1850 | fb->base.height, |
| 1851 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1852 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1853 | fb->base.modifier[0], |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1854 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1855 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1856 | seq_putc(m, '\n'); |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1857 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1858 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1859 | mutex_lock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1860 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
Daniel Vetter | 131a56d | 2013-10-17 14:35:31 +0200 | [diff] [blame] | 1861 | if (ifbdev && &fb->base == ifbdev->helper.fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1862 | continue; |
| 1863 | |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1864 | 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] | 1865 | fb->base.width, |
| 1866 | fb->base.height, |
| 1867 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1868 | fb->base.bits_per_pixel, |
Tvrtko Ursulin | c1ca506d | 2015-02-10 17:16:07 +0000 | [diff] [blame] | 1869 | fb->base.modifier[0], |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1870 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1871 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1872 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1873 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1874 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1875 | |
| 1876 | return 0; |
| 1877 | } |
| 1878 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1879 | static void describe_ctx_ringbuf(struct seq_file *m, |
| 1880 | struct intel_ringbuffer *ringbuf) |
| 1881 | { |
| 1882 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
| 1883 | ringbuf->space, ringbuf->head, ringbuf->tail, |
| 1884 | ringbuf->last_retired_head); |
| 1885 | } |
| 1886 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1887 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1888 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1889 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1890 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1891 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1892 | struct intel_engine_cs *ring; |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1893 | struct intel_context *ctx; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1894 | int ret, i; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1895 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1896 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1897 | if (ret) |
| 1898 | return ret; |
| 1899 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1900 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1901 | if (!i915.enable_execlists && |
| 1902 | ctx->legacy_hw_ctx.rcs_state == NULL) |
Chris Wilson | b77f699 | 2014-04-30 08:30:00 +0100 | [diff] [blame] | 1903 | continue; |
| 1904 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1905 | seq_puts(m, "HW context "); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 1906 | describe_ctx(m, ctx); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1907 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1908 | if (ring->default_context == ctx) |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1909 | seq_printf(m, "(default context %s) ", |
| 1910 | ring->name); |
| 1911 | } |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1912 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1913 | if (i915.enable_execlists) { |
| 1914 | seq_putc(m, '\n'); |
| 1915 | for_each_ring(ring, dev_priv, i) { |
| 1916 | struct drm_i915_gem_object *ctx_obj = |
| 1917 | ctx->engine[i].state; |
| 1918 | struct intel_ringbuffer *ringbuf = |
| 1919 | ctx->engine[i].ringbuf; |
| 1920 | |
| 1921 | seq_printf(m, "%s: ", ring->name); |
| 1922 | if (ctx_obj) |
| 1923 | describe_obj(m, ctx_obj); |
| 1924 | if (ringbuf) |
| 1925 | describe_ctx_ringbuf(m, ringbuf); |
| 1926 | seq_putc(m, '\n'); |
| 1927 | } |
| 1928 | } else { |
| 1929 | describe_obj(m, ctx->legacy_hw_ctx.rcs_state); |
| 1930 | } |
| 1931 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1932 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1933 | } |
| 1934 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1935 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1936 | |
| 1937 | return 0; |
| 1938 | } |
| 1939 | |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 1940 | static void i915_dump_lrc_obj(struct seq_file *m, |
| 1941 | struct intel_engine_cs *ring, |
| 1942 | struct drm_i915_gem_object *ctx_obj) |
| 1943 | { |
| 1944 | struct page *page; |
| 1945 | uint32_t *reg_state; |
| 1946 | int j; |
| 1947 | unsigned long ggtt_offset = 0; |
| 1948 | |
| 1949 | if (ctx_obj == NULL) { |
| 1950 | seq_printf(m, "Context on %s with no gem object\n", |
| 1951 | ring->name); |
| 1952 | return; |
| 1953 | } |
| 1954 | |
| 1955 | seq_printf(m, "CONTEXT: %s %u\n", ring->name, |
| 1956 | intel_execlists_ctx_id(ctx_obj)); |
| 1957 | |
| 1958 | if (!i915_gem_obj_ggtt_bound(ctx_obj)) |
| 1959 | seq_puts(m, "\tNot bound in GGTT\n"); |
| 1960 | else |
| 1961 | ggtt_offset = i915_gem_obj_ggtt_offset(ctx_obj); |
| 1962 | |
| 1963 | if (i915_gem_object_get_pages(ctx_obj)) { |
| 1964 | seq_puts(m, "\tFailed to get pages for context object\n"); |
| 1965 | return; |
| 1966 | } |
| 1967 | |
| 1968 | page = i915_gem_object_get_page(ctx_obj, 1); |
| 1969 | if (!WARN_ON(page == NULL)) { |
| 1970 | reg_state = kmap_atomic(page); |
| 1971 | |
| 1972 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 1973 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1974 | ggtt_offset + 4096 + (j * 4), |
| 1975 | reg_state[j], reg_state[j + 1], |
| 1976 | reg_state[j + 2], reg_state[j + 3]); |
| 1977 | } |
| 1978 | kunmap_atomic(reg_state); |
| 1979 | } |
| 1980 | |
| 1981 | seq_putc(m, '\n'); |
| 1982 | } |
| 1983 | |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 1984 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 1985 | { |
| 1986 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1987 | struct drm_device *dev = node->minor->dev; |
| 1988 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1989 | struct intel_engine_cs *ring; |
| 1990 | struct intel_context *ctx; |
| 1991 | int ret, i; |
| 1992 | |
| 1993 | if (!i915.enable_execlists) { |
| 1994 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
| 1998 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1999 | if (ret) |
| 2000 | return ret; |
| 2001 | |
| 2002 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
| 2003 | for_each_ring(ring, dev_priv, i) { |
Thomas Daniel | 064ca1d | 2014-12-02 13:21:18 +0000 | [diff] [blame] | 2004 | if (ring->default_context != ctx) |
| 2005 | i915_dump_lrc_obj(m, ring, |
| 2006 | ctx->engine[i].state); |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 2007 | } |
| 2008 | } |
| 2009 | |
| 2010 | mutex_unlock(&dev->struct_mutex); |
| 2011 | |
| 2012 | return 0; |
| 2013 | } |
| 2014 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2015 | static int i915_execlists(struct seq_file *m, void *data) |
| 2016 | { |
| 2017 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 2018 | struct drm_device *dev = node->minor->dev; |
| 2019 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2020 | struct intel_engine_cs *ring; |
| 2021 | u32 status_pointer; |
| 2022 | u8 read_pointer; |
| 2023 | u8 write_pointer; |
| 2024 | u32 status; |
| 2025 | u32 ctx_id; |
| 2026 | struct list_head *cursor; |
| 2027 | int ring_id, i; |
| 2028 | int ret; |
| 2029 | |
| 2030 | if (!i915.enable_execlists) { |
| 2031 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 2032 | return 0; |
| 2033 | } |
| 2034 | |
| 2035 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2036 | if (ret) |
| 2037 | return ret; |
| 2038 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2039 | intel_runtime_pm_get(dev_priv); |
| 2040 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2041 | for_each_ring(ring, dev_priv, ring_id) { |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2042 | struct drm_i915_gem_request *head_req = NULL; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2043 | int count = 0; |
| 2044 | unsigned long flags; |
| 2045 | |
| 2046 | seq_printf(m, "%s\n", ring->name); |
| 2047 | |
| 2048 | status = I915_READ(RING_EXECLIST_STATUS(ring)); |
| 2049 | ctx_id = I915_READ(RING_EXECLIST_STATUS(ring) + 4); |
| 2050 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 2051 | status, ctx_id); |
| 2052 | |
| 2053 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring)); |
| 2054 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 2055 | |
| 2056 | read_pointer = ring->next_context_status_buffer; |
| 2057 | write_pointer = status_pointer & 0x07; |
| 2058 | if (read_pointer > write_pointer) |
| 2059 | write_pointer += 6; |
| 2060 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 2061 | read_pointer, write_pointer); |
| 2062 | |
| 2063 | for (i = 0; i < 6; i++) { |
| 2064 | status = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i); |
| 2065 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i + 4); |
| 2066 | |
| 2067 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 2068 | i, status, ctx_id); |
| 2069 | } |
| 2070 | |
| 2071 | spin_lock_irqsave(&ring->execlist_lock, flags); |
| 2072 | list_for_each(cursor, &ring->execlist_queue) |
| 2073 | count++; |
| 2074 | head_req = list_first_entry_or_null(&ring->execlist_queue, |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2075 | struct drm_i915_gem_request, execlist_link); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2076 | spin_unlock_irqrestore(&ring->execlist_lock, flags); |
| 2077 | |
| 2078 | seq_printf(m, "\t%d requests in queue\n", count); |
| 2079 | if (head_req) { |
| 2080 | struct drm_i915_gem_object *ctx_obj; |
| 2081 | |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2082 | ctx_obj = head_req->ctx->engine[ring_id].state; |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2083 | seq_printf(m, "\tHead request id: %u\n", |
| 2084 | intel_execlists_ctx_id(ctx_obj)); |
| 2085 | seq_printf(m, "\tHead request tail: %u\n", |
Nick Hoath | 6d3d827 | 2015-01-15 13:10:39 +0000 | [diff] [blame] | 2086 | head_req->tail); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | seq_putc(m, '\n'); |
| 2090 | } |
| 2091 | |
Michel Thierry | fc0412e | 2014-10-16 16:13:38 +0100 | [diff] [blame] | 2092 | intel_runtime_pm_put(dev_priv); |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 2093 | mutex_unlock(&dev->struct_mutex); |
| 2094 | |
| 2095 | return 0; |
| 2096 | } |
| 2097 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2098 | static const char *swizzle_string(unsigned swizzle) |
| 2099 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 2100 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2101 | case I915_BIT_6_SWIZZLE_NONE: |
| 2102 | return "none"; |
| 2103 | case I915_BIT_6_SWIZZLE_9: |
| 2104 | return "bit9"; |
| 2105 | case I915_BIT_6_SWIZZLE_9_10: |
| 2106 | return "bit9/bit10"; |
| 2107 | case I915_BIT_6_SWIZZLE_9_11: |
| 2108 | return "bit9/bit11"; |
| 2109 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 2110 | return "bit9/bit10/bit11"; |
| 2111 | case I915_BIT_6_SWIZZLE_9_17: |
| 2112 | return "bit9/bit17"; |
| 2113 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 2114 | return "bit9/bit10/bit17"; |
| 2115 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 2116 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2117 | } |
| 2118 | |
| 2119 | return "bug"; |
| 2120 | } |
| 2121 | |
| 2122 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 2123 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2124 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2125 | struct drm_device *dev = node->minor->dev; |
| 2126 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2127 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2128 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2129 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2130 | if (ret) |
| 2131 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2132 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2133 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2134 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 2135 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 2136 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 2137 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 2138 | |
| 2139 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 2140 | seq_printf(m, "DDC = 0x%08x\n", |
| 2141 | I915_READ(DCC)); |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2142 | seq_printf(m, "DDC2 = 0x%08x\n", |
| 2143 | I915_READ(DCC2)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2144 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 2145 | I915_READ16(C0DRB3)); |
| 2146 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 2147 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2148 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2149 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 2150 | I915_READ(MAD_DIMM_C0)); |
| 2151 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 2152 | I915_READ(MAD_DIMM_C1)); |
| 2153 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 2154 | I915_READ(MAD_DIMM_C2)); |
| 2155 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 2156 | I915_READ(TILECTL)); |
Robert Beckett | 5907f5f | 2014-01-23 14:23:14 +0000 | [diff] [blame] | 2157 | if (INTEL_INFO(dev)->gen >= 8) |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 2158 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 2159 | I915_READ(GAMTARBMODE)); |
| 2160 | else |
| 2161 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 2162 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 2163 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 2164 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2165 | } |
Daniel Vetter | 656bfa3 | 2014-11-20 09:26:30 +0100 | [diff] [blame] | 2166 | |
| 2167 | if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
| 2168 | seq_puts(m, "L-shaped memory detected\n"); |
| 2169 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2170 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2171 | mutex_unlock(&dev->struct_mutex); |
| 2172 | |
| 2173 | return 0; |
| 2174 | } |
| 2175 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2176 | static int per_file_ctx(int id, void *ptr, void *data) |
| 2177 | { |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 2178 | struct intel_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2179 | struct seq_file *m = data; |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2180 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 2181 | |
| 2182 | if (!ppgtt) { |
| 2183 | seq_printf(m, " no ppgtt for context %d\n", |
| 2184 | ctx->user_handle); |
| 2185 | return 0; |
| 2186 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2187 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 2188 | if (i915_gem_context_is_default(ctx)) |
| 2189 | seq_puts(m, " default context:\n"); |
| 2190 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 2191 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2192 | ppgtt->debug_dump(ppgtt, m); |
| 2193 | |
| 2194 | return 0; |
| 2195 | } |
| 2196 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2197 | 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] | 2198 | { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2199 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2200 | struct intel_engine_cs *ring; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2201 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2202 | int unused, i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2203 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2204 | if (!ppgtt) |
| 2205 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2206 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2207 | for_each_ring(ring, dev_priv, unused) { |
| 2208 | seq_printf(m, "%s\n", ring->name); |
| 2209 | for (i = 0; i < 4; i++) { |
| 2210 | u32 offset = 0x270 + i * 8; |
| 2211 | u64 pdp = I915_READ(ring->mmio_base + offset + 4); |
| 2212 | pdp <<= 32; |
| 2213 | pdp |= I915_READ(ring->mmio_base + offset); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2214 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2215 | } |
| 2216 | } |
| 2217 | } |
| 2218 | |
| 2219 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2220 | { |
| 2221 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2222 | struct intel_engine_cs *ring; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2223 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2224 | int i; |
| 2225 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2226 | if (INTEL_INFO(dev)->gen == 6) |
| 2227 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2228 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 2229 | for_each_ring(ring, dev_priv, i) { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2230 | seq_printf(m, "%s\n", ring->name); |
| 2231 | if (INTEL_INFO(dev)->gen == 7) |
| 2232 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 2233 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 2234 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 2235 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 2236 | } |
| 2237 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2238 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2239 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2240 | seq_puts(m, "aliasing PPGTT:\n"); |
Mika Kuoppala | 44159dd | 2015-06-25 18:35:07 +0300 | [diff] [blame] | 2241 | 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] | 2242 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2243 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c4806 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2244 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2245 | |
| 2246 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2247 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2248 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2249 | seq_printf(m, "proc: %s\n", |
| 2250 | get_pid_task(file->pid, PIDTYPE_PID)->comm); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2251 | idr_for_each(&file_priv->context_idr, per_file_ctx, m); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2252 | } |
| 2253 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2254 | } |
| 2255 | |
| 2256 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2257 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2258 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2259 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2260 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2261 | |
| 2262 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2263 | if (ret) |
| 2264 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2265 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2266 | |
| 2267 | if (INTEL_INFO(dev)->gen >= 8) |
| 2268 | gen8_ppgtt_info(m, dev); |
| 2269 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2270 | gen6_ppgtt_info(m, dev); |
| 2271 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2272 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2273 | mutex_unlock(&dev->struct_mutex); |
| 2274 | |
| 2275 | return 0; |
| 2276 | } |
| 2277 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2278 | static int count_irq_waiters(struct drm_i915_private *i915) |
| 2279 | { |
| 2280 | struct intel_engine_cs *ring; |
| 2281 | int count = 0; |
| 2282 | int i; |
| 2283 | |
| 2284 | for_each_ring(ring, i915, i) |
| 2285 | count += ring->irq_refcount; |
| 2286 | |
| 2287 | return count; |
| 2288 | } |
| 2289 | |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2290 | static int i915_rps_boost_info(struct seq_file *m, void *data) |
| 2291 | { |
| 2292 | struct drm_info_node *node = m->private; |
| 2293 | struct drm_device *dev = node->minor->dev; |
| 2294 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2295 | struct drm_file *file; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2296 | |
Chris Wilson | f5a4c67 | 2015-04-27 13:41:23 +0100 | [diff] [blame] | 2297 | seq_printf(m, "RPS enabled? %d\n", dev_priv->rps.enabled); |
| 2298 | seq_printf(m, "GPU busy? %d\n", dev_priv->mm.busy); |
| 2299 | seq_printf(m, "CPU waiting? %d\n", count_irq_waiters(dev_priv)); |
| 2300 | seq_printf(m, "Frequency requested %d; min hard:%d, soft:%d; max soft:%d, hard:%d\n", |
| 2301 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq), |
| 2302 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
| 2303 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), |
| 2304 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), |
| 2305 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2306 | spin_lock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2307 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2308 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 2309 | struct task_struct *task; |
| 2310 | |
| 2311 | rcu_read_lock(); |
| 2312 | task = pid_task(file->pid, PIDTYPE_PID); |
| 2313 | seq_printf(m, "%s [%d]: %d boosts%s\n", |
| 2314 | task ? task->comm : "<unknown>", |
| 2315 | task ? task->pid : -1, |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2316 | file_priv->rps.boosts, |
| 2317 | list_empty(&file_priv->rps.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2318 | rcu_read_unlock(); |
| 2319 | } |
Chris Wilson | 2e1b873 | 2015-04-27 13:41:22 +0100 | [diff] [blame] | 2320 | seq_printf(m, "Semaphore boosts: %d%s\n", |
| 2321 | dev_priv->rps.semaphores.boosts, |
| 2322 | list_empty(&dev_priv->rps.semaphores.link) ? "" : ", active"); |
| 2323 | seq_printf(m, "MMIO flip boosts: %d%s\n", |
| 2324 | dev_priv->rps.mmioflips.boosts, |
| 2325 | list_empty(&dev_priv->rps.mmioflips.link) ? "" : ", active"); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2326 | seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts); |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2327 | spin_unlock(&dev_priv->rps.client_lock); |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2328 | |
Chris Wilson | 8d3afd7 | 2015-05-21 21:01:47 +0100 | [diff] [blame] | 2329 | return 0; |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 2330 | } |
| 2331 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2332 | static int i915_llc(struct seq_file *m, void *data) |
| 2333 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2334 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2335 | struct drm_device *dev = node->minor->dev; |
| 2336 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2337 | |
| 2338 | /* Size calculation for LLC is a bit of a pain. Ignore for now. */ |
| 2339 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
| 2340 | seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size); |
| 2341 | |
| 2342 | return 0; |
| 2343 | } |
| 2344 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2345 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2346 | { |
| 2347 | struct drm_info_node *node = m->private; |
| 2348 | struct drm_device *dev = node->minor->dev; |
| 2349 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2350 | u32 psrperf = 0; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2351 | u32 stat[3]; |
| 2352 | enum pipe pipe; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2353 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2354 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2355 | if (!HAS_PSR(dev)) { |
| 2356 | seq_puts(m, "PSR not supported\n"); |
| 2357 | return 0; |
| 2358 | } |
| 2359 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2360 | intel_runtime_pm_get(dev_priv); |
| 2361 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2362 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2363 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2364 | 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] | 2365 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2366 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2367 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2368 | dev_priv->psr.busy_frontbuffer_bits); |
| 2369 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2370 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2371 | |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2372 | if (HAS_DDI(dev)) |
| 2373 | enabled = I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE; |
| 2374 | else { |
| 2375 | for_each_pipe(dev_priv, pipe) { |
| 2376 | stat[pipe] = I915_READ(VLV_PSRSTAT(pipe)) & |
| 2377 | VLV_EDP_PSR_CURR_STATE_MASK; |
| 2378 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2379 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2380 | enabled = true; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2381 | } |
| 2382 | } |
| 2383 | seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2384 | |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2385 | if (!HAS_DDI(dev)) |
| 2386 | for_each_pipe(dev_priv, pipe) { |
| 2387 | if ((stat[pipe] == VLV_EDP_PSR_ACTIVE_NORFB_UP) || |
| 2388 | (stat[pipe] == VLV_EDP_PSR_ACTIVE_SF_UPDATE)) |
| 2389 | seq_printf(m, " pipe %c", pipe_name(pipe)); |
| 2390 | } |
| 2391 | seq_puts(m, "\n"); |
| 2392 | |
| 2393 | /* CHV PSR has no kind of performance counter */ |
Damien Lespiau | 3553a8e | 2015-03-09 14:17:58 +0000 | [diff] [blame] | 2394 | if (HAS_DDI(dev)) { |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2395 | psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) & |
| 2396 | EDP_PSR_PERF_CNT_MASK; |
Rodrigo Vivi | a6cbdb8 | 2014-11-14 08:52:40 -0800 | [diff] [blame] | 2397 | |
| 2398 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
| 2399 | } |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2400 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2401 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2402 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2403 | return 0; |
| 2404 | } |
| 2405 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2406 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2407 | { |
| 2408 | struct drm_info_node *node = m->private; |
| 2409 | struct drm_device *dev = node->minor->dev; |
| 2410 | struct intel_encoder *encoder; |
| 2411 | struct intel_connector *connector; |
| 2412 | struct intel_dp *intel_dp = NULL; |
| 2413 | int ret; |
| 2414 | u8 crc[6]; |
| 2415 | |
| 2416 | drm_modeset_lock_all(dev); |
Rodrigo Vivi | aca5e36 | 2015-03-13 16:13:59 -0700 | [diff] [blame] | 2417 | for_each_intel_connector(dev, connector) { |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2418 | |
| 2419 | if (connector->base.dpms != DRM_MODE_DPMS_ON) |
| 2420 | continue; |
| 2421 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2422 | if (!connector->base.encoder) |
| 2423 | continue; |
| 2424 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2425 | encoder = to_intel_encoder(connector->base.encoder); |
| 2426 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 2427 | continue; |
| 2428 | |
| 2429 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 2430 | |
| 2431 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2432 | if (ret) |
| 2433 | goto out; |
| 2434 | |
| 2435 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2436 | crc[0], crc[1], crc[2], |
| 2437 | crc[3], crc[4], crc[5]); |
| 2438 | goto out; |
| 2439 | } |
| 2440 | ret = -ENODEV; |
| 2441 | out: |
| 2442 | drm_modeset_unlock_all(dev); |
| 2443 | return ret; |
| 2444 | } |
| 2445 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2446 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2447 | { |
| 2448 | struct drm_info_node *node = m->private; |
| 2449 | struct drm_device *dev = node->minor->dev; |
| 2450 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2451 | u64 power; |
| 2452 | u32 units; |
| 2453 | |
| 2454 | if (INTEL_INFO(dev)->gen < 6) |
| 2455 | return -ENODEV; |
| 2456 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2457 | intel_runtime_pm_get(dev_priv); |
| 2458 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2459 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2460 | power = (power & 0x1f00) >> 8; |
| 2461 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2462 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2463 | power *= units; |
| 2464 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2465 | intel_runtime_pm_put(dev_priv); |
| 2466 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2467 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2468 | |
| 2469 | return 0; |
| 2470 | } |
| 2471 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2472 | static int i915_runtime_pm_status(struct seq_file *m, void *unused) |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2473 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2474 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2475 | struct drm_device *dev = node->minor->dev; |
| 2476 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2477 | |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 2478 | if (!HAS_RUNTIME_PM(dev)) { |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2479 | seq_puts(m, "not supported\n"); |
| 2480 | return 0; |
| 2481 | } |
| 2482 | |
Paulo Zanoni | 86c4ec0 | 2014-02-21 13:52:24 -0300 | [diff] [blame] | 2483 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2484 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2485 | yesno(!intel_irqs_enabled(dev_priv))); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2486 | #ifdef CONFIG_PM |
Damien Lespiau | a6aaec8 | 2015-06-04 18:23:58 +0100 | [diff] [blame] | 2487 | seq_printf(m, "Usage count: %d\n", |
| 2488 | atomic_read(&dev->dev->power.usage_count)); |
Chris Wilson | 0d80418 | 2015-06-15 12:52:28 +0100 | [diff] [blame] | 2489 | #else |
| 2490 | seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n"); |
| 2491 | #endif |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2492 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2493 | return 0; |
| 2494 | } |
| 2495 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2496 | static const char *power_domain_str(enum intel_display_power_domain domain) |
| 2497 | { |
| 2498 | switch (domain) { |
| 2499 | case POWER_DOMAIN_PIPE_A: |
| 2500 | return "PIPE_A"; |
| 2501 | case POWER_DOMAIN_PIPE_B: |
| 2502 | return "PIPE_B"; |
| 2503 | case POWER_DOMAIN_PIPE_C: |
| 2504 | return "PIPE_C"; |
| 2505 | case POWER_DOMAIN_PIPE_A_PANEL_FITTER: |
| 2506 | return "PIPE_A_PANEL_FITTER"; |
| 2507 | case POWER_DOMAIN_PIPE_B_PANEL_FITTER: |
| 2508 | return "PIPE_B_PANEL_FITTER"; |
| 2509 | case POWER_DOMAIN_PIPE_C_PANEL_FITTER: |
| 2510 | return "PIPE_C_PANEL_FITTER"; |
| 2511 | case POWER_DOMAIN_TRANSCODER_A: |
| 2512 | return "TRANSCODER_A"; |
| 2513 | case POWER_DOMAIN_TRANSCODER_B: |
| 2514 | return "TRANSCODER_B"; |
| 2515 | case POWER_DOMAIN_TRANSCODER_C: |
| 2516 | return "TRANSCODER_C"; |
| 2517 | case POWER_DOMAIN_TRANSCODER_EDP: |
| 2518 | return "TRANSCODER_EDP"; |
Imre Deak | 319be8a | 2014-03-04 19:22:57 +0200 | [diff] [blame] | 2519 | case POWER_DOMAIN_PORT_DDI_A_2_LANES: |
| 2520 | return "PORT_DDI_A_2_LANES"; |
| 2521 | case POWER_DOMAIN_PORT_DDI_A_4_LANES: |
| 2522 | return "PORT_DDI_A_4_LANES"; |
| 2523 | case POWER_DOMAIN_PORT_DDI_B_2_LANES: |
| 2524 | return "PORT_DDI_B_2_LANES"; |
| 2525 | case POWER_DOMAIN_PORT_DDI_B_4_LANES: |
| 2526 | return "PORT_DDI_B_4_LANES"; |
| 2527 | case POWER_DOMAIN_PORT_DDI_C_2_LANES: |
| 2528 | return "PORT_DDI_C_2_LANES"; |
| 2529 | case POWER_DOMAIN_PORT_DDI_C_4_LANES: |
| 2530 | return "PORT_DDI_C_4_LANES"; |
| 2531 | case POWER_DOMAIN_PORT_DDI_D_2_LANES: |
| 2532 | return "PORT_DDI_D_2_LANES"; |
| 2533 | case POWER_DOMAIN_PORT_DDI_D_4_LANES: |
| 2534 | return "PORT_DDI_D_4_LANES"; |
| 2535 | case POWER_DOMAIN_PORT_DSI: |
| 2536 | return "PORT_DSI"; |
| 2537 | case POWER_DOMAIN_PORT_CRT: |
| 2538 | return "PORT_CRT"; |
| 2539 | case POWER_DOMAIN_PORT_OTHER: |
| 2540 | return "PORT_OTHER"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2541 | case POWER_DOMAIN_VGA: |
| 2542 | return "VGA"; |
| 2543 | case POWER_DOMAIN_AUDIO: |
| 2544 | return "AUDIO"; |
Paulo Zanoni | bd2bb1b | 2014-07-04 11:27:38 -0300 | [diff] [blame] | 2545 | case POWER_DOMAIN_PLLS: |
| 2546 | return "PLLS"; |
Satheeshakrishna M | 1407121 | 2015-01-16 15:57:51 +0000 | [diff] [blame] | 2547 | case POWER_DOMAIN_AUX_A: |
| 2548 | return "AUX_A"; |
| 2549 | case POWER_DOMAIN_AUX_B: |
| 2550 | return "AUX_B"; |
| 2551 | case POWER_DOMAIN_AUX_C: |
| 2552 | return "AUX_C"; |
| 2553 | case POWER_DOMAIN_AUX_D: |
| 2554 | return "AUX_D"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2555 | case POWER_DOMAIN_INIT: |
| 2556 | return "INIT"; |
| 2557 | default: |
Daniel Vetter | 5f77eeb | 2014-12-08 16:40:10 +0100 | [diff] [blame] | 2558 | MISSING_CASE(domain); |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2559 | return "?"; |
| 2560 | } |
| 2561 | } |
| 2562 | |
| 2563 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2564 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2565 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2566 | struct drm_device *dev = node->minor->dev; |
| 2567 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2568 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2569 | int i; |
| 2570 | |
| 2571 | mutex_lock(&power_domains->lock); |
| 2572 | |
| 2573 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2574 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2575 | struct i915_power_well *power_well; |
| 2576 | enum intel_display_power_domain power_domain; |
| 2577 | |
| 2578 | power_well = &power_domains->power_wells[i]; |
| 2579 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2580 | power_well->count); |
| 2581 | |
| 2582 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2583 | power_domain++) { |
| 2584 | if (!(BIT(power_domain) & power_well->domains)) |
| 2585 | continue; |
| 2586 | |
| 2587 | seq_printf(m, " %-23s %d\n", |
| 2588 | power_domain_str(power_domain), |
| 2589 | power_domains->domain_use_count[power_domain]); |
| 2590 | } |
| 2591 | } |
| 2592 | |
| 2593 | mutex_unlock(&power_domains->lock); |
| 2594 | |
| 2595 | return 0; |
| 2596 | } |
| 2597 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2598 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2599 | struct drm_display_mode *mode) |
| 2600 | { |
| 2601 | int i; |
| 2602 | |
| 2603 | for (i = 0; i < tabs; i++) |
| 2604 | seq_putc(m, '\t'); |
| 2605 | |
| 2606 | 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", |
| 2607 | mode->base.id, mode->name, |
| 2608 | mode->vrefresh, mode->clock, |
| 2609 | mode->hdisplay, mode->hsync_start, |
| 2610 | mode->hsync_end, mode->htotal, |
| 2611 | mode->vdisplay, mode->vsync_start, |
| 2612 | mode->vsync_end, mode->vtotal, |
| 2613 | mode->type, mode->flags); |
| 2614 | } |
| 2615 | |
| 2616 | static void intel_encoder_info(struct seq_file *m, |
| 2617 | struct intel_crtc *intel_crtc, |
| 2618 | struct intel_encoder *intel_encoder) |
| 2619 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2620 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2621 | struct drm_device *dev = node->minor->dev; |
| 2622 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2623 | struct intel_connector *intel_connector; |
| 2624 | struct drm_encoder *encoder; |
| 2625 | |
| 2626 | encoder = &intel_encoder->base; |
| 2627 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a03 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2628 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2629 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2630 | struct drm_connector *connector = &intel_connector->base; |
| 2631 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2632 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2633 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2634 | drm_get_connector_status_name(connector->status)); |
| 2635 | if (connector->status == connector_status_connected) { |
| 2636 | struct drm_display_mode *mode = &crtc->mode; |
| 2637 | seq_printf(m, ", mode:\n"); |
| 2638 | intel_seq_print_mode(m, 2, mode); |
| 2639 | } else { |
| 2640 | seq_putc(m, '\n'); |
| 2641 | } |
| 2642 | } |
| 2643 | } |
| 2644 | |
| 2645 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2646 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2647 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2648 | struct drm_device *dev = node->minor->dev; |
| 2649 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2650 | struct intel_encoder *intel_encoder; |
| 2651 | |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2652 | if (crtc->primary->fb) |
| 2653 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
| 2654 | crtc->primary->fb->base.id, crtc->x, crtc->y, |
| 2655 | crtc->primary->fb->width, crtc->primary->fb->height); |
| 2656 | else |
| 2657 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2658 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2659 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2660 | } |
| 2661 | |
| 2662 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2663 | { |
| 2664 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2665 | |
| 2666 | seq_printf(m, "\tfixed mode:\n"); |
| 2667 | intel_seq_print_mode(m, 2, mode); |
| 2668 | } |
| 2669 | |
| 2670 | static void intel_dp_info(struct seq_file *m, |
| 2671 | struct intel_connector *intel_connector) |
| 2672 | { |
| 2673 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2674 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2675 | |
| 2676 | seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); |
| 2677 | seq_printf(m, "\taudio support: %s\n", intel_dp->has_audio ? "yes" : |
| 2678 | "no"); |
| 2679 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2680 | intel_panel_info(m, &intel_connector->panel); |
| 2681 | } |
| 2682 | |
| 2683 | static void intel_hdmi_info(struct seq_file *m, |
| 2684 | struct intel_connector *intel_connector) |
| 2685 | { |
| 2686 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2687 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2688 | |
| 2689 | seq_printf(m, "\taudio support: %s\n", intel_hdmi->has_audio ? "yes" : |
| 2690 | "no"); |
| 2691 | } |
| 2692 | |
| 2693 | static void intel_lvds_info(struct seq_file *m, |
| 2694 | struct intel_connector *intel_connector) |
| 2695 | { |
| 2696 | intel_panel_info(m, &intel_connector->panel); |
| 2697 | } |
| 2698 | |
| 2699 | static void intel_connector_info(struct seq_file *m, |
| 2700 | struct drm_connector *connector) |
| 2701 | { |
| 2702 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2703 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2704 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2705 | |
| 2706 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2707 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2708 | drm_get_connector_status_name(connector->status)); |
| 2709 | if (connector->status == connector_status_connected) { |
| 2710 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2711 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2712 | connector->display_info.width_mm, |
| 2713 | connector->display_info.height_mm); |
| 2714 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2715 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2716 | seq_printf(m, "\tCEA rev: %d\n", |
| 2717 | connector->display_info.cea_rev); |
| 2718 | } |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2719 | if (intel_encoder) { |
| 2720 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2721 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2722 | intel_dp_info(m, intel_connector); |
| 2723 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2724 | intel_hdmi_info(m, intel_connector); |
| 2725 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2726 | intel_lvds_info(m, intel_connector); |
| 2727 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2728 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2729 | seq_printf(m, "\tmodes:\n"); |
| 2730 | list_for_each_entry(mode, &connector->modes, head) |
| 2731 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2732 | } |
| 2733 | |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2734 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 2735 | { |
| 2736 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2737 | u32 state; |
| 2738 | |
| 2739 | if (IS_845G(dev) || IS_I865G(dev)) |
| 2740 | state = I915_READ(_CURACNTR) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2741 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2742 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2743 | |
| 2744 | return state; |
| 2745 | } |
| 2746 | |
| 2747 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 2748 | { |
| 2749 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2750 | u32 pos; |
| 2751 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2752 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2753 | |
| 2754 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2755 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2756 | *x = -*x; |
| 2757 | |
| 2758 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2759 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2760 | *y = -*y; |
| 2761 | |
| 2762 | return cursor_active(dev, pipe); |
| 2763 | } |
| 2764 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2765 | static int i915_display_info(struct seq_file *m, void *unused) |
| 2766 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2767 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2768 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2769 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2770 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2771 | struct drm_connector *connector; |
| 2772 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2773 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2774 | drm_modeset_lock_all(dev); |
| 2775 | seq_printf(m, "CRTC info\n"); |
| 2776 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 2777 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2778 | bool active; |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 2779 | struct intel_crtc_state *pipe_config; |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2780 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2781 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 2782 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 2783 | |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2784 | seq_printf(m, "CRTC %d: pipe: %c, active=%s (size=%dx%d)\n", |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2785 | crtc->base.base.id, pipe_name(crtc->pipe), |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 2786 | yesno(pipe_config->base.active), |
| 2787 | pipe_config->pipe_src_w, pipe_config->pipe_src_h); |
| 2788 | if (pipe_config->base.active) { |
Chris Wilson | 065f2ec2 | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2789 | intel_crtc_info(m, crtc); |
| 2790 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2791 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2792 | 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] | 2793 | yesno(crtc->cursor_base), |
Matt Roper | 3dd512f | 2015-02-27 10:12:00 -0800 | [diff] [blame] | 2794 | x, y, crtc->base.cursor->state->crtc_w, |
| 2795 | crtc->base.cursor->state->crtc_h, |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2796 | crtc->cursor_addr, yesno(active)); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2797 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 2798 | |
| 2799 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 2800 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 2801 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2802 | } |
| 2803 | |
| 2804 | seq_printf(m, "\n"); |
| 2805 | seq_printf(m, "Connector info\n"); |
| 2806 | seq_printf(m, "--------------\n"); |
| 2807 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 2808 | intel_connector_info(m, connector); |
| 2809 | } |
| 2810 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2811 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2812 | |
| 2813 | return 0; |
| 2814 | } |
| 2815 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2816 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 2817 | { |
| 2818 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2819 | struct drm_device *dev = node->minor->dev; |
| 2820 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2821 | struct intel_engine_cs *ring; |
| 2822 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
| 2823 | int i, j, ret; |
| 2824 | |
| 2825 | if (!i915_semaphore_is_enabled(dev)) { |
| 2826 | seq_puts(m, "Semaphores are disabled\n"); |
| 2827 | return 0; |
| 2828 | } |
| 2829 | |
| 2830 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2831 | if (ret) |
| 2832 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2833 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2834 | |
| 2835 | if (IS_BROADWELL(dev)) { |
| 2836 | struct page *page; |
| 2837 | uint64_t *seqno; |
| 2838 | |
| 2839 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 2840 | |
| 2841 | seqno = (uint64_t *)kmap_atomic(page); |
| 2842 | for_each_ring(ring, dev_priv, i) { |
| 2843 | uint64_t offset; |
| 2844 | |
| 2845 | seq_printf(m, "%s\n", ring->name); |
| 2846 | |
| 2847 | seq_puts(m, " Last signal:"); |
| 2848 | for (j = 0; j < num_rings; j++) { |
| 2849 | offset = i * I915_NUM_RINGS + j; |
| 2850 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2851 | seqno[offset], offset * 8); |
| 2852 | } |
| 2853 | seq_putc(m, '\n'); |
| 2854 | |
| 2855 | seq_puts(m, " Last wait: "); |
| 2856 | for (j = 0; j < num_rings; j++) { |
| 2857 | offset = i + (j * I915_NUM_RINGS); |
| 2858 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2859 | seqno[offset], offset * 8); |
| 2860 | } |
| 2861 | seq_putc(m, '\n'); |
| 2862 | |
| 2863 | } |
| 2864 | kunmap_atomic(seqno); |
| 2865 | } else { |
| 2866 | seq_puts(m, " Last signal:"); |
| 2867 | for_each_ring(ring, dev_priv, i) |
| 2868 | for (j = 0; j < num_rings; j++) |
| 2869 | seq_printf(m, "0x%08x\n", |
| 2870 | I915_READ(ring->semaphore.mbox.signal[j])); |
| 2871 | seq_putc(m, '\n'); |
| 2872 | } |
| 2873 | |
| 2874 | seq_puts(m, "\nSync seqno:\n"); |
| 2875 | for_each_ring(ring, dev_priv, i) { |
| 2876 | for (j = 0; j < num_rings; j++) { |
| 2877 | seq_printf(m, " 0x%08x ", ring->semaphore.sync_seqno[j]); |
| 2878 | } |
| 2879 | seq_putc(m, '\n'); |
| 2880 | } |
| 2881 | seq_putc(m, '\n'); |
| 2882 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2883 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2884 | mutex_unlock(&dev->struct_mutex); |
| 2885 | return 0; |
| 2886 | } |
| 2887 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2888 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 2889 | { |
| 2890 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2891 | struct drm_device *dev = node->minor->dev; |
| 2892 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2893 | int i; |
| 2894 | |
| 2895 | drm_modeset_lock_all(dev); |
| 2896 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 2897 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 2898 | |
| 2899 | 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] | 2900 | 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] | 2901 | pll->config.crtc_mask, pll->active, yesno(pll->on)); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2902 | seq_printf(m, " tracked hardware state:\n"); |
Ander Conselvan de Oliveira | 3e369b7 | 2014-10-29 11:32:32 +0200 | [diff] [blame] | 2903 | seq_printf(m, " dpll: 0x%08x\n", pll->config.hw_state.dpll); |
| 2904 | seq_printf(m, " dpll_md: 0x%08x\n", |
| 2905 | pll->config.hw_state.dpll_md); |
| 2906 | seq_printf(m, " fp0: 0x%08x\n", pll->config.hw_state.fp0); |
| 2907 | seq_printf(m, " fp1: 0x%08x\n", pll->config.hw_state.fp1); |
| 2908 | seq_printf(m, " wrpll: 0x%08x\n", pll->config.hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2909 | } |
| 2910 | drm_modeset_unlock_all(dev); |
| 2911 | |
| 2912 | return 0; |
| 2913 | } |
| 2914 | |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 2915 | static int i915_wa_registers(struct seq_file *m, void *unused) |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2916 | { |
| 2917 | int i; |
| 2918 | int ret; |
| 2919 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2920 | struct drm_device *dev = node->minor->dev; |
| 2921 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2922 | |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2923 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2924 | if (ret) |
| 2925 | return ret; |
| 2926 | |
| 2927 | intel_runtime_pm_get(dev_priv); |
| 2928 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2929 | seq_printf(m, "Workarounds applied: %d\n", dev_priv->workarounds.count); |
| 2930 | for (i = 0; i < dev_priv->workarounds.count; ++i) { |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 2931 | u32 addr, mask, value, read; |
| 2932 | bool ok; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2933 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2934 | addr = dev_priv->workarounds.reg[i].addr; |
| 2935 | mask = dev_priv->workarounds.reg[i].mask; |
Mika Kuoppala | 2fa60f6 | 2014-10-07 17:21:27 +0300 | [diff] [blame] | 2936 | value = dev_priv->workarounds.reg[i].value; |
| 2937 | read = I915_READ(addr); |
| 2938 | ok = (value & mask) == (read & mask); |
| 2939 | seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n", |
| 2940 | addr, value, mask, read, ok ? "OK" : "FAIL"); |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 2941 | } |
| 2942 | |
| 2943 | intel_runtime_pm_put(dev_priv); |
| 2944 | mutex_unlock(&dev->struct_mutex); |
| 2945 | |
| 2946 | return 0; |
| 2947 | } |
| 2948 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2949 | static int i915_ddb_info(struct seq_file *m, void *unused) |
| 2950 | { |
| 2951 | struct drm_info_node *node = m->private; |
| 2952 | struct drm_device *dev = node->minor->dev; |
| 2953 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2954 | struct skl_ddb_allocation *ddb; |
| 2955 | struct skl_ddb_entry *entry; |
| 2956 | enum pipe pipe; |
| 2957 | int plane; |
| 2958 | |
Damien Lespiau | 2fcffe1 | 2014-12-03 17:33:24 +0000 | [diff] [blame] | 2959 | if (INTEL_INFO(dev)->gen < 9) |
| 2960 | return 0; |
| 2961 | |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2962 | drm_modeset_lock_all(dev); |
| 2963 | |
| 2964 | ddb = &dev_priv->wm.skl_hw.ddb; |
| 2965 | |
| 2966 | seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); |
| 2967 | |
| 2968 | for_each_pipe(dev_priv, pipe) { |
| 2969 | seq_printf(m, "Pipe %c\n", pipe_name(pipe)); |
| 2970 | |
Damien Lespiau | dd74078 | 2015-02-28 14:54:08 +0000 | [diff] [blame] | 2971 | for_each_plane(dev_priv, pipe, plane) { |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 2972 | entry = &ddb->plane[pipe][plane]; |
| 2973 | seq_printf(m, " Plane%-8d%8u%8u%8u\n", plane + 1, |
| 2974 | entry->start, entry->end, |
| 2975 | skl_ddb_entry_size(entry)); |
| 2976 | } |
| 2977 | |
| 2978 | entry = &ddb->cursor[pipe]; |
| 2979 | seq_printf(m, " %-13s%8u%8u%8u\n", "Cursor", entry->start, |
| 2980 | entry->end, skl_ddb_entry_size(entry)); |
| 2981 | } |
| 2982 | |
| 2983 | drm_modeset_unlock_all(dev); |
| 2984 | |
| 2985 | return 0; |
| 2986 | } |
| 2987 | |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 2988 | static void drrs_status_per_crtc(struct seq_file *m, |
| 2989 | struct drm_device *dev, struct intel_crtc *intel_crtc) |
| 2990 | { |
| 2991 | struct intel_encoder *intel_encoder; |
| 2992 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2993 | struct i915_drrs *drrs = &dev_priv->drrs; |
| 2994 | int vrefresh = 0; |
| 2995 | |
| 2996 | for_each_encoder_on_crtc(dev, &intel_crtc->base, intel_encoder) { |
| 2997 | /* Encoder connected on this CRTC */ |
| 2998 | switch (intel_encoder->type) { |
| 2999 | case INTEL_OUTPUT_EDP: |
| 3000 | seq_puts(m, "eDP:\n"); |
| 3001 | break; |
| 3002 | case INTEL_OUTPUT_DSI: |
| 3003 | seq_puts(m, "DSI:\n"); |
| 3004 | break; |
| 3005 | case INTEL_OUTPUT_HDMI: |
| 3006 | seq_puts(m, "HDMI:\n"); |
| 3007 | break; |
| 3008 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3009 | seq_puts(m, "DP:\n"); |
| 3010 | break; |
| 3011 | default: |
| 3012 | seq_printf(m, "Other encoder (id=%d).\n", |
| 3013 | intel_encoder->type); |
| 3014 | return; |
| 3015 | } |
| 3016 | } |
| 3017 | |
| 3018 | if (dev_priv->vbt.drrs_type == STATIC_DRRS_SUPPORT) |
| 3019 | seq_puts(m, "\tVBT: DRRS_type: Static"); |
| 3020 | else if (dev_priv->vbt.drrs_type == SEAMLESS_DRRS_SUPPORT) |
| 3021 | seq_puts(m, "\tVBT: DRRS_type: Seamless"); |
| 3022 | else if (dev_priv->vbt.drrs_type == DRRS_NOT_SUPPORTED) |
| 3023 | seq_puts(m, "\tVBT: DRRS_type: None"); |
| 3024 | else |
| 3025 | seq_puts(m, "\tVBT: DRRS_type: FIXME: Unrecognized Value"); |
| 3026 | |
| 3027 | seq_puts(m, "\n\n"); |
| 3028 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3029 | if (to_intel_crtc_state(intel_crtc->base.state)->has_drrs) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3030 | struct intel_panel *panel; |
| 3031 | |
| 3032 | mutex_lock(&drrs->mutex); |
| 3033 | /* DRRS Supported */ |
| 3034 | seq_puts(m, "\tDRRS Supported: Yes\n"); |
| 3035 | |
| 3036 | /* disable_drrs() will make drrs->dp NULL */ |
| 3037 | if (!drrs->dp) { |
| 3038 | seq_puts(m, "Idleness DRRS: Disabled"); |
| 3039 | mutex_unlock(&drrs->mutex); |
| 3040 | return; |
| 3041 | } |
| 3042 | |
| 3043 | panel = &drrs->dp->attached_connector->panel; |
| 3044 | seq_printf(m, "\t\tBusy_frontbuffer_bits: 0x%X", |
| 3045 | drrs->busy_frontbuffer_bits); |
| 3046 | |
| 3047 | seq_puts(m, "\n\t\t"); |
| 3048 | if (drrs->refresh_rate_type == DRRS_HIGH_RR) { |
| 3049 | seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); |
| 3050 | vrefresh = panel->fixed_mode->vrefresh; |
| 3051 | } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { |
| 3052 | seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); |
| 3053 | vrefresh = panel->downclock_mode->vrefresh; |
| 3054 | } else { |
| 3055 | seq_printf(m, "DRRS_State: Unknown(%d)\n", |
| 3056 | drrs->refresh_rate_type); |
| 3057 | mutex_unlock(&drrs->mutex); |
| 3058 | return; |
| 3059 | } |
| 3060 | seq_printf(m, "\t\tVrefresh: %d", vrefresh); |
| 3061 | |
| 3062 | seq_puts(m, "\n\t\t"); |
| 3063 | mutex_unlock(&drrs->mutex); |
| 3064 | } else { |
| 3065 | /* DRRS not supported. Print the VBT parameter*/ |
| 3066 | seq_puts(m, "\tDRRS Supported : No"); |
| 3067 | } |
| 3068 | seq_puts(m, "\n"); |
| 3069 | } |
| 3070 | |
| 3071 | static int i915_drrs_status(struct seq_file *m, void *unused) |
| 3072 | { |
| 3073 | struct drm_info_node *node = m->private; |
| 3074 | struct drm_device *dev = node->minor->dev; |
| 3075 | struct intel_crtc *intel_crtc; |
| 3076 | int active_crtc_cnt = 0; |
| 3077 | |
| 3078 | for_each_intel_crtc(dev, intel_crtc) { |
| 3079 | drm_modeset_lock(&intel_crtc->base.mutex, NULL); |
| 3080 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3081 | if (intel_crtc->base.state->active) { |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 3082 | active_crtc_cnt++; |
| 3083 | seq_printf(m, "\nCRTC %d: ", active_crtc_cnt); |
| 3084 | |
| 3085 | drrs_status_per_crtc(m, dev, intel_crtc); |
| 3086 | } |
| 3087 | |
| 3088 | drm_modeset_unlock(&intel_crtc->base.mutex); |
| 3089 | } |
| 3090 | |
| 3091 | if (!active_crtc_cnt) |
| 3092 | seq_puts(m, "No active crtc found\n"); |
| 3093 | |
| 3094 | return 0; |
| 3095 | } |
| 3096 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3097 | struct pipe_crc_info { |
| 3098 | const char *name; |
| 3099 | struct drm_device *dev; |
| 3100 | enum pipe pipe; |
| 3101 | }; |
| 3102 | |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 3103 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 3104 | { |
| 3105 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3106 | struct drm_device *dev = node->minor->dev; |
| 3107 | struct drm_encoder *encoder; |
| 3108 | struct intel_encoder *intel_encoder; |
| 3109 | struct intel_digital_port *intel_dig_port; |
| 3110 | drm_modeset_lock_all(dev); |
| 3111 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 3112 | intel_encoder = to_intel_encoder(encoder); |
| 3113 | if (intel_encoder->type != INTEL_OUTPUT_DISPLAYPORT) |
| 3114 | continue; |
| 3115 | intel_dig_port = enc_to_dig_port(encoder); |
| 3116 | if (!intel_dig_port->dp.can_mst) |
| 3117 | continue; |
| 3118 | |
| 3119 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 3120 | } |
| 3121 | drm_modeset_unlock_all(dev); |
| 3122 | return 0; |
| 3123 | } |
| 3124 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3125 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3126 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3127 | struct pipe_crc_info *info = inode->i_private; |
| 3128 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 3129 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3130 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 3131 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 3132 | return -ENODEV; |
| 3133 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3134 | spin_lock_irq(&pipe_crc->lock); |
| 3135 | |
| 3136 | if (pipe_crc->opened) { |
| 3137 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3138 | return -EBUSY; /* already open */ |
| 3139 | } |
| 3140 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3141 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3142 | filep->private_data = inode->i_private; |
| 3143 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3144 | spin_unlock_irq(&pipe_crc->lock); |
| 3145 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3146 | return 0; |
| 3147 | } |
| 3148 | |
| 3149 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 3150 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3151 | struct pipe_crc_info *info = inode->i_private; |
| 3152 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 3153 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3154 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3155 | spin_lock_irq(&pipe_crc->lock); |
| 3156 | pipe_crc->opened = false; |
| 3157 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 3158 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3159 | return 0; |
| 3160 | } |
| 3161 | |
| 3162 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 3163 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 3164 | /* account for \'0' */ |
| 3165 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 3166 | |
| 3167 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 3168 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3169 | assert_spin_locked(&pipe_crc->lock); |
| 3170 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3171 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3172 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3173 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3174 | static ssize_t |
| 3175 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 3176 | loff_t *pos) |
| 3177 | { |
| 3178 | struct pipe_crc_info *info = filep->private_data; |
| 3179 | struct drm_device *dev = info->dev; |
| 3180 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3181 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 3182 | char buf[PIPE_CRC_BUFFER_LEN]; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3183 | int n_entries; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3184 | ssize_t bytes_read; |
| 3185 | |
| 3186 | /* |
| 3187 | * Don't allow user space to provide buffers not big enough to hold |
| 3188 | * a line of data. |
| 3189 | */ |
| 3190 | if (count < PIPE_CRC_LINE_LEN) |
| 3191 | return -EINVAL; |
| 3192 | |
| 3193 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 3194 | return 0; |
| 3195 | |
| 3196 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3197 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3198 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3199 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3200 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3201 | if (filep->f_flags & O_NONBLOCK) { |
| 3202 | spin_unlock_irq(&pipe_crc->lock); |
| 3203 | return -EAGAIN; |
| 3204 | } |
| 3205 | |
| 3206 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 3207 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 3208 | if (ret) { |
| 3209 | spin_unlock_irq(&pipe_crc->lock); |
| 3210 | return ret; |
| 3211 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3212 | } |
| 3213 | |
| 3214 | /* We now have one or more entries to read */ |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3215 | n_entries = count / PIPE_CRC_LINE_LEN; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3216 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3217 | bytes_read = 0; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3218 | while (n_entries > 0) { |
| 3219 | struct intel_pipe_crc_entry *entry = |
| 3220 | &pipe_crc->entries[pipe_crc->tail]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3221 | int ret; |
| 3222 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3223 | if (CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 3224 | INTEL_PIPE_CRC_ENTRIES_NR) < 1) |
| 3225 | break; |
| 3226 | |
| 3227 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 3228 | pipe_crc->tail = (pipe_crc->tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 3229 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3230 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 3231 | "%8u %8x %8x %8x %8x %8x\n", |
| 3232 | entry->frame, entry->crc[0], |
| 3233 | entry->crc[1], entry->crc[2], |
| 3234 | entry->crc[3], entry->crc[4]); |
| 3235 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3236 | spin_unlock_irq(&pipe_crc->lock); |
| 3237 | |
| 3238 | ret = copy_to_user(user_buf, buf, PIPE_CRC_LINE_LEN); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3239 | if (ret == PIPE_CRC_LINE_LEN) |
| 3240 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 3241 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3242 | user_buf += PIPE_CRC_LINE_LEN; |
| 3243 | n_entries--; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3244 | |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3245 | spin_lock_irq(&pipe_crc->lock); |
| 3246 | } |
| 3247 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3248 | spin_unlock_irq(&pipe_crc->lock); |
| 3249 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3250 | return bytes_read; |
| 3251 | } |
| 3252 | |
| 3253 | static const struct file_operations i915_pipe_crc_fops = { |
| 3254 | .owner = THIS_MODULE, |
| 3255 | .open = i915_pipe_crc_open, |
| 3256 | .read = i915_pipe_crc_read, |
| 3257 | .release = i915_pipe_crc_release, |
| 3258 | }; |
| 3259 | |
| 3260 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 3261 | { |
| 3262 | .name = "i915_pipe_A_crc", |
| 3263 | .pipe = PIPE_A, |
| 3264 | }, |
| 3265 | { |
| 3266 | .name = "i915_pipe_B_crc", |
| 3267 | .pipe = PIPE_B, |
| 3268 | }, |
| 3269 | { |
| 3270 | .name = "i915_pipe_C_crc", |
| 3271 | .pipe = PIPE_C, |
| 3272 | }, |
| 3273 | }; |
| 3274 | |
| 3275 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 3276 | enum pipe pipe) |
| 3277 | { |
| 3278 | struct drm_device *dev = minor->dev; |
| 3279 | struct dentry *ent; |
| 3280 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 3281 | |
| 3282 | info->dev = dev; |
| 3283 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 3284 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 3285 | if (!ent) |
| 3286 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 3287 | |
| 3288 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 3289 | } |
| 3290 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3291 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3292 | "none", |
| 3293 | "plane1", |
| 3294 | "plane2", |
| 3295 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3296 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3297 | "TV", |
| 3298 | "DP-B", |
| 3299 | "DP-C", |
| 3300 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3301 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3302 | }; |
| 3303 | |
| 3304 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 3305 | { |
| 3306 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 3307 | return pipe_crc_sources[source]; |
| 3308 | } |
| 3309 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3310 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3311 | { |
| 3312 | struct drm_device *dev = m->private; |
| 3313 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3314 | int i; |
| 3315 | |
| 3316 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 3317 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 3318 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 3319 | |
| 3320 | return 0; |
| 3321 | } |
| 3322 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3323 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3324 | { |
| 3325 | struct drm_device *dev = inode->i_private; |
| 3326 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3327 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3328 | } |
| 3329 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3330 | 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] | 3331 | uint32_t *val) |
| 3332 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3333 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3334 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3335 | |
| 3336 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3337 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3338 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 3339 | break; |
| 3340 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3341 | *val = 0; |
| 3342 | break; |
| 3343 | default: |
| 3344 | return -EINVAL; |
| 3345 | } |
| 3346 | |
| 3347 | return 0; |
| 3348 | } |
| 3349 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3350 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 3351 | enum intel_pipe_crc_source *source) |
| 3352 | { |
| 3353 | struct intel_encoder *encoder; |
| 3354 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3355 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3356 | int ret = 0; |
| 3357 | |
| 3358 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3359 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3360 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 3361 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3362 | if (!encoder->base.crtc) |
| 3363 | continue; |
| 3364 | |
| 3365 | crtc = to_intel_crtc(encoder->base.crtc); |
| 3366 | |
| 3367 | if (crtc->pipe != pipe) |
| 3368 | continue; |
| 3369 | |
| 3370 | switch (encoder->type) { |
| 3371 | case INTEL_OUTPUT_TVOUT: |
| 3372 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 3373 | break; |
| 3374 | case INTEL_OUTPUT_DISPLAYPORT: |
| 3375 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 3376 | dig_port = enc_to_dig_port(&encoder->base); |
| 3377 | switch (dig_port->port) { |
| 3378 | case PORT_B: |
| 3379 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 3380 | break; |
| 3381 | case PORT_C: |
| 3382 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 3383 | break; |
| 3384 | case PORT_D: |
| 3385 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 3386 | break; |
| 3387 | default: |
| 3388 | WARN(1, "nonexisting DP port %c\n", |
| 3389 | port_name(dig_port->port)); |
| 3390 | break; |
| 3391 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3392 | break; |
Paulo Zanoni | 6847d71b | 2014-10-27 17:47:52 -0200 | [diff] [blame] | 3393 | default: |
| 3394 | break; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3395 | } |
| 3396 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 3397 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3398 | |
| 3399 | return ret; |
| 3400 | } |
| 3401 | |
| 3402 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3403 | enum pipe pipe, |
| 3404 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3405 | uint32_t *val) |
| 3406 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3407 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3408 | bool need_stable_symbols = false; |
| 3409 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3410 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3411 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3412 | if (ret) |
| 3413 | return ret; |
| 3414 | } |
| 3415 | |
| 3416 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3417 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3418 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 3419 | break; |
| 3420 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3421 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3422 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3423 | break; |
| 3424 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3425 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3426 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3427 | break; |
Ville Syrjälä | 2be5792 | 2014-12-09 21:28:29 +0200 | [diff] [blame] | 3428 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3429 | if (!IS_CHERRYVIEW(dev)) |
| 3430 | return -EINVAL; |
| 3431 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV; |
| 3432 | need_stable_symbols = true; |
| 3433 | break; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3434 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3435 | *val = 0; |
| 3436 | break; |
| 3437 | default: |
| 3438 | return -EINVAL; |
| 3439 | } |
| 3440 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3441 | /* |
| 3442 | * When the pipe CRC tap point is after the transcoders we need |
| 3443 | * to tweak symbol-level features to produce a deterministic series of |
| 3444 | * symbols for a given frame. We need to reset those features only once |
| 3445 | * a frame (instead of every nth symbol): |
| 3446 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3447 | * link (SDVO) |
| 3448 | * - DisplayPort scrambling: used for EMI reduction |
| 3449 | */ |
| 3450 | if (need_stable_symbols) { |
| 3451 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3452 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3453 | tmp |= DC_BALANCE_RESET_VLV; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3454 | switch (pipe) { |
| 3455 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3456 | tmp |= PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3457 | break; |
| 3458 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3459 | tmp |= PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3460 | break; |
| 3461 | case PIPE_C: |
| 3462 | tmp |= PIPE_C_SCRAMBLE_RESET; |
| 3463 | break; |
| 3464 | default: |
| 3465 | return -EINVAL; |
| 3466 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3467 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3468 | } |
| 3469 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3470 | return 0; |
| 3471 | } |
| 3472 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3473 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3474 | enum pipe pipe, |
| 3475 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3476 | uint32_t *val) |
| 3477 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3478 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3479 | bool need_stable_symbols = false; |
| 3480 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3481 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 3482 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 3483 | if (ret) |
| 3484 | return ret; |
| 3485 | } |
| 3486 | |
| 3487 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3488 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3489 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 3490 | break; |
| 3491 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 3492 | if (!SUPPORTS_TV(dev)) |
| 3493 | return -EINVAL; |
| 3494 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3495 | break; |
| 3496 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3497 | if (!IS_G4X(dev)) |
| 3498 | return -EINVAL; |
| 3499 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3500 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3501 | break; |
| 3502 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3503 | if (!IS_G4X(dev)) |
| 3504 | return -EINVAL; |
| 3505 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3506 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3507 | break; |
| 3508 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3509 | if (!IS_G4X(dev)) |
| 3510 | return -EINVAL; |
| 3511 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3512 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3513 | break; |
| 3514 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3515 | *val = 0; |
| 3516 | break; |
| 3517 | default: |
| 3518 | return -EINVAL; |
| 3519 | } |
| 3520 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3521 | /* |
| 3522 | * When the pipe CRC tap point is after the transcoders we need |
| 3523 | * to tweak symbol-level features to produce a deterministic series of |
| 3524 | * symbols for a given frame. We need to reset those features only once |
| 3525 | * a frame (instead of every nth symbol): |
| 3526 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3527 | * link (SDVO) |
| 3528 | * - DisplayPort scrambling: used for EMI reduction |
| 3529 | */ |
| 3530 | if (need_stable_symbols) { |
| 3531 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3532 | |
| 3533 | WARN_ON(!IS_G4X(dev)); |
| 3534 | |
| 3535 | I915_WRITE(PORT_DFT_I9XX, |
| 3536 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3537 | |
| 3538 | if (pipe == PIPE_A) |
| 3539 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3540 | else |
| 3541 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3542 | |
| 3543 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3544 | } |
| 3545 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3546 | return 0; |
| 3547 | } |
| 3548 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3549 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3550 | enum pipe pipe) |
| 3551 | { |
| 3552 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3553 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3554 | |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3555 | switch (pipe) { |
| 3556 | case PIPE_A: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3557 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3558 | break; |
| 3559 | case PIPE_B: |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3560 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
Ville Syrjälä | eb73667 | 2014-12-09 21:28:28 +0200 | [diff] [blame] | 3561 | break; |
| 3562 | case PIPE_C: |
| 3563 | tmp &= ~PIPE_C_SCRAMBLE_RESET; |
| 3564 | break; |
| 3565 | default: |
| 3566 | return; |
| 3567 | } |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3568 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3569 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3570 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3571 | |
| 3572 | } |
| 3573 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3574 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3575 | enum pipe pipe) |
| 3576 | { |
| 3577 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3578 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3579 | |
| 3580 | if (pipe == PIPE_A) |
| 3581 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3582 | else |
| 3583 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3584 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3585 | |
| 3586 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3587 | I915_WRITE(PORT_DFT_I9XX, |
| 3588 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3589 | } |
| 3590 | } |
| 3591 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3592 | 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] | 3593 | uint32_t *val) |
| 3594 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3595 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3596 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3597 | |
| 3598 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3599 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3600 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 3601 | break; |
| 3602 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3603 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 3604 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3605 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3606 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 3607 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3608 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3609 | *val = 0; |
| 3610 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3611 | default: |
| 3612 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3613 | } |
| 3614 | |
| 3615 | return 0; |
| 3616 | } |
| 3617 | |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3618 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3619 | { |
| 3620 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3621 | struct intel_crtc *crtc = |
| 3622 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3623 | struct intel_crtc_state *pipe_config; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3624 | |
| 3625 | drm_modeset_lock_all(dev); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3626 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3627 | |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3628 | /* |
| 3629 | * If we use the eDP transcoder we need to make sure that we don't |
| 3630 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3631 | * relevant on hsw with pipe A when using the always-on power well |
| 3632 | * routing. |
| 3633 | */ |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3634 | if (pipe_config->cpu_transcoder == TRANSCODER_EDP && |
| 3635 | !pipe_config->pch_pfit.enabled) { |
| 3636 | bool active = pipe_config->base.active; |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3637 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3638 | if (active) { |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3639 | intel_crtc_control(&crtc->base, false); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3640 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3641 | } |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3642 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3643 | pipe_config->pch_pfit.force_thru = true; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3644 | |
| 3645 | intel_display_power_get(dev_priv, |
| 3646 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3647 | |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3648 | if (active) |
| 3649 | intel_crtc_control(&crtc->base, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3650 | } |
| 3651 | drm_modeset_unlock_all(dev); |
| 3652 | } |
| 3653 | |
| 3654 | static void hsw_undo_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3655 | { |
| 3656 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3657 | struct intel_crtc *crtc = |
| 3658 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3659 | struct intel_crtc_state *pipe_config; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3660 | |
| 3661 | drm_modeset_lock_all(dev); |
| 3662 | /* |
| 3663 | * If we use the eDP transcoder we need to make sure that we don't |
| 3664 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3665 | * relevant on hsw with pipe A when using the always-on power well |
| 3666 | * routing. |
| 3667 | */ |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3668 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3669 | if (pipe_config->pch_pfit.force_thru) { |
| 3670 | bool active = pipe_config->base.active; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3671 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3672 | if (active) { |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3673 | intel_crtc_control(&crtc->base, false); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3674 | pipe_config = to_intel_crtc_state(crtc->base.state); |
| 3675 | } |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3676 | |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3677 | pipe_config->pch_pfit.force_thru = false; |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3678 | |
| 3679 | intel_display_power_put(dev_priv, |
| 3680 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
Maarten Lankhorst | 1b50925 | 2015-06-01 12:49:48 +0200 | [diff] [blame] | 3681 | |
| 3682 | if (active) |
| 3683 | intel_crtc_control(&crtc->base, true); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3684 | } |
| 3685 | drm_modeset_unlock_all(dev); |
| 3686 | } |
| 3687 | |
| 3688 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3689 | enum pipe pipe, |
| 3690 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3691 | uint32_t *val) |
| 3692 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3693 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3694 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 3695 | |
| 3696 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3697 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3698 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 3699 | break; |
| 3700 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3701 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 3702 | break; |
| 3703 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3704 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3705 | hsw_trans_edp_pipe_A_crc_wa(dev); |
| 3706 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3707 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 3708 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3709 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3710 | *val = 0; |
| 3711 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3712 | default: |
| 3713 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3714 | } |
| 3715 | |
| 3716 | return 0; |
| 3717 | } |
| 3718 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3719 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 3720 | enum intel_pipe_crc_source source) |
| 3721 | { |
| 3722 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3723 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3724 | struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, |
| 3725 | pipe)); |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 3726 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3727 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3728 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3729 | if (pipe_crc->source == source) |
| 3730 | return 0; |
| 3731 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 3732 | /* forbid changing the source without going back to 'none' */ |
| 3733 | if (pipe_crc->source && source) |
| 3734 | return -EINVAL; |
| 3735 | |
Daniel Vetter | 9d8b058 | 2014-11-25 14:00:40 +0100 | [diff] [blame] | 3736 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PIPE(pipe))) { |
| 3737 | DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n"); |
| 3738 | return -EIO; |
| 3739 | } |
| 3740 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3741 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3742 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3743 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3744 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3745 | else if (IS_VALLEYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3746 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3747 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3748 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3749 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3750 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3751 | |
| 3752 | if (ret != 0) |
| 3753 | return ret; |
| 3754 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3755 | /* none -> real source transition */ |
| 3756 | if (source) { |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3757 | struct intel_pipe_crc_entry *entries; |
| 3758 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3759 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 3760 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 3761 | |
Ville Syrjälä | 3cf54b3 | 2014-12-09 21:28:31 +0200 | [diff] [blame] | 3762 | entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR, |
| 3763 | sizeof(pipe_crc->entries[0]), |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3764 | GFP_KERNEL); |
| 3765 | if (!entries) |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3766 | return -ENOMEM; |
| 3767 | |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3768 | /* |
| 3769 | * When IPS gets enabled, the pipe CRC changes. Since IPS gets |
| 3770 | * enabled and disabled dynamically based on package C states, |
| 3771 | * user space can't make reliable use of the CRCs, so let's just |
| 3772 | * completely disable it. |
| 3773 | */ |
| 3774 | hsw_disable_ips(crtc); |
| 3775 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3776 | spin_lock_irq(&pipe_crc->lock); |
Daniel Vetter | 64387b6 | 2014-12-10 11:00:29 +0100 | [diff] [blame] | 3777 | kfree(pipe_crc->entries); |
Ville Syrjälä | 4252fbc | 2014-12-09 21:28:30 +0200 | [diff] [blame] | 3778 | pipe_crc->entries = entries; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3779 | pipe_crc->head = 0; |
| 3780 | pipe_crc->tail = 0; |
| 3781 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3782 | } |
| 3783 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3784 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3785 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3786 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 3787 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 3788 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3789 | /* real source -> none transition */ |
| 3790 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3791 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3792 | struct intel_crtc *crtc = |
| 3793 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3794 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3795 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 3796 | pipe_name(pipe)); |
| 3797 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3798 | drm_modeset_lock(&crtc->base.mutex, NULL); |
Maarten Lankhorst | f77076c | 2015-06-01 12:50:08 +0200 | [diff] [blame] | 3799 | if (crtc->base.state->active) |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3800 | intel_wait_for_vblank(dev, pipe); |
| 3801 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 3802 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3803 | spin_lock_irq(&pipe_crc->lock); |
| 3804 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3805 | pipe_crc->entries = NULL; |
Ville Syrjälä | 9ad6d99 | 2014-12-09 21:28:32 +0200 | [diff] [blame] | 3806 | pipe_crc->head = 0; |
| 3807 | pipe_crc->tail = 0; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3808 | spin_unlock_irq(&pipe_crc->lock); |
| 3809 | |
| 3810 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3811 | |
| 3812 | if (IS_G4X(dev)) |
| 3813 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3814 | else if (IS_VALLEYVIEW(dev)) |
| 3815 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3816 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3817 | hsw_undo_trans_edp_pipe_A_crc_wa(dev); |
Paulo Zanoni | 8c740dc | 2014-10-17 18:42:03 -0300 | [diff] [blame] | 3818 | |
| 3819 | hsw_enable_ips(crtc); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3820 | } |
| 3821 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3822 | return 0; |
| 3823 | } |
| 3824 | |
| 3825 | /* |
| 3826 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3827 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 3828 | * object: 'pipe' |
| 3829 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3830 | * source: (none | plane1 | plane2 | pf) |
| 3831 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 3832 | * |
| 3833 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3834 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 3835 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3836 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3837 | 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] | 3838 | { |
| 3839 | int n_words = 0; |
| 3840 | |
| 3841 | while (*buf) { |
| 3842 | char *end; |
| 3843 | |
| 3844 | /* skip leading white space */ |
| 3845 | buf = skip_spaces(buf); |
| 3846 | if (!*buf) |
| 3847 | break; /* end of buffer */ |
| 3848 | |
| 3849 | /* find end of word */ |
| 3850 | for (end = buf; *end && !isspace(*end); end++) |
| 3851 | ; |
| 3852 | |
| 3853 | if (n_words == max_words) { |
| 3854 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 3855 | max_words); |
| 3856 | return -EINVAL; /* ran out of words[] before bytes */ |
| 3857 | } |
| 3858 | |
| 3859 | if (*end) |
| 3860 | *end++ = '\0'; |
| 3861 | words[n_words++] = buf; |
| 3862 | buf = end; |
| 3863 | } |
| 3864 | |
| 3865 | return n_words; |
| 3866 | } |
| 3867 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3868 | enum intel_pipe_crc_object { |
| 3869 | PIPE_CRC_OBJECT_PIPE, |
| 3870 | }; |
| 3871 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3872 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3873 | "pipe", |
| 3874 | }; |
| 3875 | |
| 3876 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3877 | 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] | 3878 | { |
| 3879 | int i; |
| 3880 | |
| 3881 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 3882 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3883 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3884 | return 0; |
| 3885 | } |
| 3886 | |
| 3887 | return -EINVAL; |
| 3888 | } |
| 3889 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3890 | 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] | 3891 | { |
| 3892 | const char name = buf[0]; |
| 3893 | |
| 3894 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 3895 | return -EINVAL; |
| 3896 | |
| 3897 | *pipe = name - 'A'; |
| 3898 | |
| 3899 | return 0; |
| 3900 | } |
| 3901 | |
| 3902 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3903 | 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] | 3904 | { |
| 3905 | int i; |
| 3906 | |
| 3907 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 3908 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3909 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3910 | return 0; |
| 3911 | } |
| 3912 | |
| 3913 | return -EINVAL; |
| 3914 | } |
| 3915 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3916 | 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] | 3917 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3918 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3919 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3920 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3921 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3922 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3923 | enum intel_pipe_crc_source source; |
| 3924 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3925 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3926 | if (n_words != N_WORDS) { |
| 3927 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 3928 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3929 | return -EINVAL; |
| 3930 | } |
| 3931 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3932 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3933 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3934 | return -EINVAL; |
| 3935 | } |
| 3936 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3937 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3938 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 3939 | return -EINVAL; |
| 3940 | } |
| 3941 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3942 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3943 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3944 | return -EINVAL; |
| 3945 | } |
| 3946 | |
| 3947 | return pipe_crc_set_source(dev, pipe, source); |
| 3948 | } |
| 3949 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3950 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 3951 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3952 | { |
| 3953 | struct seq_file *m = file->private_data; |
| 3954 | struct drm_device *dev = m->private; |
| 3955 | char *tmpbuf; |
| 3956 | int ret; |
| 3957 | |
| 3958 | if (len == 0) |
| 3959 | return 0; |
| 3960 | |
| 3961 | if (len > PAGE_SIZE - 1) { |
| 3962 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 3963 | PAGE_SIZE); |
| 3964 | return -E2BIG; |
| 3965 | } |
| 3966 | |
| 3967 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 3968 | if (!tmpbuf) |
| 3969 | return -ENOMEM; |
| 3970 | |
| 3971 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 3972 | ret = -EFAULT; |
| 3973 | goto out; |
| 3974 | } |
| 3975 | tmpbuf[len] = '\0'; |
| 3976 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3977 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3978 | |
| 3979 | out: |
| 3980 | kfree(tmpbuf); |
| 3981 | if (ret < 0) |
| 3982 | return ret; |
| 3983 | |
| 3984 | *offp += len; |
| 3985 | return len; |
| 3986 | } |
| 3987 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3988 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3989 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3990 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3991 | .read = seq_read, |
| 3992 | .llseek = seq_lseek, |
| 3993 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3994 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3995 | }; |
| 3996 | |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 3997 | static ssize_t i915_displayport_test_active_write(struct file *file, |
| 3998 | const char __user *ubuf, |
| 3999 | size_t len, loff_t *offp) |
| 4000 | { |
| 4001 | char *input_buffer; |
| 4002 | int status = 0; |
| 4003 | struct seq_file *m; |
| 4004 | struct drm_device *dev; |
| 4005 | struct drm_connector *connector; |
| 4006 | struct list_head *connector_list; |
| 4007 | struct intel_dp *intel_dp; |
| 4008 | int val = 0; |
| 4009 | |
| 4010 | m = file->private_data; |
| 4011 | if (!m) { |
| 4012 | status = -ENODEV; |
| 4013 | return status; |
| 4014 | } |
| 4015 | dev = m->private; |
| 4016 | |
| 4017 | if (!dev) { |
| 4018 | status = -ENODEV; |
| 4019 | return status; |
| 4020 | } |
| 4021 | connector_list = &dev->mode_config.connector_list; |
| 4022 | |
| 4023 | if (len == 0) |
| 4024 | return 0; |
| 4025 | |
| 4026 | input_buffer = kmalloc(len + 1, GFP_KERNEL); |
| 4027 | if (!input_buffer) |
| 4028 | return -ENOMEM; |
| 4029 | |
| 4030 | if (copy_from_user(input_buffer, ubuf, len)) { |
| 4031 | status = -EFAULT; |
| 4032 | goto out; |
| 4033 | } |
| 4034 | |
| 4035 | input_buffer[len] = '\0'; |
| 4036 | DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); |
| 4037 | |
| 4038 | list_for_each_entry(connector, connector_list, head) { |
| 4039 | |
| 4040 | if (connector->connector_type != |
| 4041 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4042 | continue; |
| 4043 | |
| 4044 | if (connector->connector_type == |
| 4045 | DRM_MODE_CONNECTOR_DisplayPort && |
| 4046 | connector->status == connector_status_connected && |
| 4047 | connector->encoder != NULL) { |
| 4048 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4049 | status = kstrtoint(input_buffer, 10, &val); |
| 4050 | if (status < 0) |
| 4051 | goto out; |
| 4052 | DRM_DEBUG_DRIVER("Got %d for test active\n", val); |
| 4053 | /* To prevent erroneous activation of the compliance |
| 4054 | * testing code, only accept an actual value of 1 here |
| 4055 | */ |
| 4056 | if (val == 1) |
| 4057 | intel_dp->compliance_test_active = 1; |
| 4058 | else |
| 4059 | intel_dp->compliance_test_active = 0; |
| 4060 | } |
| 4061 | } |
| 4062 | out: |
| 4063 | kfree(input_buffer); |
| 4064 | if (status < 0) |
| 4065 | return status; |
| 4066 | |
| 4067 | *offp += len; |
| 4068 | return len; |
| 4069 | } |
| 4070 | |
| 4071 | static int i915_displayport_test_active_show(struct seq_file *m, void *data) |
| 4072 | { |
| 4073 | struct drm_device *dev = m->private; |
| 4074 | struct drm_connector *connector; |
| 4075 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4076 | struct intel_dp *intel_dp; |
| 4077 | |
| 4078 | if (!dev) |
| 4079 | return -ENODEV; |
| 4080 | |
| 4081 | list_for_each_entry(connector, connector_list, head) { |
| 4082 | |
| 4083 | if (connector->connector_type != |
| 4084 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4085 | continue; |
| 4086 | |
| 4087 | if (connector->status == connector_status_connected && |
| 4088 | connector->encoder != NULL) { |
| 4089 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4090 | if (intel_dp->compliance_test_active) |
| 4091 | seq_puts(m, "1"); |
| 4092 | else |
| 4093 | seq_puts(m, "0"); |
| 4094 | } else |
| 4095 | seq_puts(m, "0"); |
| 4096 | } |
| 4097 | |
| 4098 | return 0; |
| 4099 | } |
| 4100 | |
| 4101 | static int i915_displayport_test_active_open(struct inode *inode, |
| 4102 | struct file *file) |
| 4103 | { |
| 4104 | struct drm_device *dev = inode->i_private; |
| 4105 | |
| 4106 | return single_open(file, i915_displayport_test_active_show, dev); |
| 4107 | } |
| 4108 | |
| 4109 | static const struct file_operations i915_displayport_test_active_fops = { |
| 4110 | .owner = THIS_MODULE, |
| 4111 | .open = i915_displayport_test_active_open, |
| 4112 | .read = seq_read, |
| 4113 | .llseek = seq_lseek, |
| 4114 | .release = single_release, |
| 4115 | .write = i915_displayport_test_active_write |
| 4116 | }; |
| 4117 | |
| 4118 | static int i915_displayport_test_data_show(struct seq_file *m, void *data) |
| 4119 | { |
| 4120 | struct drm_device *dev = m->private; |
| 4121 | struct drm_connector *connector; |
| 4122 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4123 | struct intel_dp *intel_dp; |
| 4124 | |
| 4125 | if (!dev) |
| 4126 | return -ENODEV; |
| 4127 | |
| 4128 | list_for_each_entry(connector, connector_list, head) { |
| 4129 | |
| 4130 | if (connector->connector_type != |
| 4131 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4132 | continue; |
| 4133 | |
| 4134 | if (connector->status == connector_status_connected && |
| 4135 | connector->encoder != NULL) { |
| 4136 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4137 | seq_printf(m, "%lx", intel_dp->compliance_test_data); |
| 4138 | } else |
| 4139 | seq_puts(m, "0"); |
| 4140 | } |
| 4141 | |
| 4142 | return 0; |
| 4143 | } |
| 4144 | static int i915_displayport_test_data_open(struct inode *inode, |
| 4145 | struct file *file) |
| 4146 | { |
| 4147 | struct drm_device *dev = inode->i_private; |
| 4148 | |
| 4149 | return single_open(file, i915_displayport_test_data_show, dev); |
| 4150 | } |
| 4151 | |
| 4152 | static const struct file_operations i915_displayport_test_data_fops = { |
| 4153 | .owner = THIS_MODULE, |
| 4154 | .open = i915_displayport_test_data_open, |
| 4155 | .read = seq_read, |
| 4156 | .llseek = seq_lseek, |
| 4157 | .release = single_release |
| 4158 | }; |
| 4159 | |
| 4160 | static int i915_displayport_test_type_show(struct seq_file *m, void *data) |
| 4161 | { |
| 4162 | struct drm_device *dev = m->private; |
| 4163 | struct drm_connector *connector; |
| 4164 | struct list_head *connector_list = &dev->mode_config.connector_list; |
| 4165 | struct intel_dp *intel_dp; |
| 4166 | |
| 4167 | if (!dev) |
| 4168 | return -ENODEV; |
| 4169 | |
| 4170 | list_for_each_entry(connector, connector_list, head) { |
| 4171 | |
| 4172 | if (connector->connector_type != |
| 4173 | DRM_MODE_CONNECTOR_DisplayPort) |
| 4174 | continue; |
| 4175 | |
| 4176 | if (connector->status == connector_status_connected && |
| 4177 | connector->encoder != NULL) { |
| 4178 | intel_dp = enc_to_intel_dp(connector->encoder); |
| 4179 | seq_printf(m, "%02lx", intel_dp->compliance_test_type); |
| 4180 | } else |
| 4181 | seq_puts(m, "0"); |
| 4182 | } |
| 4183 | |
| 4184 | return 0; |
| 4185 | } |
| 4186 | |
| 4187 | static int i915_displayport_test_type_open(struct inode *inode, |
| 4188 | struct file *file) |
| 4189 | { |
| 4190 | struct drm_device *dev = inode->i_private; |
| 4191 | |
| 4192 | return single_open(file, i915_displayport_test_type_show, dev); |
| 4193 | } |
| 4194 | |
| 4195 | static const struct file_operations i915_displayport_test_type_fops = { |
| 4196 | .owner = THIS_MODULE, |
| 4197 | .open = i915_displayport_test_type_open, |
| 4198 | .read = seq_read, |
| 4199 | .llseek = seq_lseek, |
| 4200 | .release = single_release |
| 4201 | }; |
| 4202 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4203 | 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] | 4204 | { |
| 4205 | struct drm_device *dev = m->private; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 4206 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4207 | int level; |
| 4208 | |
| 4209 | drm_modeset_lock_all(dev); |
| 4210 | |
| 4211 | for (level = 0; level < num_levels; level++) { |
| 4212 | unsigned int latency = wm[level]; |
| 4213 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4214 | /* |
| 4215 | * - WM1+ latency values in 0.5us units |
| 4216 | * - latencies are in us on gen9 |
| 4217 | */ |
| 4218 | if (INTEL_INFO(dev)->gen >= 9) |
| 4219 | latency *= 10; |
| 4220 | else if (level > 0) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4221 | latency *= 5; |
| 4222 | |
| 4223 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4224 | level, wm[level], latency / 10, latency % 10); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4225 | } |
| 4226 | |
| 4227 | drm_modeset_unlock_all(dev); |
| 4228 | } |
| 4229 | |
| 4230 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 4231 | { |
| 4232 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4233 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4234 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4235 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4236 | if (INTEL_INFO(dev)->gen >= 9) |
| 4237 | latencies = dev_priv->wm.skl_latency; |
| 4238 | else |
| 4239 | latencies = to_i915(dev)->wm.pri_latency; |
| 4240 | |
| 4241 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4242 | |
| 4243 | return 0; |
| 4244 | } |
| 4245 | |
| 4246 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 4247 | { |
| 4248 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4249 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4250 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4251 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4252 | if (INTEL_INFO(dev)->gen >= 9) |
| 4253 | latencies = dev_priv->wm.skl_latency; |
| 4254 | else |
| 4255 | latencies = to_i915(dev)->wm.spr_latency; |
| 4256 | |
| 4257 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4258 | |
| 4259 | return 0; |
| 4260 | } |
| 4261 | |
| 4262 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 4263 | { |
| 4264 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4265 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4266 | const uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4267 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4268 | if (INTEL_INFO(dev)->gen >= 9) |
| 4269 | latencies = dev_priv->wm.skl_latency; |
| 4270 | else |
| 4271 | latencies = to_i915(dev)->wm.cur_latency; |
| 4272 | |
| 4273 | wm_latency_show(m, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4274 | |
| 4275 | return 0; |
| 4276 | } |
| 4277 | |
| 4278 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 4279 | { |
| 4280 | struct drm_device *dev = inode->i_private; |
| 4281 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4282 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4283 | return -ENODEV; |
| 4284 | |
| 4285 | return single_open(file, pri_wm_latency_show, dev); |
| 4286 | } |
| 4287 | |
| 4288 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 4289 | { |
| 4290 | struct drm_device *dev = inode->i_private; |
| 4291 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4292 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4293 | return -ENODEV; |
| 4294 | |
| 4295 | return single_open(file, spr_wm_latency_show, dev); |
| 4296 | } |
| 4297 | |
| 4298 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 4299 | { |
| 4300 | struct drm_device *dev = inode->i_private; |
| 4301 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 4302 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4303 | return -ENODEV; |
| 4304 | |
| 4305 | return single_open(file, cur_wm_latency_show, dev); |
| 4306 | } |
| 4307 | |
| 4308 | 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] | 4309 | size_t len, loff_t *offp, uint16_t wm[8]) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4310 | { |
| 4311 | struct seq_file *m = file->private_data; |
| 4312 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4313 | uint16_t new[8] = { 0 }; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 4314 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4315 | int level; |
| 4316 | int ret; |
| 4317 | char tmp[32]; |
| 4318 | |
| 4319 | if (len >= sizeof(tmp)) |
| 4320 | return -EINVAL; |
| 4321 | |
| 4322 | if (copy_from_user(tmp, ubuf, len)) |
| 4323 | return -EFAULT; |
| 4324 | |
| 4325 | tmp[len] = '\0'; |
| 4326 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4327 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu %hu %hu %hu", |
| 4328 | &new[0], &new[1], &new[2], &new[3], |
| 4329 | &new[4], &new[5], &new[6], &new[7]); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4330 | if (ret != num_levels) |
| 4331 | return -EINVAL; |
| 4332 | |
| 4333 | drm_modeset_lock_all(dev); |
| 4334 | |
| 4335 | for (level = 0; level < num_levels; level++) |
| 4336 | wm[level] = new[level]; |
| 4337 | |
| 4338 | drm_modeset_unlock_all(dev); |
| 4339 | |
| 4340 | return len; |
| 4341 | } |
| 4342 | |
| 4343 | |
| 4344 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4345 | size_t len, loff_t *offp) |
| 4346 | { |
| 4347 | struct seq_file *m = file->private_data; |
| 4348 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4349 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4350 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4351 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4352 | if (INTEL_INFO(dev)->gen >= 9) |
| 4353 | latencies = dev_priv->wm.skl_latency; |
| 4354 | else |
| 4355 | latencies = to_i915(dev)->wm.pri_latency; |
| 4356 | |
| 4357 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4358 | } |
| 4359 | |
| 4360 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4361 | size_t len, loff_t *offp) |
| 4362 | { |
| 4363 | struct seq_file *m = file->private_data; |
| 4364 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4365 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4366 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4367 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4368 | if (INTEL_INFO(dev)->gen >= 9) |
| 4369 | latencies = dev_priv->wm.skl_latency; |
| 4370 | else |
| 4371 | latencies = to_i915(dev)->wm.spr_latency; |
| 4372 | |
| 4373 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4374 | } |
| 4375 | |
| 4376 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 4377 | size_t len, loff_t *offp) |
| 4378 | { |
| 4379 | struct seq_file *m = file->private_data; |
| 4380 | struct drm_device *dev = m->private; |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4381 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4382 | uint16_t *latencies; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4383 | |
Damien Lespiau | 97e94b2 | 2014-11-04 17:06:50 +0000 | [diff] [blame] | 4384 | if (INTEL_INFO(dev)->gen >= 9) |
| 4385 | latencies = dev_priv->wm.skl_latency; |
| 4386 | else |
| 4387 | latencies = to_i915(dev)->wm.cur_latency; |
| 4388 | |
| 4389 | return wm_latency_write(file, ubuf, len, offp, latencies); |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4390 | } |
| 4391 | |
| 4392 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 4393 | .owner = THIS_MODULE, |
| 4394 | .open = pri_wm_latency_open, |
| 4395 | .read = seq_read, |
| 4396 | .llseek = seq_lseek, |
| 4397 | .release = single_release, |
| 4398 | .write = pri_wm_latency_write |
| 4399 | }; |
| 4400 | |
| 4401 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 4402 | .owner = THIS_MODULE, |
| 4403 | .open = spr_wm_latency_open, |
| 4404 | .read = seq_read, |
| 4405 | .llseek = seq_lseek, |
| 4406 | .release = single_release, |
| 4407 | .write = spr_wm_latency_write |
| 4408 | }; |
| 4409 | |
| 4410 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 4411 | .owner = THIS_MODULE, |
| 4412 | .open = cur_wm_latency_open, |
| 4413 | .read = seq_read, |
| 4414 | .llseek = seq_lseek, |
| 4415 | .release = single_release, |
| 4416 | .write = cur_wm_latency_write |
| 4417 | }; |
| 4418 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4419 | static int |
| 4420 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4421 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4422 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4423 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4424 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4425 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4426 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4427 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4428 | } |
| 4429 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4430 | static int |
| 4431 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4432 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4433 | struct drm_device *dev = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4434 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4435 | |
Mika Kuoppala | b8d24a0 | 2015-01-28 17:03:14 +0200 | [diff] [blame] | 4436 | /* |
| 4437 | * There is no safeguard against this debugfs entry colliding |
| 4438 | * with the hangcheck calling same i915_handle_error() in |
| 4439 | * parallel, causing an explosion. For now we assume that the |
| 4440 | * test harness is responsible enough not to inject gpu hangs |
| 4441 | * while it is writing to 'i915_wedged' |
| 4442 | */ |
| 4443 | |
| 4444 | if (i915_reset_in_progress(&dev_priv->gpu_error)) |
| 4445 | return -EAGAIN; |
| 4446 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4447 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4448 | |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 4449 | i915_handle_error(dev, val, |
| 4450 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 4451 | |
| 4452 | intel_runtime_pm_put(dev_priv); |
| 4453 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4454 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4455 | } |
| 4456 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4457 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 4458 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4459 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4460 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4461 | static int |
| 4462 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4463 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4464 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4465 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4466 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4467 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4468 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4469 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4470 | } |
| 4471 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4472 | static int |
| 4473 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4474 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4475 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4476 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4477 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4478 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4479 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4480 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4481 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4482 | if (ret) |
| 4483 | return ret; |
| 4484 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 4485 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4486 | mutex_unlock(&dev->struct_mutex); |
| 4487 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4488 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 4489 | } |
| 4490 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4491 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 4492 | i915_ring_stop_get, i915_ring_stop_set, |
| 4493 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 4494 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4495 | static int |
| 4496 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 4497 | { |
| 4498 | struct drm_device *dev = data; |
| 4499 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4500 | |
| 4501 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 4502 | return 0; |
| 4503 | } |
| 4504 | |
| 4505 | static int |
| 4506 | i915_ring_missed_irq_set(void *data, u64 val) |
| 4507 | { |
| 4508 | struct drm_device *dev = data; |
| 4509 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4510 | int ret; |
| 4511 | |
| 4512 | /* Lock against concurrent debugfs callers */ |
| 4513 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4514 | if (ret) |
| 4515 | return ret; |
| 4516 | dev_priv->gpu_error.missed_irq_rings = val; |
| 4517 | mutex_unlock(&dev->struct_mutex); |
| 4518 | |
| 4519 | return 0; |
| 4520 | } |
| 4521 | |
| 4522 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 4523 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 4524 | "0x%08llx\n"); |
| 4525 | |
| 4526 | static int |
| 4527 | i915_ring_test_irq_get(void *data, u64 *val) |
| 4528 | { |
| 4529 | struct drm_device *dev = data; |
| 4530 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4531 | |
| 4532 | *val = dev_priv->gpu_error.test_irq_rings; |
| 4533 | |
| 4534 | return 0; |
| 4535 | } |
| 4536 | |
| 4537 | static int |
| 4538 | i915_ring_test_irq_set(void *data, u64 val) |
| 4539 | { |
| 4540 | struct drm_device *dev = data; |
| 4541 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4542 | int ret; |
| 4543 | |
| 4544 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 4545 | |
| 4546 | /* Lock against concurrent debugfs callers */ |
| 4547 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4548 | if (ret) |
| 4549 | return ret; |
| 4550 | |
| 4551 | dev_priv->gpu_error.test_irq_rings = val; |
| 4552 | mutex_unlock(&dev->struct_mutex); |
| 4553 | |
| 4554 | return 0; |
| 4555 | } |
| 4556 | |
| 4557 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 4558 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 4559 | "0x%08llx\n"); |
| 4560 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4561 | #define DROP_UNBOUND 0x1 |
| 4562 | #define DROP_BOUND 0x2 |
| 4563 | #define DROP_RETIRE 0x4 |
| 4564 | #define DROP_ACTIVE 0x8 |
| 4565 | #define DROP_ALL (DROP_UNBOUND | \ |
| 4566 | DROP_BOUND | \ |
| 4567 | DROP_RETIRE | \ |
| 4568 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4569 | static int |
| 4570 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4571 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4572 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4573 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4574 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4575 | } |
| 4576 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4577 | static int |
| 4578 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4579 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4580 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4581 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4582 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4583 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 4584 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4585 | |
| 4586 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 4587 | * on ioctls on -EAGAIN. */ |
| 4588 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4589 | if (ret) |
| 4590 | return ret; |
| 4591 | |
| 4592 | if (val & DROP_ACTIVE) { |
| 4593 | ret = i915_gpu_idle(dev); |
| 4594 | if (ret) |
| 4595 | goto unlock; |
| 4596 | } |
| 4597 | |
| 4598 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 4599 | i915_gem_retire_requests(dev); |
| 4600 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4601 | if (val & DROP_BOUND) |
| 4602 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); |
Chris Wilson | 4ad72b7 | 2014-09-03 19:23:37 +0100 | [diff] [blame] | 4603 | |
Chris Wilson | 21ab4e7 | 2014-09-09 11:16:08 +0100 | [diff] [blame] | 4604 | if (val & DROP_UNBOUND) |
| 4605 | i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_UNBOUND); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4606 | |
| 4607 | unlock: |
| 4608 | mutex_unlock(&dev->struct_mutex); |
| 4609 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4610 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4611 | } |
| 4612 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4613 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 4614 | i915_drop_caches_get, i915_drop_caches_set, |
| 4615 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 4616 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4617 | static int |
| 4618 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4619 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4620 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4621 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4622 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4623 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4624 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4625 | return -ENODEV; |
| 4626 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4627 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4628 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4629 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4630 | if (ret) |
| 4631 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4632 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4633 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4634 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4635 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4636 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4637 | } |
| 4638 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4639 | static int |
| 4640 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4641 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4642 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4643 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4644 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4645 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4646 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4647 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4648 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4649 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4650 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4651 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4652 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4653 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4654 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4655 | if (ret) |
| 4656 | return ret; |
| 4657 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4658 | /* |
| 4659 | * Turbo will still be enabled, but won't go above the set value. |
| 4660 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4661 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4662 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4663 | hw_max = dev_priv->rps.max_freq; |
| 4664 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 4665 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4666 | 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] | 4667 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4668 | return -EINVAL; |
| 4669 | } |
| 4670 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4671 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4672 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4673 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4674 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4675 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4676 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4677 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4678 | } |
| 4679 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4680 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 4681 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4682 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4683 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4684 | static int |
| 4685 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4686 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4687 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4688 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4689 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4690 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4691 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4692 | return -ENODEV; |
| 4693 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4694 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4695 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4696 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4697 | if (ret) |
| 4698 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4699 | |
Ville Syrjälä | 7c59a9c1 | 2015-01-23 21:04:26 +0200 | [diff] [blame] | 4700 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4701 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4702 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4703 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4704 | } |
| 4705 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4706 | static int |
| 4707 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4708 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4709 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4710 | struct drm_i915_private *dev_priv = dev->dev_private; |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4711 | u32 hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4712 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4713 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 4714 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4715 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4716 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 4717 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 4718 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4719 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4720 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4721 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4722 | if (ret) |
| 4723 | return ret; |
| 4724 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4725 | /* |
| 4726 | * Turbo will still be enabled, but won't go below the set value. |
| 4727 | */ |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4728 | val = intel_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4729 | |
Akash Goel | bc4d91f | 2015-02-26 16:09:47 +0530 | [diff] [blame] | 4730 | hw_max = dev_priv->rps.max_freq; |
| 4731 | hw_min = dev_priv->rps.min_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4732 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4733 | 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] | 4734 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 4735 | return -EINVAL; |
| 4736 | } |
| 4737 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 4738 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4739 | |
Ville Syrjälä | ffe02b4 | 2015-02-02 19:09:50 +0200 | [diff] [blame] | 4740 | intel_set_rps(dev, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 4741 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 4742 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4743 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4744 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4745 | } |
| 4746 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4747 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 4748 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 4749 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 4750 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4751 | static int |
| 4752 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4753 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4754 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 4755 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4756 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4757 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4758 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4759 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4760 | return -ENODEV; |
| 4761 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4762 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4763 | if (ret) |
| 4764 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4765 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4766 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4767 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4768 | |
| 4769 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4770 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 4771 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4772 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4773 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4774 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4775 | } |
| 4776 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4777 | static int |
| 4778 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4779 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4780 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4781 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4782 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4783 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4784 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4785 | return -ENODEV; |
| 4786 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4787 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4788 | return -EINVAL; |
| 4789 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4790 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4791 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4792 | |
| 4793 | /* Update the cache sharing policy here as well */ |
| 4794 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4795 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4796 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4797 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4798 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4799 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4800 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4801 | } |
| 4802 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4803 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4804 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4805 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4806 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4807 | struct sseu_dev_status { |
| 4808 | unsigned int slice_total; |
| 4809 | unsigned int subslice_total; |
| 4810 | unsigned int subslice_per_slice; |
| 4811 | unsigned int eu_total; |
| 4812 | unsigned int eu_per_subslice; |
| 4813 | }; |
| 4814 | |
| 4815 | static void cherryview_sseu_device_status(struct drm_device *dev, |
| 4816 | struct sseu_dev_status *stat) |
| 4817 | { |
| 4818 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4819 | const int ss_max = 2; |
| 4820 | int ss; |
| 4821 | u32 sig1[ss_max], sig2[ss_max]; |
| 4822 | |
| 4823 | sig1[0] = I915_READ(CHV_POWER_SS0_SIG1); |
| 4824 | sig1[1] = I915_READ(CHV_POWER_SS1_SIG1); |
| 4825 | sig2[0] = I915_READ(CHV_POWER_SS0_SIG2); |
| 4826 | sig2[1] = I915_READ(CHV_POWER_SS1_SIG2); |
| 4827 | |
| 4828 | for (ss = 0; ss < ss_max; ss++) { |
| 4829 | unsigned int eu_cnt; |
| 4830 | |
| 4831 | if (sig1[ss] & CHV_SS_PG_ENABLE) |
| 4832 | /* skip disabled subslice */ |
| 4833 | continue; |
| 4834 | |
| 4835 | stat->slice_total = 1; |
| 4836 | stat->subslice_per_slice++; |
| 4837 | eu_cnt = ((sig1[ss] & CHV_EU08_PG_ENABLE) ? 0 : 2) + |
| 4838 | ((sig1[ss] & CHV_EU19_PG_ENABLE) ? 0 : 2) + |
| 4839 | ((sig1[ss] & CHV_EU210_PG_ENABLE) ? 0 : 2) + |
| 4840 | ((sig2[ss] & CHV_EU311_PG_ENABLE) ? 0 : 2); |
| 4841 | stat->eu_total += eu_cnt; |
| 4842 | stat->eu_per_subslice = max(stat->eu_per_subslice, eu_cnt); |
| 4843 | } |
| 4844 | stat->subslice_total = stat->subslice_per_slice; |
| 4845 | } |
| 4846 | |
| 4847 | static void gen9_sseu_device_status(struct drm_device *dev, |
| 4848 | struct sseu_dev_status *stat) |
| 4849 | { |
| 4850 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4851 | int s_max = 3, ss_max = 4; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4852 | int s, ss; |
| 4853 | u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2]; |
| 4854 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4855 | /* BXT has a single slice and at most 3 subslices. */ |
| 4856 | if (IS_BROXTON(dev)) { |
| 4857 | s_max = 1; |
| 4858 | ss_max = 3; |
| 4859 | } |
| 4860 | |
| 4861 | for (s = 0; s < s_max; s++) { |
| 4862 | s_reg[s] = I915_READ(GEN9_SLICE_PGCTL_ACK(s)); |
| 4863 | eu_reg[2*s] = I915_READ(GEN9_SS01_EU_PGCTL_ACK(s)); |
| 4864 | eu_reg[2*s + 1] = I915_READ(GEN9_SS23_EU_PGCTL_ACK(s)); |
| 4865 | } |
| 4866 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4867 | eu_mask[0] = GEN9_PGCTL_SSA_EU08_ACK | |
| 4868 | GEN9_PGCTL_SSA_EU19_ACK | |
| 4869 | GEN9_PGCTL_SSA_EU210_ACK | |
| 4870 | GEN9_PGCTL_SSA_EU311_ACK; |
| 4871 | eu_mask[1] = GEN9_PGCTL_SSB_EU08_ACK | |
| 4872 | GEN9_PGCTL_SSB_EU19_ACK | |
| 4873 | GEN9_PGCTL_SSB_EU210_ACK | |
| 4874 | GEN9_PGCTL_SSB_EU311_ACK; |
| 4875 | |
| 4876 | for (s = 0; s < s_max; s++) { |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4877 | unsigned int ss_cnt = 0; |
| 4878 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4879 | if ((s_reg[s] & GEN9_PGCTL_SLICE_ACK) == 0) |
| 4880 | /* skip disabled slice */ |
| 4881 | continue; |
| 4882 | |
| 4883 | stat->slice_total++; |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4884 | |
| 4885 | if (IS_SKYLAKE(dev)) |
| 4886 | ss_cnt = INTEL_INFO(dev)->subslice_per_slice; |
| 4887 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4888 | for (ss = 0; ss < ss_max; ss++) { |
| 4889 | unsigned int eu_cnt; |
| 4890 | |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4891 | if (IS_BROXTON(dev) && |
| 4892 | !(s_reg[s] & (GEN9_PGCTL_SS_ACK(ss)))) |
| 4893 | /* skip disabled subslice */ |
| 4894 | continue; |
| 4895 | |
| 4896 | if (IS_BROXTON(dev)) |
| 4897 | ss_cnt++; |
| 4898 | |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4899 | eu_cnt = 2 * hweight32(eu_reg[2*s + ss/2] & |
| 4900 | eu_mask[ss%2]); |
| 4901 | stat->eu_total += eu_cnt; |
| 4902 | stat->eu_per_subslice = max(stat->eu_per_subslice, |
| 4903 | eu_cnt); |
| 4904 | } |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4905 | |
| 4906 | stat->subslice_total += ss_cnt; |
| 4907 | stat->subslice_per_slice = max(stat->subslice_per_slice, |
| 4908 | ss_cnt); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4909 | } |
| 4910 | } |
| 4911 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4912 | static int i915_sseu_status(struct seq_file *m, void *unused) |
| 4913 | { |
| 4914 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 4915 | struct drm_device *dev = node->minor->dev; |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4916 | struct sseu_dev_status stat; |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4917 | |
Jeff McGee | 5575f03 | 2015-02-27 10:22:32 -0800 | [diff] [blame] | 4918 | if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev)) |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4919 | return -ENODEV; |
| 4920 | |
| 4921 | seq_puts(m, "SSEU Device Info\n"); |
| 4922 | seq_printf(m, " Available Slice Total: %u\n", |
| 4923 | INTEL_INFO(dev)->slice_total); |
| 4924 | seq_printf(m, " Available Subslice Total: %u\n", |
| 4925 | INTEL_INFO(dev)->subslice_total); |
| 4926 | seq_printf(m, " Available Subslice Per Slice: %u\n", |
| 4927 | INTEL_INFO(dev)->subslice_per_slice); |
| 4928 | seq_printf(m, " Available EU Total: %u\n", |
| 4929 | INTEL_INFO(dev)->eu_total); |
| 4930 | seq_printf(m, " Available EU Per Subslice: %u\n", |
| 4931 | INTEL_INFO(dev)->eu_per_subslice); |
| 4932 | seq_printf(m, " Has Slice Power Gating: %s\n", |
| 4933 | yesno(INTEL_INFO(dev)->has_slice_pg)); |
| 4934 | seq_printf(m, " Has Subslice Power Gating: %s\n", |
| 4935 | yesno(INTEL_INFO(dev)->has_subslice_pg)); |
| 4936 | seq_printf(m, " Has EU Power Gating: %s\n", |
| 4937 | yesno(INTEL_INFO(dev)->has_eu_pg)); |
| 4938 | |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4939 | seq_puts(m, "SSEU Device Status\n"); |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4940 | memset(&stat, 0, sizeof(stat)); |
Jeff McGee | 5575f03 | 2015-02-27 10:22:32 -0800 | [diff] [blame] | 4941 | if (IS_CHERRYVIEW(dev)) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4942 | cherryview_sseu_device_status(dev, &stat); |
Jeff McGee | 1c046bc | 2015-04-03 18:13:18 -0700 | [diff] [blame] | 4943 | } else if (INTEL_INFO(dev)->gen >= 9) { |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4944 | gen9_sseu_device_status(dev, &stat); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4945 | } |
Jeff McGee | 5d39525 | 2015-04-03 18:13:17 -0700 | [diff] [blame] | 4946 | seq_printf(m, " Enabled Slice Total: %u\n", |
| 4947 | stat.slice_total); |
| 4948 | seq_printf(m, " Enabled Subslice Total: %u\n", |
| 4949 | stat.subslice_total); |
| 4950 | seq_printf(m, " Enabled Subslice Per Slice: %u\n", |
| 4951 | stat.subslice_per_slice); |
| 4952 | seq_printf(m, " Enabled EU Total: %u\n", |
| 4953 | stat.eu_total); |
| 4954 | seq_printf(m, " Enabled EU Per Subslice: %u\n", |
| 4955 | stat.eu_per_subslice); |
Jeff McGee | 7f992ab | 2015-02-13 10:27:55 -0600 | [diff] [blame] | 4956 | |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 4957 | return 0; |
| 4958 | } |
| 4959 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4960 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4961 | { |
| 4962 | struct drm_device *dev = inode->i_private; |
| 4963 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4964 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4965 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4966 | return 0; |
| 4967 | |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4968 | intel_runtime_pm_get(dev_priv); |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4969 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4970 | |
| 4971 | return 0; |
| 4972 | } |
| 4973 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4974 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4975 | { |
| 4976 | struct drm_device *dev = inode->i_private; |
| 4977 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4978 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4979 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4980 | return 0; |
| 4981 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 4982 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Chris Wilson | 6daccb0 | 2015-01-16 11:34:35 +0200 | [diff] [blame] | 4983 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4984 | |
| 4985 | return 0; |
| 4986 | } |
| 4987 | |
| 4988 | static const struct file_operations i915_forcewake_fops = { |
| 4989 | .owner = THIS_MODULE, |
| 4990 | .open = i915_forcewake_open, |
| 4991 | .release = i915_forcewake_release, |
| 4992 | }; |
| 4993 | |
| 4994 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 4995 | { |
| 4996 | struct drm_device *dev = minor->dev; |
| 4997 | struct dentry *ent; |
| 4998 | |
| 4999 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5000 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5001 | root, dev, |
| 5002 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5003 | if (!ent) |
| 5004 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5005 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 5006 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5007 | } |
| 5008 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5009 | static int i915_debugfs_create(struct dentry *root, |
| 5010 | struct drm_minor *minor, |
| 5011 | const char *name, |
| 5012 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5013 | { |
| 5014 | struct drm_device *dev = minor->dev; |
| 5015 | struct dentry *ent; |
| 5016 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5017 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5018 | S_IRUGO | S_IWUSR, |
| 5019 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5020 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 5021 | if (!ent) |
| 5022 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 5023 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5024 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 5025 | } |
| 5026 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5027 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 5028 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 5029 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 5030 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 5031 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5032 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 5033 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b8885 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 5034 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 5035 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5036 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 5037 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 5038 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5039 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 5040 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 5041 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 5042 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 5043 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Brad Volkin | 493018d | 2014-12-11 12:13:08 -0800 | [diff] [blame] | 5044 | {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 5045 | {"i915_frequency_info", i915_frequency_info, 0}, |
Chris Wilson | f654449 | 2015-01-26 18:03:04 +0200 | [diff] [blame] | 5046 | {"i915_hangcheck_info", i915_hangcheck_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 5047 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 5048 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 5049 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Daniel Vetter | 9a85178 | 2015-06-18 10:30:22 +0200 | [diff] [blame] | 5050 | {"i915_frontbuffer_tracking", i915_frontbuffer_tracking, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 5051 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 5052 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 5053 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 5054 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 5055 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 5056 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae9 | 2014-08-07 13:24:26 +0100 | [diff] [blame] | 5057 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 5058 | {"i915_execlists", i915_execlists, 0}, |
Mika Kuoppala | f65367b | 2015-01-16 11:34:42 +0200 | [diff] [blame] | 5059 | {"i915_forcewake_domains", i915_forcewake_domains, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 5060 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 5061 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 5062 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 5063 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 5064 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 5065 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Damien Lespiau | 6455c87 | 2015-06-04 18:23:57 +0100 | [diff] [blame] | 5066 | {"i915_runtime_pm_status", i915_runtime_pm_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 5067 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 5068 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 5069 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 5070 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed95 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 5071 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Damien Lespiau | 1ed1ef9 | 2014-08-30 16:50:59 +0100 | [diff] [blame] | 5072 | {"i915_wa_registers", i915_wa_registers, 0}, |
Damien Lespiau | c5511e4 | 2014-11-04 17:06:51 +0000 | [diff] [blame] | 5073 | {"i915_ddb_info", i915_ddb_info, 0}, |
Jeff McGee | 3873218 | 2015-02-13 10:27:54 -0600 | [diff] [blame] | 5074 | {"i915_sseu_status", i915_sseu_status, 0}, |
Vandana Kannan | a54746e | 2015-03-03 20:53:10 +0530 | [diff] [blame] | 5075 | {"i915_drrs_status", i915_drrs_status, 0}, |
Chris Wilson | 1854d5c | 2015-04-07 16:20:32 +0100 | [diff] [blame] | 5076 | {"i915_rps_boost_info", i915_rps_boost_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5077 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5078 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5079 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 5080 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5081 | const char *name; |
| 5082 | const struct file_operations *fops; |
| 5083 | } i915_debugfs_files[] = { |
| 5084 | {"i915_wedged", &i915_wedged_fops}, |
| 5085 | {"i915_max_freq", &i915_max_freq_fops}, |
| 5086 | {"i915_min_freq", &i915_min_freq_fops}, |
| 5087 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 5088 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 5089 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 5090 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5091 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 5092 | {"i915_error_state", &i915_error_state_fops}, |
| 5093 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 5094 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 5095 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 5096 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 5097 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 5098 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Todd Previte | eb3394fa | 2015-04-18 00:04:19 -0700 | [diff] [blame] | 5099 | {"i915_dp_test_data", &i915_displayport_test_data_fops}, |
| 5100 | {"i915_dp_test_type", &i915_displayport_test_type_fops}, |
| 5101 | {"i915_dp_test_active", &i915_displayport_test_active_fops} |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5102 | }; |
| 5103 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5104 | void intel_display_crc_init(struct drm_device *dev) |
| 5105 | { |
| 5106 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5107 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5108 | |
Damien Lespiau | 055e393 | 2014-08-18 13:49:10 +0100 | [diff] [blame] | 5109 | for_each_pipe(dev_priv, pipe) { |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 5110 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5111 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 5112 | pipe_crc->opened = false; |
| 5113 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5114 | init_waitqueue_head(&pipe_crc->wq); |
| 5115 | } |
| 5116 | } |
| 5117 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5118 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5119 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5120 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 5121 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5122 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 5123 | if (ret) |
| 5124 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 5125 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5126 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 5127 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 5128 | if (ret) |
| 5129 | return ret; |
| 5130 | } |
| 5131 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5132 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5133 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 5134 | i915_debugfs_files[i].name, |
| 5135 | i915_debugfs_files[i].fops); |
| 5136 | if (ret) |
| 5137 | return ret; |
| 5138 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 5139 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5140 | return drm_debugfs_create_files(i915_debugfs_list, |
| 5141 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5142 | minor->debugfs_root, minor); |
| 5143 | } |
| 5144 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5145 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5146 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5147 | int i; |
| 5148 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 5149 | drm_debugfs_remove_files(i915_debugfs_list, |
| 5150 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5151 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 5152 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 5153 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5154 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 5155 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 5156 | struct drm_info_list *info_list = |
| 5157 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 5158 | |
| 5159 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5160 | } |
| 5161 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 5162 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 5163 | struct drm_info_list *info_list = |
| 5164 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 5165 | |
| 5166 | drm_debugfs_remove_files(info_list, 1, minor); |
| 5167 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 5168 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5169 | |
| 5170 | struct dpcd_block { |
| 5171 | /* DPCD dump start address. */ |
| 5172 | unsigned int offset; |
| 5173 | /* DPCD dump end address, inclusive. If unset, .size will be used. */ |
| 5174 | unsigned int end; |
| 5175 | /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */ |
| 5176 | size_t size; |
| 5177 | /* Only valid for eDP. */ |
| 5178 | bool edp; |
| 5179 | }; |
| 5180 | |
| 5181 | static const struct dpcd_block i915_dpcd_debug[] = { |
| 5182 | { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE }, |
| 5183 | { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS }, |
| 5184 | { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 }, |
| 5185 | { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET }, |
| 5186 | { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 }, |
| 5187 | { .offset = DP_SET_POWER }, |
| 5188 | { .offset = DP_EDP_DPCD_REV }, |
| 5189 | { .offset = DP_EDP_GENERAL_CAP_1, .end = DP_EDP_GENERAL_CAP_3 }, |
| 5190 | { .offset = DP_EDP_DISPLAY_CONTROL_REGISTER, .end = DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB }, |
| 5191 | { .offset = DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET, .end = DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET }, |
| 5192 | }; |
| 5193 | |
| 5194 | static int i915_dpcd_show(struct seq_file *m, void *data) |
| 5195 | { |
| 5196 | struct drm_connector *connector = m->private; |
| 5197 | struct intel_dp *intel_dp = |
| 5198 | enc_to_intel_dp(&intel_attached_encoder(connector)->base); |
| 5199 | uint8_t buf[16]; |
| 5200 | ssize_t err; |
| 5201 | int i; |
| 5202 | |
Mika Kuoppala | 5c1a887 | 2015-05-15 13:09:21 +0300 | [diff] [blame] | 5203 | if (connector->status != connector_status_connected) |
| 5204 | return -ENODEV; |
| 5205 | |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5206 | for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) { |
| 5207 | const struct dpcd_block *b = &i915_dpcd_debug[i]; |
| 5208 | size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1); |
| 5209 | |
| 5210 | if (b->edp && |
| 5211 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
| 5212 | continue; |
| 5213 | |
| 5214 | /* low tech for now */ |
| 5215 | if (WARN_ON(size > sizeof(buf))) |
| 5216 | continue; |
| 5217 | |
| 5218 | err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size); |
| 5219 | if (err <= 0) { |
| 5220 | DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n", |
| 5221 | size, b->offset, err); |
| 5222 | continue; |
| 5223 | } |
| 5224 | |
| 5225 | seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf); |
kbuild test robot | b3f9d7d | 2015-04-16 18:34:06 +0800 | [diff] [blame] | 5226 | } |
Jani Nikula | aa7471d | 2015-04-01 11:15:21 +0300 | [diff] [blame] | 5227 | |
| 5228 | return 0; |
| 5229 | } |
| 5230 | |
| 5231 | static int i915_dpcd_open(struct inode *inode, struct file *file) |
| 5232 | { |
| 5233 | return single_open(file, i915_dpcd_show, inode->i_private); |
| 5234 | } |
| 5235 | |
| 5236 | static const struct file_operations i915_dpcd_fops = { |
| 5237 | .owner = THIS_MODULE, |
| 5238 | .open = i915_dpcd_open, |
| 5239 | .read = seq_read, |
| 5240 | .llseek = seq_lseek, |
| 5241 | .release = single_release, |
| 5242 | }; |
| 5243 | |
| 5244 | /** |
| 5245 | * i915_debugfs_connector_add - add i915 specific connector debugfs files |
| 5246 | * @connector: pointer to a registered drm_connector |
| 5247 | * |
| 5248 | * Cleanup will be done by drm_connector_unregister() through a call to |
| 5249 | * drm_debugfs_connector_remove(). |
| 5250 | * |
| 5251 | * Returns 0 on success, negative error codes on error. |
| 5252 | */ |
| 5253 | int i915_debugfs_connector_add(struct drm_connector *connector) |
| 5254 | { |
| 5255 | struct dentry *root = connector->debugfs_entry; |
| 5256 | |
| 5257 | /* The connector must have been registered beforehands. */ |
| 5258 | if (!root) |
| 5259 | return -ENODEV; |
| 5260 | |
| 5261 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 5262 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 5263 | debugfs_create_file("i915_dpcd", S_IRUGO, root, connector, |
| 5264 | &i915_dpcd_fops); |
| 5265 | |
| 5266 | return 0; |
| 5267 | } |