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 | 6d2b888 | 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 | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 99 | if (obj->user_pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 100 | return "P"; |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 101 | else if (i915_gem_obj_is_pinned(obj)) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 102 | return "p"; |
| 103 | else |
| 104 | return " "; |
| 105 | } |
| 106 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 107 | static const char *get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 108 | { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 109 | switch (obj->tiling_mode) { |
| 110 | default: |
| 111 | case I915_TILING_NONE: return " "; |
| 112 | case I915_TILING_X: return "X"; |
| 113 | case I915_TILING_Y: return "Y"; |
| 114 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 115 | } |
| 116 | |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 117 | static inline const char *get_global_flag(struct drm_i915_gem_object *obj) |
| 118 | { |
| 119 | return obj->has_global_gtt_mapping ? "g" : " "; |
| 120 | } |
| 121 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 122 | static void |
| 123 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 124 | { |
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; |
| 127 | |
Ville Syrjälä | fb1ae91 | 2013-08-22 19:21:30 +0300 | [diff] [blame] | 128 | seq_printf(m, "%pK: %s%s%s %8zdKiB %02x %02x %u %u %u%s%s%s", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 129 | &obj->base, |
| 130 | get_pin_flag(obj), |
| 131 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 132 | get_global_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 133 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 134 | obj->base.read_domains, |
| 135 | obj->base.write_domain, |
Chris Wilson | 0201f1e | 2012-07-20 12:41:01 +0100 | [diff] [blame] | 136 | obj->last_read_seqno, |
| 137 | obj->last_write_seqno, |
Chris Wilson | caea747 | 2010-11-12 13:53:37 +0000 | [diff] [blame] | 138 | obj->last_fenced_seqno, |
Mika Kuoppala | 84734a0 | 2013-07-12 16:50:57 +0300 | [diff] [blame] | 139 | i915_cache_level_str(obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 140 | obj->dirty ? " dirty" : "", |
| 141 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 142 | if (obj->base.name) |
| 143 | seq_printf(m, " (name: %d)", obj->base.name); |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 144 | list_for_each_entry(vma, &obj->vma_list, vma_link) |
| 145 | if (vma->pin_count > 0) |
| 146 | pin_count++; |
| 147 | seq_printf(m, " (pinned x %d)", pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 148 | if (obj->pin_display) |
| 149 | seq_printf(m, " (display)"); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 150 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 151 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 152 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 153 | if (!i915_is_ggtt(vma->vm)) |
| 154 | seq_puts(m, " (pp"); |
| 155 | else |
| 156 | seq_puts(m, " (g"); |
| 157 | seq_printf(m, "gtt offset: %08lx, size: %08lx)", |
| 158 | vma->node.start, vma->node.size); |
| 159 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 160 | if (obj->stolen) |
| 161 | seq_printf(m, " (stolen: %08lx)", obj->stolen->start); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 162 | if (obj->pin_mappable || obj->fault_mappable) { |
| 163 | char s[3], *t = s; |
| 164 | if (obj->pin_mappable) |
| 165 | *t++ = 'p'; |
| 166 | if (obj->fault_mappable) |
| 167 | *t++ = 'f'; |
| 168 | *t = '\0'; |
| 169 | seq_printf(m, " (%s mappable)", s); |
| 170 | } |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 171 | if (obj->ring != NULL) |
| 172 | seq_printf(m, " (%s)", obj->ring->name); |
Daniel Vetter | d5a81ef | 2014-06-18 14:46:49 +0200 | [diff] [blame] | 173 | if (obj->frontbuffer_bits) |
| 174 | seq_printf(m, " (frontbuffer: 0x%03x)", obj->frontbuffer_bits); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 175 | } |
| 176 | |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 177 | static void describe_ctx(struct seq_file *m, struct intel_context *ctx) |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 178 | { |
Oscar Mateo | ea0c76f | 2014-07-03 16:27:59 +0100 | [diff] [blame] | 179 | seq_putc(m, ctx->legacy_hw_ctx.initialized ? 'I' : 'i'); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 180 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 181 | seq_putc(m, ' '); |
| 182 | } |
| 183 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 184 | 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] | 185 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 186 | struct drm_info_node *node = m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 187 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 188 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 189 | struct drm_device *dev = node->minor->dev; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 190 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 191 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 192 | struct i915_vma *vma; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 193 | size_t total_obj_size, total_gtt_size; |
| 194 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 195 | |
| 196 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 197 | if (ret) |
| 198 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 199 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 200 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 201 | switch (list) { |
| 202 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 203 | seq_puts(m, "Active:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 204 | head = &vm->active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 205 | break; |
| 206 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 207 | seq_puts(m, "Inactive:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 208 | head = &vm->inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 209 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 210 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 211 | mutex_unlock(&dev->struct_mutex); |
| 212 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 213 | } |
| 214 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 215 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 216 | list_for_each_entry(vma, head, mm_list) { |
| 217 | seq_printf(m, " "); |
| 218 | describe_obj(m, vma->obj); |
| 219 | seq_printf(m, "\n"); |
| 220 | total_obj_size += vma->obj->base.size; |
| 221 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 222 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 223 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 224 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 225 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 226 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 227 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 228 | return 0; |
| 229 | } |
| 230 | |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 231 | static int obj_rank_by_stolen(void *priv, |
| 232 | struct list_head *A, struct list_head *B) |
| 233 | { |
| 234 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 235 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 236 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 237 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 238 | |
| 239 | return a->stolen->start - b->stolen->start; |
| 240 | } |
| 241 | |
| 242 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 243 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 244 | struct drm_info_node *node = m->private; |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 245 | struct drm_device *dev = node->minor->dev; |
| 246 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 247 | struct drm_i915_gem_object *obj; |
| 248 | size_t total_obj_size, total_gtt_size; |
| 249 | LIST_HEAD(stolen); |
| 250 | int count, ret; |
| 251 | |
| 252 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 253 | if (ret) |
| 254 | return ret; |
| 255 | |
| 256 | total_obj_size = total_gtt_size = count = 0; |
| 257 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 258 | if (obj->stolen == NULL) |
| 259 | continue; |
| 260 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 261 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 262 | |
| 263 | total_obj_size += obj->base.size; |
| 264 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
| 265 | count++; |
| 266 | } |
| 267 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 268 | if (obj->stolen == NULL) |
| 269 | continue; |
| 270 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 271 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 272 | |
| 273 | total_obj_size += obj->base.size; |
| 274 | count++; |
| 275 | } |
| 276 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 277 | seq_puts(m, "Stolen:\n"); |
| 278 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 279 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 280 | seq_puts(m, " "); |
| 281 | describe_obj(m, obj); |
| 282 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 283 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 284 | } |
| 285 | mutex_unlock(&dev->struct_mutex); |
| 286 | |
| 287 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 288 | count, total_obj_size, total_gtt_size); |
| 289 | return 0; |
| 290 | } |
| 291 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 292 | #define count_objects(list, member) do { \ |
| 293 | list_for_each_entry(obj, list, member) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 294 | size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 295 | ++count; \ |
| 296 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 297 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 298 | ++mappable_count; \ |
| 299 | } \ |
| 300 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 301 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 302 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 303 | struct file_stats { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 304 | struct drm_i915_file_private *file_priv; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 305 | int count; |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 306 | size_t total, unbound; |
| 307 | size_t global, shared; |
| 308 | size_t active, inactive; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 309 | }; |
| 310 | |
| 311 | static int per_file_stats(int id, void *ptr, void *data) |
| 312 | { |
| 313 | struct drm_i915_gem_object *obj = ptr; |
| 314 | struct file_stats *stats = data; |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 315 | struct i915_vma *vma; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 316 | |
| 317 | stats->count++; |
| 318 | stats->total += obj->base.size; |
| 319 | |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 320 | if (obj->base.name || obj->base.dma_buf) |
| 321 | stats->shared += obj->base.size; |
| 322 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 323 | if (USES_FULL_PPGTT(obj->base.dev)) { |
| 324 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 325 | struct i915_hw_ppgtt *ppgtt; |
| 326 | |
| 327 | if (!drm_mm_node_allocated(&vma->node)) |
| 328 | continue; |
| 329 | |
| 330 | if (i915_is_ggtt(vma->vm)) { |
| 331 | stats->global += obj->base.size; |
| 332 | continue; |
| 333 | } |
| 334 | |
| 335 | ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base); |
Daniel Vetter | 4d88470 | 2014-08-06 15:04:47 +0200 | [diff] [blame] | 336 | if (ppgtt->file_priv != stats->file_priv) |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 337 | continue; |
| 338 | |
| 339 | if (obj->ring) /* XXX per-vma statistic */ |
| 340 | stats->active += obj->base.size; |
| 341 | else |
| 342 | stats->inactive += obj->base.size; |
| 343 | |
| 344 | return 0; |
| 345 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 346 | } else { |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 347 | if (i915_gem_obj_ggtt_bound(obj)) { |
| 348 | stats->global += obj->base.size; |
| 349 | if (obj->ring) |
| 350 | stats->active += obj->base.size; |
| 351 | else |
| 352 | stats->inactive += obj->base.size; |
| 353 | return 0; |
| 354 | } |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 355 | } |
| 356 | |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 357 | if (!list_empty(&obj->global_list)) |
| 358 | stats->unbound += obj->base.size; |
| 359 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 360 | return 0; |
| 361 | } |
| 362 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 363 | #define count_vmas(list, member) do { \ |
| 364 | list_for_each_entry(vma, list, member) { \ |
| 365 | size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 366 | ++count; \ |
| 367 | if (vma->obj->map_and_fenceable) { \ |
| 368 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 369 | ++mappable_count; \ |
| 370 | } \ |
| 371 | } \ |
| 372 | } while (0) |
| 373 | |
| 374 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 375 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 376 | struct drm_info_node *node = m->private; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 377 | struct drm_device *dev = node->minor->dev; |
| 378 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 379 | u32 count, mappable_count, purgeable_count; |
| 380 | size_t size, mappable_size, purgeable_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 381 | struct drm_i915_gem_object *obj; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 382 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 383 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 384 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 385 | int ret; |
| 386 | |
| 387 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 388 | if (ret) |
| 389 | return ret; |
| 390 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 391 | seq_printf(m, "%u objects, %zu bytes\n", |
| 392 | dev_priv->mm.object_count, |
| 393 | dev_priv->mm.object_memory); |
| 394 | |
| 395 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 396 | count_objects(&dev_priv->mm.bound_list, global_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 397 | seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", |
| 398 | count, mappable_count, size, mappable_size); |
| 399 | |
| 400 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 401 | count_vmas(&vm->active_list, mm_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 402 | seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n", |
| 403 | count, mappable_count, size, mappable_size); |
| 404 | |
| 405 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 406 | count_vmas(&vm->inactive_list, mm_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 407 | seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n", |
| 408 | count, mappable_count, size, mappable_size); |
| 409 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 410 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 411 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 412 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 413 | if (obj->madv == I915_MADV_DONTNEED) |
| 414 | purgeable_size += obj->base.size, ++purgeable_count; |
| 415 | } |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 416 | seq_printf(m, "%u unbound objects, %zu bytes\n", count, size); |
| 417 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 418 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 419 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 420 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 421 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 422 | ++count; |
| 423 | } |
| 424 | if (obj->pin_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 425 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 426 | ++mappable_count; |
| 427 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 428 | if (obj->madv == I915_MADV_DONTNEED) { |
| 429 | purgeable_size += obj->base.size; |
| 430 | ++purgeable_count; |
| 431 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 432 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 433 | seq_printf(m, "%u purgeable objects, %zu bytes\n", |
| 434 | purgeable_count, purgeable_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 435 | seq_printf(m, "%u pinned mappable objects, %zu bytes\n", |
| 436 | mappable_count, mappable_size); |
| 437 | seq_printf(m, "%u fault mappable objects, %zu bytes\n", |
| 438 | count, size); |
| 439 | |
Ben Widawsky | 93d1879 | 2013-01-17 12:45:17 -0800 | [diff] [blame] | 440 | seq_printf(m, "%zu [%lu] gtt total\n", |
Ben Widawsky | 853ba5d | 2013-07-16 16:50:05 -0700 | [diff] [blame] | 441 | dev_priv->gtt.base.total, |
| 442 | dev_priv->gtt.mappable_end - dev_priv->gtt.base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 443 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 444 | seq_putc(m, '\n'); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 445 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 446 | struct file_stats stats; |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 447 | struct task_struct *task; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 448 | |
| 449 | memset(&stats, 0, sizeof(stats)); |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 450 | stats.file_priv = file->driver_priv; |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 451 | spin_lock(&file->table_lock); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 452 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
Chris Wilson | 5b5ffff | 2014-06-17 09:56:24 +0100 | [diff] [blame] | 453 | spin_unlock(&file->table_lock); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 454 | /* |
| 455 | * Although we have a valid reference on file->pid, that does |
| 456 | * not guarantee that the task_struct who called get_pid() is |
| 457 | * still alive (e.g. get_pid(current) => fork() => exit()). |
| 458 | * Therefore, we need to protect this ->comm access using RCU. |
| 459 | */ |
| 460 | rcu_read_lock(); |
| 461 | task = pid_task(file->pid, PIDTYPE_PID); |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 462 | seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 463 | task ? task->comm : "<unknown>", |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 464 | stats.count, |
| 465 | stats.total, |
| 466 | stats.active, |
| 467 | stats.inactive, |
Chris Wilson | 6313c20 | 2014-03-19 13:45:45 +0000 | [diff] [blame] | 468 | stats.global, |
Chris Wilson | c67a17e | 2014-03-19 13:45:46 +0000 | [diff] [blame] | 469 | stats.shared, |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 470 | stats.unbound); |
Tetsuo Handa | 3ec2f42 | 2014-01-03 20:42:18 +0900 | [diff] [blame] | 471 | rcu_read_unlock(); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 472 | } |
| 473 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 474 | mutex_unlock(&dev->struct_mutex); |
| 475 | |
| 476 | return 0; |
| 477 | } |
| 478 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 479 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 480 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 481 | struct drm_info_node *node = m->private; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 482 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 483 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 484 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 485 | struct drm_i915_gem_object *obj; |
| 486 | size_t total_obj_size, total_gtt_size; |
| 487 | int count, ret; |
| 488 | |
| 489 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 490 | if (ret) |
| 491 | return ret; |
| 492 | |
| 493 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 494 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 495 | if (list == PINNED_LIST && !i915_gem_obj_is_pinned(obj)) |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 496 | continue; |
| 497 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 498 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 499 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 500 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 501 | total_obj_size += obj->base.size; |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 502 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 503 | count++; |
| 504 | } |
| 505 | |
| 506 | mutex_unlock(&dev->struct_mutex); |
| 507 | |
| 508 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 509 | count, total_obj_size, total_gtt_size); |
| 510 | |
| 511 | return 0; |
| 512 | } |
| 513 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 514 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 515 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 516 | struct drm_info_node *node = m->private; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 517 | struct drm_device *dev = node->minor->dev; |
| 518 | unsigned long flags; |
| 519 | struct intel_crtc *crtc; |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 520 | int ret; |
| 521 | |
| 522 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 523 | if (ret) |
| 524 | return ret; |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 525 | |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 526 | for_each_intel_crtc(dev, crtc) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 527 | const char pipe = pipe_name(crtc->pipe); |
| 528 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 529 | struct intel_unpin_work *work; |
| 530 | |
| 531 | spin_lock_irqsave(&dev->event_lock, flags); |
| 532 | work = crtc->unpin_work; |
| 533 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 534 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 535 | pipe, plane); |
| 536 | } else { |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 537 | if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 538 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 539 | pipe, plane); |
| 540 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 541 | 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] | 542 | pipe, plane); |
| 543 | } |
| 544 | if (work->enable_stall_check) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 545 | seq_puts(m, "Stall check enabled, "); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 546 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 547 | seq_puts(m, "Stall check waiting for page flip ioctl, "); |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 548 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 549 | |
| 550 | if (work->old_fb_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 551 | struct drm_i915_gem_object *obj = work->old_fb_obj; |
| 552 | if (obj) |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 553 | seq_printf(m, "Old framebuffer gtt_offset 0x%08lx\n", |
| 554 | i915_gem_obj_ggtt_offset(obj)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 555 | } |
| 556 | if (work->pending_flip_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 557 | struct drm_i915_gem_object *obj = work->pending_flip_obj; |
| 558 | if (obj) |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 559 | seq_printf(m, "New framebuffer gtt_offset 0x%08lx\n", |
| 560 | i915_gem_obj_ggtt_offset(obj)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 561 | } |
| 562 | } |
| 563 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 564 | } |
| 565 | |
Daniel Vetter | 8a270eb | 2014-06-17 22:34:37 +0200 | [diff] [blame] | 566 | mutex_unlock(&dev->struct_mutex); |
| 567 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 568 | return 0; |
| 569 | } |
| 570 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 571 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 572 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 573 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 574 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 575 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 576 | struct intel_engine_cs *ring; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 577 | struct drm_i915_gem_request *gem_request; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 578 | int ret, count, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 579 | |
| 580 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 581 | if (ret) |
| 582 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 583 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 584 | count = 0; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 585 | for_each_ring(ring, dev_priv, i) { |
| 586 | if (list_empty(&ring->request_list)) |
| 587 | continue; |
| 588 | |
| 589 | seq_printf(m, "%s requests:\n", ring->name); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 590 | list_for_each_entry(gem_request, |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 591 | &ring->request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 592 | list) { |
| 593 | seq_printf(m, " %d @ %d\n", |
| 594 | gem_request->seqno, |
| 595 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 596 | } |
| 597 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 598 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 599 | mutex_unlock(&dev->struct_mutex); |
| 600 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 601 | if (count == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 602 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 603 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 604 | return 0; |
| 605 | } |
| 606 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 607 | static void i915_ring_seqno_info(struct seq_file *m, |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 608 | struct intel_engine_cs *ring) |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 609 | { |
| 610 | if (ring->get_seqno) { |
Mika Kuoppala | 43a7b92 | 2012-12-04 15:12:01 +0200 | [diff] [blame] | 611 | seq_printf(m, "Current sequence (%s): %u\n", |
Chris Wilson | b2eadbc | 2012-08-09 10:58:30 +0100 | [diff] [blame] | 612 | ring->name, ring->get_seqno(ring, false)); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 613 | } |
| 614 | } |
| 615 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 616 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 617 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 618 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 619 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 620 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 621 | struct intel_engine_cs *ring; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 622 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 623 | |
| 624 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 625 | if (ret) |
| 626 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 627 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 628 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 629 | for_each_ring(ring, dev_priv, i) |
| 630 | i915_ring_seqno_info(m, ring); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 631 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 632 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 633 | mutex_unlock(&dev->struct_mutex); |
| 634 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 635 | return 0; |
| 636 | } |
| 637 | |
| 638 | |
| 639 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 640 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 641 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 642 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 643 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 644 | struct intel_engine_cs *ring; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 645 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 646 | |
| 647 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 648 | if (ret) |
| 649 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 650 | intel_runtime_pm_get(dev_priv); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 651 | |
Ville Syrjälä | 74e1ca8 | 2014-04-09 13:28:09 +0300 | [diff] [blame] | 652 | if (IS_CHERRYVIEW(dev)) { |
| 653 | int i; |
| 654 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 655 | I915_READ(GEN8_MASTER_IRQ)); |
| 656 | |
| 657 | seq_printf(m, "Display IER:\t%08x\n", |
| 658 | I915_READ(VLV_IER)); |
| 659 | seq_printf(m, "Display IIR:\t%08x\n", |
| 660 | I915_READ(VLV_IIR)); |
| 661 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 662 | I915_READ(VLV_IIR_RW)); |
| 663 | seq_printf(m, "Display IMR:\t%08x\n", |
| 664 | I915_READ(VLV_IMR)); |
| 665 | for_each_pipe(pipe) |
| 666 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 667 | pipe_name(pipe), |
| 668 | I915_READ(PIPESTAT(pipe))); |
| 669 | |
| 670 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 671 | I915_READ(PORT_HOTPLUG_EN)); |
| 672 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 673 | I915_READ(VLV_DPFLIPSTAT)); |
| 674 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 675 | I915_READ(DPINVGTT)); |
| 676 | |
| 677 | for (i = 0; i < 4; i++) { |
| 678 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 679 | i, I915_READ(GEN8_GT_IMR(i))); |
| 680 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 681 | i, I915_READ(GEN8_GT_IIR(i))); |
| 682 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 683 | i, I915_READ(GEN8_GT_IER(i))); |
| 684 | } |
| 685 | |
| 686 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 687 | I915_READ(GEN8_PCU_IMR)); |
| 688 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 689 | I915_READ(GEN8_PCU_IIR)); |
| 690 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 691 | I915_READ(GEN8_PCU_IER)); |
| 692 | } else if (INTEL_INFO(dev)->gen >= 8) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 693 | seq_printf(m, "Master Interrupt Control:\t%08x\n", |
| 694 | I915_READ(GEN8_MASTER_IRQ)); |
| 695 | |
| 696 | for (i = 0; i < 4; i++) { |
| 697 | seq_printf(m, "GT Interrupt IMR %d:\t%08x\n", |
| 698 | i, I915_READ(GEN8_GT_IMR(i))); |
| 699 | seq_printf(m, "GT Interrupt IIR %d:\t%08x\n", |
| 700 | i, I915_READ(GEN8_GT_IIR(i))); |
| 701 | seq_printf(m, "GT Interrupt IER %d:\t%08x\n", |
| 702 | i, I915_READ(GEN8_GT_IER(i))); |
| 703 | } |
| 704 | |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 705 | for_each_pipe(pipe) { |
Paulo Zanoni | 22c5996 | 2014-08-08 17:45:32 -0300 | [diff] [blame] | 706 | if (!intel_display_power_enabled(dev_priv, |
| 707 | POWER_DOMAIN_PIPE(pipe))) { |
| 708 | seq_printf(m, "Pipe %c power disabled\n", |
| 709 | pipe_name(pipe)); |
| 710 | continue; |
| 711 | } |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 712 | seq_printf(m, "Pipe %c IMR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 713 | pipe_name(pipe), |
| 714 | I915_READ(GEN8_DE_PIPE_IMR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 715 | seq_printf(m, "Pipe %c IIR:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 716 | pipe_name(pipe), |
| 717 | I915_READ(GEN8_DE_PIPE_IIR(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 718 | seq_printf(m, "Pipe %c IER:\t%08x\n", |
Damien Lespiau | 07d27e2 | 2014-03-03 17:31:46 +0000 | [diff] [blame] | 719 | pipe_name(pipe), |
| 720 | I915_READ(GEN8_DE_PIPE_IER(pipe))); |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | seq_printf(m, "Display Engine port interrupt mask:\t%08x\n", |
| 724 | I915_READ(GEN8_DE_PORT_IMR)); |
| 725 | seq_printf(m, "Display Engine port interrupt identity:\t%08x\n", |
| 726 | I915_READ(GEN8_DE_PORT_IIR)); |
| 727 | seq_printf(m, "Display Engine port interrupt enable:\t%08x\n", |
| 728 | I915_READ(GEN8_DE_PORT_IER)); |
| 729 | |
| 730 | seq_printf(m, "Display Engine misc interrupt mask:\t%08x\n", |
| 731 | I915_READ(GEN8_DE_MISC_IMR)); |
| 732 | seq_printf(m, "Display Engine misc interrupt identity:\t%08x\n", |
| 733 | I915_READ(GEN8_DE_MISC_IIR)); |
| 734 | seq_printf(m, "Display Engine misc interrupt enable:\t%08x\n", |
| 735 | I915_READ(GEN8_DE_MISC_IER)); |
| 736 | |
| 737 | seq_printf(m, "PCU interrupt mask:\t%08x\n", |
| 738 | I915_READ(GEN8_PCU_IMR)); |
| 739 | seq_printf(m, "PCU interrupt identity:\t%08x\n", |
| 740 | I915_READ(GEN8_PCU_IIR)); |
| 741 | seq_printf(m, "PCU interrupt enable:\t%08x\n", |
| 742 | I915_READ(GEN8_PCU_IER)); |
| 743 | } else if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 744 | seq_printf(m, "Display IER:\t%08x\n", |
| 745 | I915_READ(VLV_IER)); |
| 746 | seq_printf(m, "Display IIR:\t%08x\n", |
| 747 | I915_READ(VLV_IIR)); |
| 748 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 749 | I915_READ(VLV_IIR_RW)); |
| 750 | seq_printf(m, "Display IMR:\t%08x\n", |
| 751 | I915_READ(VLV_IMR)); |
| 752 | for_each_pipe(pipe) |
| 753 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 754 | pipe_name(pipe), |
| 755 | I915_READ(PIPESTAT(pipe))); |
| 756 | |
| 757 | seq_printf(m, "Master IER:\t%08x\n", |
| 758 | I915_READ(VLV_MASTER_IER)); |
| 759 | |
| 760 | seq_printf(m, "Render IER:\t%08x\n", |
| 761 | I915_READ(GTIER)); |
| 762 | seq_printf(m, "Render IIR:\t%08x\n", |
| 763 | I915_READ(GTIIR)); |
| 764 | seq_printf(m, "Render IMR:\t%08x\n", |
| 765 | I915_READ(GTIMR)); |
| 766 | |
| 767 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 768 | I915_READ(GEN6_PMIER)); |
| 769 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 770 | I915_READ(GEN6_PMIIR)); |
| 771 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 772 | I915_READ(GEN6_PMIMR)); |
| 773 | |
| 774 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 775 | I915_READ(PORT_HOTPLUG_EN)); |
| 776 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 777 | I915_READ(VLV_DPFLIPSTAT)); |
| 778 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 779 | I915_READ(DPINVGTT)); |
| 780 | |
| 781 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 782 | seq_printf(m, "Interrupt enable: %08x\n", |
| 783 | I915_READ(IER)); |
| 784 | seq_printf(m, "Interrupt identity: %08x\n", |
| 785 | I915_READ(IIR)); |
| 786 | seq_printf(m, "Interrupt mask: %08x\n", |
| 787 | I915_READ(IMR)); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 788 | for_each_pipe(pipe) |
| 789 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 790 | pipe_name(pipe), |
| 791 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 792 | } else { |
| 793 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 794 | I915_READ(DEIER)); |
| 795 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 796 | I915_READ(DEIIR)); |
| 797 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 798 | I915_READ(DEIMR)); |
| 799 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 800 | I915_READ(SDEIER)); |
| 801 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 802 | I915_READ(SDEIIR)); |
| 803 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 804 | I915_READ(SDEIMR)); |
| 805 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 806 | I915_READ(GTIER)); |
| 807 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 808 | I915_READ(GTIIR)); |
| 809 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 810 | I915_READ(GTIMR)); |
| 811 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 812 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a123f15 | 2013-11-02 21:07:10 -0700 | [diff] [blame] | 813 | if (INTEL_INFO(dev)->gen >= 6) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 814 | seq_printf(m, |
| 815 | "Graphics Interrupt mask (%s): %08x\n", |
| 816 | ring->name, I915_READ_IMR(ring)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 817 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 818 | i915_ring_seqno_info(m, ring); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 819 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 820 | intel_runtime_pm_put(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 821 | mutex_unlock(&dev->struct_mutex); |
| 822 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 823 | return 0; |
| 824 | } |
| 825 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 826 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 827 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 828 | struct drm_info_node *node = m->private; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 829 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 830 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 831 | int i, ret; |
| 832 | |
| 833 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 834 | if (ret) |
| 835 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 836 | |
| 837 | seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start); |
| 838 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 839 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 840 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 841 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 842 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 843 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 844 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 845 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 846 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 847 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 848 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 851 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 852 | return 0; |
| 853 | } |
| 854 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 855 | static int i915_hws_info(struct seq_file *m, void *data) |
| 856 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 857 | struct drm_info_node *node = m->private; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 858 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 859 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 860 | struct intel_engine_cs *ring; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 861 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 862 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 863 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 864 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 865 | hws = ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 866 | if (hws == NULL) |
| 867 | return 0; |
| 868 | |
| 869 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 870 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 871 | i * 4, |
| 872 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 873 | } |
| 874 | return 0; |
| 875 | } |
| 876 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 877 | static ssize_t |
| 878 | i915_error_state_write(struct file *filp, |
| 879 | const char __user *ubuf, |
| 880 | size_t cnt, |
| 881 | loff_t *ppos) |
| 882 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 883 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 884 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 885 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 886 | |
| 887 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 888 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 889 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 890 | if (ret) |
| 891 | return ret; |
| 892 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 893 | i915_destroy_error_state(dev); |
| 894 | mutex_unlock(&dev->struct_mutex); |
| 895 | |
| 896 | return cnt; |
| 897 | } |
| 898 | |
| 899 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 900 | { |
| 901 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 902 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 903 | |
| 904 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 905 | if (!error_priv) |
| 906 | return -ENOMEM; |
| 907 | |
| 908 | error_priv->dev = dev; |
| 909 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 910 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 911 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 912 | file->private_data = error_priv; |
| 913 | |
| 914 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 918 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 919 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 920 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 921 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 922 | kfree(error_priv); |
| 923 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 924 | return 0; |
| 925 | } |
| 926 | |
| 927 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 928 | size_t count, loff_t *pos) |
| 929 | { |
| 930 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 931 | struct drm_i915_error_state_buf error_str; |
| 932 | loff_t tmp_pos = 0; |
| 933 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 934 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 935 | |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 936 | ret = i915_error_state_buf_init(&error_str, count, *pos); |
| 937 | if (ret) |
| 938 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 939 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 940 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 941 | if (ret) |
| 942 | goto out; |
| 943 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 944 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 945 | error_str.buf, |
| 946 | error_str.bytes); |
| 947 | |
| 948 | if (ret_count < 0) |
| 949 | ret = ret_count; |
| 950 | else |
| 951 | *pos = error_str.start + ret_count; |
| 952 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 953 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 954 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | static const struct file_operations i915_error_state_fops = { |
| 958 | .owner = THIS_MODULE, |
| 959 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 960 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 961 | .write = i915_error_state_write, |
| 962 | .llseek = default_llseek, |
| 963 | .release = i915_error_state_release, |
| 964 | }; |
| 965 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 966 | static int |
| 967 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 968 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 969 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 970 | struct drm_i915_private *dev_priv = dev->dev_private; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 971 | int ret; |
| 972 | |
| 973 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 974 | if (ret) |
| 975 | return ret; |
| 976 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 977 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 978 | mutex_unlock(&dev->struct_mutex); |
| 979 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 980 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 981 | } |
| 982 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 983 | static int |
| 984 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 985 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 986 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 987 | int ret; |
| 988 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 989 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 990 | if (ret) |
| 991 | return ret; |
| 992 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 993 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 994 | mutex_unlock(&dev->struct_mutex); |
| 995 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 996 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 997 | } |
| 998 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 999 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 1000 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 1001 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 1002 | |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 1003 | static int i915_frequency_info(struct seq_file *m, void *unused) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1004 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1005 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1006 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1007 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1008 | int ret = 0; |
| 1009 | |
| 1010 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1011 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1012 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1013 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1014 | if (IS_GEN5(dev)) { |
| 1015 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 1016 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 1017 | |
| 1018 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 1019 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 1020 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 1021 | MEMSTAT_VID_SHIFT); |
| 1022 | seq_printf(m, "Current P-state: %d\n", |
| 1023 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1024 | } else if (IS_GEN6(dev) || (IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) || |
| 1025 | IS_BROADWELL(dev)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1026 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 1027 | u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 1028 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1029 | u32 rpmodectl, rpinclimit, rpdeclimit; |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1030 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1031 | u32 rpupei, rpcurup, rpprevup; |
| 1032 | u32 rpdownei, rpcurdown, rpprevdown; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1033 | int max_freq; |
| 1034 | |
| 1035 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1036 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1037 | if (ret) |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1038 | goto out; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1039 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 1040 | gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1041 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1042 | reqf = I915_READ(GEN6_RPNSWREQ); |
| 1043 | reqf &= ~GEN6_TURBO_DISABLE; |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1044 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1045 | reqf >>= 24; |
| 1046 | else |
| 1047 | reqf >>= 25; |
| 1048 | reqf *= GT_FREQUENCY_MULTIPLIER; |
| 1049 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1050 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
| 1051 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
| 1052 | rpdeclimit = I915_READ(GEN6_RP_DOWN_THRESHOLD); |
| 1053 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1054 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 1055 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 1056 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 1057 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 1058 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 1059 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 1060 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 1061 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1062 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 1063 | else |
| 1064 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
| 1065 | cagf *= GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1066 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 1067 | gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 1068 | mutex_unlock(&dev->struct_mutex); |
| 1069 | |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1070 | seq_printf(m, "PM IER=0x%08x IMR=0x%08x ISR=0x%08x IIR=0x%08x, MASK=0x%08x\n", |
| 1071 | I915_READ(GEN6_PMIER), |
| 1072 | I915_READ(GEN6_PMIMR), |
| 1073 | I915_READ(GEN6_PMISR), |
| 1074 | I915_READ(GEN6_PMIIR), |
| 1075 | I915_READ(GEN6_PMINTRMSK)); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1076 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1077 | seq_printf(m, "Render p-state ratio: %d\n", |
| 1078 | (gt_perf_status & 0xff00) >> 8); |
| 1079 | seq_printf(m, "Render p-state VID: %d\n", |
| 1080 | gt_perf_status & 0xff); |
| 1081 | seq_printf(m, "Render p-state limit: %d\n", |
| 1082 | rp_state_limits & 0xff); |
Chris Wilson | 0d8f949 | 2014-03-27 09:06:14 +0000 | [diff] [blame] | 1083 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
| 1084 | seq_printf(m, "RPMODECTL: 0x%08x\n", rpmodectl); |
| 1085 | seq_printf(m, "RPINCLIMIT: 0x%08x\n", rpinclimit); |
| 1086 | seq_printf(m, "RPDECLIMIT: 0x%08x\n", rpdeclimit); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 1087 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 1088 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 1089 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 1090 | GEN6_CURICONT_MASK); |
| 1091 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 1092 | GEN6_CURBSYTAVG_MASK); |
| 1093 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 1094 | GEN6_CURBSYTAVG_MASK); |
| 1095 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 1096 | GEN6_CURIAVG_MASK); |
| 1097 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 1098 | GEN6_CURBSYTAVG_MASK); |
| 1099 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 1100 | GEN6_CURBSYTAVG_MASK); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1101 | |
| 1102 | max_freq = (rp_state_cap & 0xff0000) >> 16; |
| 1103 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 1104 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1105 | |
| 1106 | max_freq = (rp_state_cap & 0xff00) >> 8; |
| 1107 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 1108 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1109 | |
| 1110 | max_freq = rp_state_cap & 0xff; |
| 1111 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 1112 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 1113 | |
| 1114 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1115 | dev_priv->rps.max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1116 | } else if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1117 | u32 freq_sts; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1118 | |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1119 | mutex_lock(&dev_priv->rps.hw_lock); |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 1120 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1121 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 1122 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 1123 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1124 | seq_printf(m, "max GPU freq: %d MHz\n", |
Deepak S | b2435c9 | 2014-07-17 14:21:14 +0530 | [diff] [blame] | 1125 | vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1126 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1127 | seq_printf(m, "min GPU freq: %d MHz\n", |
Deepak S | b2435c9 | 2014-07-17 14:21:14 +0530 | [diff] [blame] | 1128 | vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 1129 | |
| 1130 | seq_printf(m, "efficient (RPe) frequency: %d MHz\n", |
Deepak S | b2435c9 | 2014-07-17 14:21:14 +0530 | [diff] [blame] | 1131 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 1132 | |
| 1133 | seq_printf(m, "current GPU freq: %d MHz\n", |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 1134 | vlv_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 1135 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1136 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1137 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 1138 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1139 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1140 | out: |
| 1141 | intel_runtime_pm_put(dev_priv); |
| 1142 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1143 | } |
| 1144 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1145 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1146 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1147 | struct drm_info_node *node = m->private; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1148 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1149 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1150 | u32 rgvmodectl, rstdbyctl; |
| 1151 | u16 crstandvid; |
| 1152 | int ret; |
| 1153 | |
| 1154 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1155 | if (ret) |
| 1156 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1157 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1158 | |
| 1159 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1160 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1161 | crstandvid = I915_READ16(CRSTANDVID); |
| 1162 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1163 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1164 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1165 | |
| 1166 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1167 | "yes" : "no"); |
| 1168 | seq_printf(m, "Boost freq: %d\n", |
| 1169 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1170 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1171 | seq_printf(m, "HW control enabled: %s\n", |
| 1172 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1173 | seq_printf(m, "SW control enabled: %s\n", |
| 1174 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1175 | seq_printf(m, "Gated voltage change: %s\n", |
| 1176 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1177 | seq_printf(m, "Starting frequency: P%d\n", |
| 1178 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1179 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1180 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1181 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1182 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1183 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1184 | seq_printf(m, "Render standby enabled: %s\n", |
| 1185 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1186 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1187 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1188 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1189 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1190 | break; |
| 1191 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1192 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1193 | break; |
| 1194 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1195 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1196 | break; |
| 1197 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1198 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1199 | break; |
| 1200 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1201 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1202 | break; |
| 1203 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1204 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1205 | break; |
| 1206 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1207 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1208 | break; |
| 1209 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1210 | |
| 1211 | return 0; |
| 1212 | } |
| 1213 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1214 | static int vlv_drpc_info(struct seq_file *m) |
| 1215 | { |
| 1216 | |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1217 | struct drm_info_node *node = m->private; |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1218 | struct drm_device *dev = node->minor->dev; |
| 1219 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1220 | u32 rpmodectl1, rcctl1; |
| 1221 | unsigned fw_rendercount = 0, fw_mediacount = 0; |
| 1222 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1223 | intel_runtime_pm_get(dev_priv); |
| 1224 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1225 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1226 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1227 | |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 1228 | intel_runtime_pm_put(dev_priv); |
| 1229 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1230 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1231 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1232 | seq_printf(m, "Turbo enabled: %s\n", |
| 1233 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1234 | seq_printf(m, "HW control enabled: %s\n", |
| 1235 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1236 | seq_printf(m, "SW control enabled: %s\n", |
| 1237 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1238 | GEN6_RP_MEDIA_SW_MODE)); |
| 1239 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1240 | yesno(rcctl1 & (GEN7_RC_CTL_TO_MODE | |
| 1241 | GEN6_RC_CTL_EI_MODE(1)))); |
| 1242 | seq_printf(m, "Render Power Well: %s\n", |
| 1243 | (I915_READ(VLV_GTLC_PW_STATUS) & |
| 1244 | VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); |
| 1245 | seq_printf(m, "Media Power Well: %s\n", |
| 1246 | (I915_READ(VLV_GTLC_PW_STATUS) & |
| 1247 | VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); |
| 1248 | |
Imre Deak | 9cc19be | 2014-04-14 20:24:24 +0300 | [diff] [blame] | 1249 | seq_printf(m, "Render RC6 residency since boot: %u\n", |
| 1250 | I915_READ(VLV_GT_RENDER_RC6)); |
| 1251 | seq_printf(m, "Media RC6 residency since boot: %u\n", |
| 1252 | I915_READ(VLV_GT_MEDIA_RC6)); |
| 1253 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1254 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1255 | fw_rendercount = dev_priv->uncore.fw_rendercount; |
| 1256 | fw_mediacount = dev_priv->uncore.fw_mediacount; |
| 1257 | spin_unlock_irq(&dev_priv->uncore.lock); |
| 1258 | |
| 1259 | seq_printf(m, "Forcewake Render Count = %u\n", fw_rendercount); |
| 1260 | seq_printf(m, "Forcewake Media Count = %u\n", fw_mediacount); |
| 1261 | |
| 1262 | |
| 1263 | return 0; |
| 1264 | } |
| 1265 | |
| 1266 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1267 | static int gen6_drpc_info(struct seq_file *m) |
| 1268 | { |
| 1269 | |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1270 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1271 | struct drm_device *dev = node->minor->dev; |
| 1272 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1273 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1274 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1275 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1276 | |
| 1277 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1278 | if (ret) |
| 1279 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1280 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1281 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1282 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1283 | forcewake_count = dev_priv->uncore.forcewake_count; |
| 1284 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1285 | |
| 1286 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1287 | seq_puts(m, "RC information inaccurate because somebody " |
| 1288 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1289 | } else { |
| 1290 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1291 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1292 | udelay(10); |
| 1293 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1294 | } |
| 1295 | |
| 1296 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1297 | 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] | 1298 | |
| 1299 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1300 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1301 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1302 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1303 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1304 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1305 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1306 | intel_runtime_pm_put(dev_priv); |
| 1307 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1308 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1309 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1310 | seq_printf(m, "HW control enabled: %s\n", |
| 1311 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1312 | seq_printf(m, "SW control enabled: %s\n", |
| 1313 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1314 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1315 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1316 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1317 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1318 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1319 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1320 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1321 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1322 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1323 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1324 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1325 | case GEN6_RC0: |
| 1326 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1327 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1328 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1329 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1330 | break; |
| 1331 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1332 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1333 | break; |
| 1334 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1335 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1336 | break; |
| 1337 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1338 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1339 | break; |
| 1340 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1341 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1342 | break; |
| 1343 | } |
| 1344 | |
| 1345 | seq_printf(m, "Core Power Down: %s\n", |
| 1346 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1347 | |
| 1348 | /* Not exactly sure what this is */ |
| 1349 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1350 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1351 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1352 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1353 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1354 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1355 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1356 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1357 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1358 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1359 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1360 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1361 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1362 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1363 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1364 | return 0; |
| 1365 | } |
| 1366 | |
| 1367 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1368 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1369 | struct drm_info_node *node = m->private; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1370 | struct drm_device *dev = node->minor->dev; |
| 1371 | |
Deepak S | 669ab5a | 2014-01-10 15:18:26 +0530 | [diff] [blame] | 1372 | if (IS_VALLEYVIEW(dev)) |
| 1373 | return vlv_drpc_info(m); |
| 1374 | else if (IS_GEN6(dev) || IS_GEN7(dev)) |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1375 | return gen6_drpc_info(m); |
| 1376 | else |
| 1377 | return ironlake_drpc_info(m); |
| 1378 | } |
| 1379 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1380 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1381 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1382 | struct drm_info_node *node = m->private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1383 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1384 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1385 | |
Daniel Vetter | 3a77c4c | 2014-01-10 08:50:12 +0100 | [diff] [blame] | 1386 | if (!HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1387 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1388 | return 0; |
| 1389 | } |
| 1390 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1391 | intel_runtime_pm_get(dev_priv); |
| 1392 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1393 | if (intel_fbc_enabled(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1394 | seq_puts(m, "FBC enabled\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1395 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1396 | seq_puts(m, "FBC disabled: "); |
Ben Widawsky | 5c3fe8b | 2013-06-27 16:30:21 -0700 | [diff] [blame] | 1397 | switch (dev_priv->fbc.no_fbc_reason) { |
Chris Wilson | 29ebf90 | 2013-07-27 17:23:55 +0100 | [diff] [blame] | 1398 | case FBC_OK: |
| 1399 | seq_puts(m, "FBC actived, but currently disabled in hardware"); |
| 1400 | break; |
| 1401 | case FBC_UNSUPPORTED: |
| 1402 | seq_puts(m, "unsupported by this chipset"); |
| 1403 | break; |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1404 | case FBC_NO_OUTPUT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1405 | seq_puts(m, "no outputs"); |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1406 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1407 | case FBC_STOLEN_TOO_SMALL: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1408 | seq_puts(m, "not enough stolen memory"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1409 | break; |
| 1410 | case FBC_UNSUPPORTED_MODE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1411 | seq_puts(m, "mode not supported"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1412 | break; |
| 1413 | case FBC_MODE_TOO_LARGE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1414 | seq_puts(m, "mode too large"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1415 | break; |
| 1416 | case FBC_BAD_PLANE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1417 | seq_puts(m, "FBC unsupported on plane"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1418 | break; |
| 1419 | case FBC_NOT_TILED: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1420 | seq_puts(m, "scanout buffer not tiled"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1421 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1422 | case FBC_MULTIPLE_PIPES: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1423 | seq_puts(m, "multiple pipes are enabled"); |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1424 | break; |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1425 | case FBC_MODULE_PARAM: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1426 | seq_puts(m, "disabled per module param (default off)"); |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1427 | break; |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1428 | case FBC_CHIP_DEFAULT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1429 | seq_puts(m, "disabled per chip default"); |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1430 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1431 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1432 | seq_puts(m, "unknown reason"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1433 | } |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1434 | seq_putc(m, '\n'); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1435 | } |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1436 | |
| 1437 | intel_runtime_pm_put(dev_priv); |
| 1438 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1439 | return 0; |
| 1440 | } |
| 1441 | |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 1442 | static int i915_fbc_fc_get(void *data, u64 *val) |
| 1443 | { |
| 1444 | struct drm_device *dev = data; |
| 1445 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1446 | |
| 1447 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1448 | return -ENODEV; |
| 1449 | |
| 1450 | drm_modeset_lock_all(dev); |
| 1451 | *val = dev_priv->fbc.false_color; |
| 1452 | drm_modeset_unlock_all(dev); |
| 1453 | |
| 1454 | return 0; |
| 1455 | } |
| 1456 | |
| 1457 | static int i915_fbc_fc_set(void *data, u64 val) |
| 1458 | { |
| 1459 | struct drm_device *dev = data; |
| 1460 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1461 | u32 reg; |
| 1462 | |
| 1463 | if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev)) |
| 1464 | return -ENODEV; |
| 1465 | |
| 1466 | drm_modeset_lock_all(dev); |
| 1467 | |
| 1468 | reg = I915_READ(ILK_DPFC_CONTROL); |
| 1469 | dev_priv->fbc.false_color = val; |
| 1470 | |
| 1471 | I915_WRITE(ILK_DPFC_CONTROL, val ? |
| 1472 | (reg | FBC_CTL_FALSE_COLOR) : |
| 1473 | (reg & ~FBC_CTL_FALSE_COLOR)); |
| 1474 | |
| 1475 | drm_modeset_unlock_all(dev); |
| 1476 | return 0; |
| 1477 | } |
| 1478 | |
| 1479 | DEFINE_SIMPLE_ATTRIBUTE(i915_fbc_fc_fops, |
| 1480 | i915_fbc_fc_get, i915_fbc_fc_set, |
| 1481 | "%llu\n"); |
| 1482 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1483 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1484 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1485 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1486 | struct drm_device *dev = node->minor->dev; |
| 1487 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1488 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1489 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1490 | seq_puts(m, "not supported\n"); |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1494 | intel_runtime_pm_get(dev_priv); |
| 1495 | |
Rodrigo Vivi | 0eaa53f | 2014-06-30 04:45:01 -0700 | [diff] [blame] | 1496 | seq_printf(m, "Enabled by kernel parameter: %s\n", |
| 1497 | yesno(i915.enable_ips)); |
| 1498 | |
| 1499 | if (INTEL_INFO(dev)->gen >= 8) { |
| 1500 | seq_puts(m, "Currently: unknown\n"); |
| 1501 | } else { |
| 1502 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1503 | seq_puts(m, "Currently: enabled\n"); |
| 1504 | else |
| 1505 | seq_puts(m, "Currently: disabled\n"); |
| 1506 | } |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1507 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1508 | intel_runtime_pm_put(dev_priv); |
| 1509 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1510 | return 0; |
| 1511 | } |
| 1512 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1513 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1514 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1515 | struct drm_info_node *node = m->private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1516 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1517 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1518 | bool sr_enabled = false; |
| 1519 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1520 | intel_runtime_pm_get(dev_priv); |
| 1521 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1522 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1523 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1524 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1525 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1526 | else if (IS_I915GM(dev)) |
| 1527 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1528 | else if (IS_PINEVIEW(dev)) |
| 1529 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1530 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 1531 | intel_runtime_pm_put(dev_priv); |
| 1532 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1533 | seq_printf(m, "self-refresh: %s\n", |
| 1534 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1535 | |
| 1536 | return 0; |
| 1537 | } |
| 1538 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1539 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1540 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1541 | struct drm_info_node *node = m->private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1542 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1543 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1544 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1545 | int ret; |
| 1546 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1547 | if (!IS_GEN5(dev)) |
| 1548 | return -ENODEV; |
| 1549 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1550 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1551 | if (ret) |
| 1552 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1553 | |
| 1554 | temp = i915_mch_val(dev_priv); |
| 1555 | chipset = i915_chipset_val(dev_priv); |
| 1556 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1557 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1558 | |
| 1559 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1560 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1561 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1562 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1563 | |
| 1564 | return 0; |
| 1565 | } |
| 1566 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1567 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1568 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1569 | struct drm_info_node *node = m->private; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1570 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1571 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1572 | int ret = 0; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1573 | int gpu_freq, ia_freq; |
| 1574 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1575 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1576 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1577 | return 0; |
| 1578 | } |
| 1579 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1580 | intel_runtime_pm_get(dev_priv); |
| 1581 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1582 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1583 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1584 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1585 | if (ret) |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1586 | goto out; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1587 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1588 | 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] | 1589 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 1590 | for (gpu_freq = dev_priv->rps.min_freq_softlimit; |
| 1591 | gpu_freq <= dev_priv->rps.max_freq_softlimit; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1592 | gpu_freq++) { |
Ben Widawsky | 42c0526 | 2012-09-26 10:34:00 -0700 | [diff] [blame] | 1593 | ia_freq = gpu_freq; |
| 1594 | sandybridge_pcode_read(dev_priv, |
| 1595 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1596 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1597 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", |
| 1598 | gpu_freq * GT_FREQUENCY_MULTIPLIER, |
| 1599 | ((ia_freq >> 0) & 0xff) * 100, |
| 1600 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1601 | } |
| 1602 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1603 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1604 | |
Paulo Zanoni | 5bfa019 | 2013-12-19 11:54:52 -0200 | [diff] [blame] | 1605 | out: |
| 1606 | intel_runtime_pm_put(dev_priv); |
| 1607 | return ret; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1608 | } |
| 1609 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1610 | static int i915_opregion(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; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [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; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1615 | struct intel_opregion *opregion = &dev_priv->opregion; |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1616 | void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1617 | int ret; |
| 1618 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1619 | if (data == NULL) |
| 1620 | return -ENOMEM; |
| 1621 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1622 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1623 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1624 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1625 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1626 | if (opregion->header) { |
| 1627 | memcpy_fromio(data, opregion->header, OPREGION_SIZE); |
| 1628 | seq_write(m, data, OPREGION_SIZE); |
| 1629 | } |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1630 | |
| 1631 | mutex_unlock(&dev->struct_mutex); |
| 1632 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1633 | out: |
| 1634 | kfree(data); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1635 | return 0; |
| 1636 | } |
| 1637 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1638 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1639 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1640 | struct drm_info_node *node = m->private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1641 | struct drm_device *dev = node->minor->dev; |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1642 | struct intel_fbdev *ifbdev = NULL; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1643 | struct intel_framebuffer *fb; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1644 | |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1645 | #ifdef CONFIG_DRM_I915_FBDEV |
| 1646 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1647 | |
| 1648 | ifbdev = dev_priv->fbdev; |
| 1649 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1650 | |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1651 | seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1652 | fb->base.width, |
| 1653 | fb->base.height, |
| 1654 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1655 | fb->base.bits_per_pixel, |
| 1656 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1657 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1658 | seq_putc(m, '\n'); |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1659 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1660 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1661 | mutex_lock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1662 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
Daniel Vetter | 131a56d | 2013-10-17 14:35:31 +0200 | [diff] [blame] | 1663 | if (ifbdev && &fb->base == ifbdev->helper.fb) |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1664 | continue; |
| 1665 | |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1666 | seq_printf(m, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ", |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1667 | fb->base.width, |
| 1668 | fb->base.height, |
| 1669 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1670 | fb->base.bits_per_pixel, |
| 1671 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1672 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1673 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1674 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1675 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1676 | |
| 1677 | return 0; |
| 1678 | } |
| 1679 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1680 | static void describe_ctx_ringbuf(struct seq_file *m, |
| 1681 | struct intel_ringbuffer *ringbuf) |
| 1682 | { |
| 1683 | seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)", |
| 1684 | ringbuf->space, ringbuf->head, ringbuf->tail, |
| 1685 | ringbuf->last_retired_head); |
| 1686 | } |
| 1687 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1688 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1689 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1690 | struct drm_info_node *node = m->private; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1691 | struct drm_device *dev = node->minor->dev; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 1692 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1693 | struct intel_engine_cs *ring; |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1694 | struct intel_context *ctx; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1695 | int ret, i; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1696 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1697 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1698 | if (ret) |
| 1699 | return ret; |
| 1700 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1701 | if (dev_priv->ips.pwrctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1702 | seq_puts(m, "power context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1703 | describe_obj(m, dev_priv->ips.pwrctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1704 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1705 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1706 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1707 | if (dev_priv->ips.renderctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1708 | seq_puts(m, "render context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1709 | describe_obj(m, dev_priv->ips.renderctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1710 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1711 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1712 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1713 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1714 | if (!i915.enable_execlists && |
| 1715 | ctx->legacy_hw_ctx.rcs_state == NULL) |
Chris Wilson | b77f699 | 2014-04-30 08:30:00 +0100 | [diff] [blame] | 1716 | continue; |
| 1717 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1718 | seq_puts(m, "HW context "); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 1719 | describe_ctx(m, ctx); |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1720 | for_each_ring(ring, dev_priv, i) { |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1721 | if (ring->default_context == ctx) |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1722 | seq_printf(m, "(default context %s) ", |
| 1723 | ring->name); |
| 1724 | } |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1725 | |
Oscar Mateo | c9fe99b | 2014-07-24 17:04:46 +0100 | [diff] [blame] | 1726 | if (i915.enable_execlists) { |
| 1727 | seq_putc(m, '\n'); |
| 1728 | for_each_ring(ring, dev_priv, i) { |
| 1729 | struct drm_i915_gem_object *ctx_obj = |
| 1730 | ctx->engine[i].state; |
| 1731 | struct intel_ringbuffer *ringbuf = |
| 1732 | ctx->engine[i].ringbuf; |
| 1733 | |
| 1734 | seq_printf(m, "%s: ", ring->name); |
| 1735 | if (ctx_obj) |
| 1736 | describe_obj(m, ctx_obj); |
| 1737 | if (ringbuf) |
| 1738 | describe_ctx_ringbuf(m, ringbuf); |
| 1739 | seq_putc(m, '\n'); |
| 1740 | } |
| 1741 | } else { |
| 1742 | describe_obj(m, ctx->legacy_hw_ctx.rcs_state); |
| 1743 | } |
| 1744 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1745 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1746 | } |
| 1747 | |
Daniel Vetter | f3d2887 | 2014-05-29 23:23:08 +0200 | [diff] [blame] | 1748 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1749 | |
| 1750 | return 0; |
| 1751 | } |
| 1752 | |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame^] | 1753 | static int i915_dump_lrc(struct seq_file *m, void *unused) |
| 1754 | { |
| 1755 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1756 | struct drm_device *dev = node->minor->dev; |
| 1757 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1758 | struct intel_engine_cs *ring; |
| 1759 | struct intel_context *ctx; |
| 1760 | int ret, i; |
| 1761 | |
| 1762 | if (!i915.enable_execlists) { |
| 1763 | seq_printf(m, "Logical Ring Contexts are disabled\n"); |
| 1764 | return 0; |
| 1765 | } |
| 1766 | |
| 1767 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1768 | if (ret) |
| 1769 | return ret; |
| 1770 | |
| 1771 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
| 1772 | for_each_ring(ring, dev_priv, i) { |
| 1773 | struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state; |
| 1774 | |
| 1775 | if (ring->default_context == ctx) |
| 1776 | continue; |
| 1777 | |
| 1778 | if (ctx_obj) { |
| 1779 | struct page *page = i915_gem_object_get_page(ctx_obj, 1); |
| 1780 | uint32_t *reg_state = kmap_atomic(page); |
| 1781 | int j; |
| 1782 | |
| 1783 | seq_printf(m, "CONTEXT: %s %u\n", ring->name, |
| 1784 | intel_execlists_ctx_id(ctx_obj)); |
| 1785 | |
| 1786 | for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { |
| 1787 | seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 1788 | i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4), |
| 1789 | reg_state[j], reg_state[j + 1], |
| 1790 | reg_state[j + 2], reg_state[j + 3]); |
| 1791 | } |
| 1792 | kunmap_atomic(reg_state); |
| 1793 | |
| 1794 | seq_putc(m, '\n'); |
| 1795 | } |
| 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | mutex_unlock(&dev->struct_mutex); |
| 1800 | |
| 1801 | return 0; |
| 1802 | } |
| 1803 | |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 1804 | static int i915_execlists(struct seq_file *m, void *data) |
| 1805 | { |
| 1806 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
| 1807 | struct drm_device *dev = node->minor->dev; |
| 1808 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1809 | struct intel_engine_cs *ring; |
| 1810 | u32 status_pointer; |
| 1811 | u8 read_pointer; |
| 1812 | u8 write_pointer; |
| 1813 | u32 status; |
| 1814 | u32 ctx_id; |
| 1815 | struct list_head *cursor; |
| 1816 | int ring_id, i; |
| 1817 | int ret; |
| 1818 | |
| 1819 | if (!i915.enable_execlists) { |
| 1820 | seq_puts(m, "Logical Ring Contexts are disabled\n"); |
| 1821 | return 0; |
| 1822 | } |
| 1823 | |
| 1824 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1825 | if (ret) |
| 1826 | return ret; |
| 1827 | |
| 1828 | for_each_ring(ring, dev_priv, ring_id) { |
| 1829 | struct intel_ctx_submit_request *head_req = NULL; |
| 1830 | int count = 0; |
| 1831 | unsigned long flags; |
| 1832 | |
| 1833 | seq_printf(m, "%s\n", ring->name); |
| 1834 | |
| 1835 | status = I915_READ(RING_EXECLIST_STATUS(ring)); |
| 1836 | ctx_id = I915_READ(RING_EXECLIST_STATUS(ring) + 4); |
| 1837 | seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n", |
| 1838 | status, ctx_id); |
| 1839 | |
| 1840 | status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring)); |
| 1841 | seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer); |
| 1842 | |
| 1843 | read_pointer = ring->next_context_status_buffer; |
| 1844 | write_pointer = status_pointer & 0x07; |
| 1845 | if (read_pointer > write_pointer) |
| 1846 | write_pointer += 6; |
| 1847 | seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n", |
| 1848 | read_pointer, write_pointer); |
| 1849 | |
| 1850 | for (i = 0; i < 6; i++) { |
| 1851 | status = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i); |
| 1852 | ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i + 4); |
| 1853 | |
| 1854 | seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n", |
| 1855 | i, status, ctx_id); |
| 1856 | } |
| 1857 | |
| 1858 | spin_lock_irqsave(&ring->execlist_lock, flags); |
| 1859 | list_for_each(cursor, &ring->execlist_queue) |
| 1860 | count++; |
| 1861 | head_req = list_first_entry_or_null(&ring->execlist_queue, |
| 1862 | struct intel_ctx_submit_request, execlist_link); |
| 1863 | spin_unlock_irqrestore(&ring->execlist_lock, flags); |
| 1864 | |
| 1865 | seq_printf(m, "\t%d requests in queue\n", count); |
| 1866 | if (head_req) { |
| 1867 | struct drm_i915_gem_object *ctx_obj; |
| 1868 | |
| 1869 | ctx_obj = head_req->ctx->engine[ring_id].state; |
| 1870 | seq_printf(m, "\tHead request id: %u\n", |
| 1871 | intel_execlists_ctx_id(ctx_obj)); |
| 1872 | seq_printf(m, "\tHead request tail: %u\n", |
| 1873 | head_req->tail); |
| 1874 | } |
| 1875 | |
| 1876 | seq_putc(m, '\n'); |
| 1877 | } |
| 1878 | |
| 1879 | mutex_unlock(&dev->struct_mutex); |
| 1880 | |
| 1881 | return 0; |
| 1882 | } |
| 1883 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1884 | static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data) |
| 1885 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1886 | struct drm_info_node *node = m->private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1887 | struct drm_device *dev = node->minor->dev; |
| 1888 | struct drm_i915_private *dev_priv = dev->dev_private; |
Deepak S | 43709ba | 2013-11-23 14:55:44 +0530 | [diff] [blame] | 1889 | unsigned forcewake_count = 0, fw_rendercount = 0, fw_mediacount = 0; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1890 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1891 | spin_lock_irq(&dev_priv->uncore.lock); |
Deepak S | 43709ba | 2013-11-23 14:55:44 +0530 | [diff] [blame] | 1892 | if (IS_VALLEYVIEW(dev)) { |
| 1893 | fw_rendercount = dev_priv->uncore.fw_rendercount; |
| 1894 | fw_mediacount = dev_priv->uncore.fw_mediacount; |
| 1895 | } else |
| 1896 | forcewake_count = dev_priv->uncore.forcewake_count; |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1897 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 9f1f46a | 2011-12-14 13:57:03 +0100 | [diff] [blame] | 1898 | |
Deepak S | 43709ba | 2013-11-23 14:55:44 +0530 | [diff] [blame] | 1899 | if (IS_VALLEYVIEW(dev)) { |
| 1900 | seq_printf(m, "fw_rendercount = %u\n", fw_rendercount); |
| 1901 | seq_printf(m, "fw_mediacount = %u\n", fw_mediacount); |
| 1902 | } else |
| 1903 | seq_printf(m, "forcewake count = %u\n", forcewake_count); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1904 | |
| 1905 | return 0; |
| 1906 | } |
| 1907 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1908 | static const char *swizzle_string(unsigned swizzle) |
| 1909 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1910 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1911 | case I915_BIT_6_SWIZZLE_NONE: |
| 1912 | return "none"; |
| 1913 | case I915_BIT_6_SWIZZLE_9: |
| 1914 | return "bit9"; |
| 1915 | case I915_BIT_6_SWIZZLE_9_10: |
| 1916 | return "bit9/bit10"; |
| 1917 | case I915_BIT_6_SWIZZLE_9_11: |
| 1918 | return "bit9/bit11"; |
| 1919 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1920 | return "bit9/bit10/bit11"; |
| 1921 | case I915_BIT_6_SWIZZLE_9_17: |
| 1922 | return "bit9/bit17"; |
| 1923 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1924 | return "bit9/bit10/bit17"; |
| 1925 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1926 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1927 | } |
| 1928 | |
| 1929 | return "bug"; |
| 1930 | } |
| 1931 | |
| 1932 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1933 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 1934 | struct drm_info_node *node = m->private; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1935 | struct drm_device *dev = node->minor->dev; |
| 1936 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1937 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1938 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1939 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1940 | if (ret) |
| 1941 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1942 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1943 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1944 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1945 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1946 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1947 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1948 | |
| 1949 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 1950 | seq_printf(m, "DDC = 0x%08x\n", |
| 1951 | I915_READ(DCC)); |
| 1952 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1953 | I915_READ16(C0DRB3)); |
| 1954 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1955 | I915_READ16(C1DRB3)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 1956 | } else if (INTEL_INFO(dev)->gen >= 6) { |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1957 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1958 | I915_READ(MAD_DIMM_C0)); |
| 1959 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1960 | I915_READ(MAD_DIMM_C1)); |
| 1961 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1962 | I915_READ(MAD_DIMM_C2)); |
| 1963 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1964 | I915_READ(TILECTL)); |
Ben Widawsky | 9d3203e | 2013-11-02 21:07:14 -0700 | [diff] [blame] | 1965 | if (IS_GEN8(dev)) |
| 1966 | seq_printf(m, "GAMTARBMODE = 0x%08x\n", |
| 1967 | I915_READ(GAMTARBMODE)); |
| 1968 | else |
| 1969 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 1970 | I915_READ(ARB_MODE)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1971 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 1972 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1973 | } |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 1974 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1975 | mutex_unlock(&dev->struct_mutex); |
| 1976 | |
| 1977 | return 0; |
| 1978 | } |
| 1979 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 1980 | static int per_file_ctx(int id, void *ptr, void *data) |
| 1981 | { |
Oscar Mateo | 273497e | 2014-05-22 14:13:37 +0100 | [diff] [blame] | 1982 | struct intel_context *ctx = ptr; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 1983 | struct seq_file *m = data; |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 1984 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
| 1985 | |
| 1986 | if (!ppgtt) { |
| 1987 | seq_printf(m, " no ppgtt for context %d\n", |
| 1988 | ctx->user_handle); |
| 1989 | return 0; |
| 1990 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 1991 | |
Oscar Mateo | f83d651 | 2014-05-22 14:13:38 +0100 | [diff] [blame] | 1992 | if (i915_gem_context_is_default(ctx)) |
| 1993 | seq_puts(m, " default context:\n"); |
| 1994 | else |
Oscar Mateo | 821d66d | 2014-07-03 16:28:00 +0100 | [diff] [blame] | 1995 | seq_printf(m, " context %d:\n", ctx->user_handle); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 1996 | ppgtt->debug_dump(ppgtt, m); |
| 1997 | |
| 1998 | return 0; |
| 1999 | } |
| 2000 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2001 | 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] | 2002 | { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2003 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2004 | struct intel_engine_cs *ring; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2005 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2006 | int unused, i; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2007 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2008 | if (!ppgtt) |
| 2009 | return; |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2010 | |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2011 | seq_printf(m, "Page directories: %d\n", ppgtt->num_pd_pages); |
Ben Widawsky | 5abbcca | 2014-02-21 13:06:34 -0800 | [diff] [blame] | 2012 | seq_printf(m, "Page tables: %d\n", ppgtt->num_pd_entries); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2013 | for_each_ring(ring, dev_priv, unused) { |
| 2014 | seq_printf(m, "%s\n", ring->name); |
| 2015 | for (i = 0; i < 4; i++) { |
| 2016 | u32 offset = 0x270 + i * 8; |
| 2017 | u64 pdp = I915_READ(ring->mmio_base + offset + 4); |
| 2018 | pdp <<= 32; |
| 2019 | pdp |= I915_READ(ring->mmio_base + offset); |
Ville Syrjälä | a2a5b15 | 2014-03-31 18:17:16 +0300 | [diff] [blame] | 2020 | seq_printf(m, "\tPDP%d 0x%016llx\n", i, pdp); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2021 | } |
| 2022 | } |
| 2023 | } |
| 2024 | |
| 2025 | static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) |
| 2026 | { |
| 2027 | struct drm_i915_private *dev_priv = dev->dev_private; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 2028 | struct intel_engine_cs *ring; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2029 | struct drm_file *file; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2030 | int i; |
| 2031 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2032 | if (INTEL_INFO(dev)->gen == 6) |
| 2033 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 2034 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 2035 | for_each_ring(ring, dev_priv, i) { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2036 | seq_printf(m, "%s\n", ring->name); |
| 2037 | if (INTEL_INFO(dev)->gen == 7) |
| 2038 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 2039 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 2040 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 2041 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 2042 | } |
| 2043 | if (dev_priv->mm.aliasing_ppgtt) { |
| 2044 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 2045 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 2046 | seq_puts(m, "aliasing PPGTT:\n"); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2047 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2048 | |
Ben Widawsky | 87d60b6 | 2013-12-06 14:11:29 -0800 | [diff] [blame] | 2049 | ppgtt->debug_dump(ppgtt, m); |
Daniel Vetter | ae6c480 | 2014-08-06 15:04:53 +0200 | [diff] [blame] | 2050 | } |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2051 | |
| 2052 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 2053 | struct drm_i915_file_private *file_priv = file->driver_priv; |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2054 | |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2055 | seq_printf(m, "proc: %s\n", |
| 2056 | get_pid_task(file->pid, PIDTYPE_PID)->comm); |
Ben Widawsky | 1c60fef | 2013-12-06 14:11:30 -0800 | [diff] [blame] | 2057 | idr_for_each(&file_priv->context_idr, per_file_ctx, m); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2058 | } |
| 2059 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2060 | } |
| 2061 | |
| 2062 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 2063 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2064 | struct drm_info_node *node = m->private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2065 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2066 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2067 | |
| 2068 | int ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2069 | if (ret) |
| 2070 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2071 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | 77df677 | 2013-11-02 21:07:30 -0700 | [diff] [blame] | 2072 | |
| 2073 | if (INTEL_INFO(dev)->gen >= 8) |
| 2074 | gen8_ppgtt_info(m, dev); |
| 2075 | else if (INTEL_INFO(dev)->gen >= 6) |
| 2076 | gen6_ppgtt_info(m, dev); |
| 2077 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2078 | intel_runtime_pm_put(dev_priv); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2079 | mutex_unlock(&dev->struct_mutex); |
| 2080 | |
| 2081 | return 0; |
| 2082 | } |
| 2083 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2084 | static int i915_llc(struct seq_file *m, void *data) |
| 2085 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2086 | struct drm_info_node *node = m->private; |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2087 | struct drm_device *dev = node->minor->dev; |
| 2088 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2089 | |
| 2090 | /* Size calculation for LLC is a bit of a pain. Ignore for now. */ |
| 2091 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
| 2092 | seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size); |
| 2093 | |
| 2094 | return 0; |
| 2095 | } |
| 2096 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2097 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 2098 | { |
| 2099 | struct drm_info_node *node = m->private; |
| 2100 | struct drm_device *dev = node->minor->dev; |
| 2101 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2102 | u32 psrperf = 0; |
| 2103 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2104 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2105 | intel_runtime_pm_get(dev_priv); |
| 2106 | |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2107 | mutex_lock(&dev_priv->psr.lock); |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2108 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 2109 | 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] | 2110 | seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled)); |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2111 | seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active)); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2112 | seq_printf(m, "Busy frontbuffer bits: 0x%03x\n", |
| 2113 | dev_priv->psr.busy_frontbuffer_bits); |
| 2114 | seq_printf(m, "Re-enable work scheduled: %s\n", |
| 2115 | yesno(work_busy(&dev_priv->psr.work.work))); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2116 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2117 | enabled = HAS_PSR(dev) && |
| 2118 | I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE; |
Rodrigo Vivi | 5755c78 | 2014-06-12 10:16:45 -0700 | [diff] [blame] | 2119 | seq_printf(m, "HW Enabled & Active bit: %s\n", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2120 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 2121 | if (HAS_PSR(dev)) |
| 2122 | psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) & |
| 2123 | EDP_PSR_PERF_CNT_MASK; |
| 2124 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
Daniel Vetter | fa128fa | 2014-07-11 10:30:17 -0700 | [diff] [blame] | 2125 | mutex_unlock(&dev_priv->psr.lock); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2126 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 2127 | intel_runtime_pm_put(dev_priv); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2128 | return 0; |
| 2129 | } |
| 2130 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2131 | static int i915_sink_crc(struct seq_file *m, void *data) |
| 2132 | { |
| 2133 | struct drm_info_node *node = m->private; |
| 2134 | struct drm_device *dev = node->minor->dev; |
| 2135 | struct intel_encoder *encoder; |
| 2136 | struct intel_connector *connector; |
| 2137 | struct intel_dp *intel_dp = NULL; |
| 2138 | int ret; |
| 2139 | u8 crc[6]; |
| 2140 | |
| 2141 | drm_modeset_lock_all(dev); |
| 2142 | list_for_each_entry(connector, &dev->mode_config.connector_list, |
| 2143 | base.head) { |
| 2144 | |
| 2145 | if (connector->base.dpms != DRM_MODE_DPMS_ON) |
| 2146 | continue; |
| 2147 | |
Paulo Zanoni | b6ae3c7 | 2014-02-13 17:51:33 -0200 | [diff] [blame] | 2148 | if (!connector->base.encoder) |
| 2149 | continue; |
| 2150 | |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 2151 | encoder = to_intel_encoder(connector->base.encoder); |
| 2152 | if (encoder->type != INTEL_OUTPUT_EDP) |
| 2153 | continue; |
| 2154 | |
| 2155 | intel_dp = enc_to_intel_dp(&encoder->base); |
| 2156 | |
| 2157 | ret = intel_dp_sink_crc(intel_dp, crc); |
| 2158 | if (ret) |
| 2159 | goto out; |
| 2160 | |
| 2161 | seq_printf(m, "%02x%02x%02x%02x%02x%02x\n", |
| 2162 | crc[0], crc[1], crc[2], |
| 2163 | crc[3], crc[4], crc[5]); |
| 2164 | goto out; |
| 2165 | } |
| 2166 | ret = -ENODEV; |
| 2167 | out: |
| 2168 | drm_modeset_unlock_all(dev); |
| 2169 | return ret; |
| 2170 | } |
| 2171 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2172 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 2173 | { |
| 2174 | struct drm_info_node *node = m->private; |
| 2175 | struct drm_device *dev = node->minor->dev; |
| 2176 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2177 | u64 power; |
| 2178 | u32 units; |
| 2179 | |
| 2180 | if (INTEL_INFO(dev)->gen < 6) |
| 2181 | return -ENODEV; |
| 2182 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2183 | intel_runtime_pm_get(dev_priv); |
| 2184 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2185 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 2186 | power = (power & 0x1f00) >> 8; |
| 2187 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 2188 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 2189 | power *= units; |
| 2190 | |
Paulo Zanoni | 36623ef | 2014-02-21 13:52:23 -0300 | [diff] [blame] | 2191 | intel_runtime_pm_put(dev_priv); |
| 2192 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2193 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2194 | |
| 2195 | return 0; |
| 2196 | } |
| 2197 | |
| 2198 | static int i915_pc8_status(struct seq_file *m, void *unused) |
| 2199 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2200 | struct drm_info_node *node = m->private; |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2201 | struct drm_device *dev = node->minor->dev; |
| 2202 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2203 | |
Zhenyu Wang | 85b8d5c | 2014-04-01 19:39:48 -0300 | [diff] [blame] | 2204 | if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2205 | seq_puts(m, "not supported\n"); |
| 2206 | return 0; |
| 2207 | } |
| 2208 | |
Paulo Zanoni | 86c4ec0 | 2014-02-21 13:52:24 -0300 | [diff] [blame] | 2209 | seq_printf(m, "GPU idle: %s\n", yesno(!dev_priv->mm.busy)); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2210 | seq_printf(m, "IRQs disabled: %s\n", |
Jesse Barnes | 9df7575f | 2014-06-20 09:29:20 -0700 | [diff] [blame] | 2211 | yesno(!intel_irqs_enabled(dev_priv))); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2212 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2213 | return 0; |
| 2214 | } |
| 2215 | |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2216 | static const char *power_domain_str(enum intel_display_power_domain domain) |
| 2217 | { |
| 2218 | switch (domain) { |
| 2219 | case POWER_DOMAIN_PIPE_A: |
| 2220 | return "PIPE_A"; |
| 2221 | case POWER_DOMAIN_PIPE_B: |
| 2222 | return "PIPE_B"; |
| 2223 | case POWER_DOMAIN_PIPE_C: |
| 2224 | return "PIPE_C"; |
| 2225 | case POWER_DOMAIN_PIPE_A_PANEL_FITTER: |
| 2226 | return "PIPE_A_PANEL_FITTER"; |
| 2227 | case POWER_DOMAIN_PIPE_B_PANEL_FITTER: |
| 2228 | return "PIPE_B_PANEL_FITTER"; |
| 2229 | case POWER_DOMAIN_PIPE_C_PANEL_FITTER: |
| 2230 | return "PIPE_C_PANEL_FITTER"; |
| 2231 | case POWER_DOMAIN_TRANSCODER_A: |
| 2232 | return "TRANSCODER_A"; |
| 2233 | case POWER_DOMAIN_TRANSCODER_B: |
| 2234 | return "TRANSCODER_B"; |
| 2235 | case POWER_DOMAIN_TRANSCODER_C: |
| 2236 | return "TRANSCODER_C"; |
| 2237 | case POWER_DOMAIN_TRANSCODER_EDP: |
| 2238 | return "TRANSCODER_EDP"; |
Imre Deak | 319be8a | 2014-03-04 19:22:57 +0200 | [diff] [blame] | 2239 | case POWER_DOMAIN_PORT_DDI_A_2_LANES: |
| 2240 | return "PORT_DDI_A_2_LANES"; |
| 2241 | case POWER_DOMAIN_PORT_DDI_A_4_LANES: |
| 2242 | return "PORT_DDI_A_4_LANES"; |
| 2243 | case POWER_DOMAIN_PORT_DDI_B_2_LANES: |
| 2244 | return "PORT_DDI_B_2_LANES"; |
| 2245 | case POWER_DOMAIN_PORT_DDI_B_4_LANES: |
| 2246 | return "PORT_DDI_B_4_LANES"; |
| 2247 | case POWER_DOMAIN_PORT_DDI_C_2_LANES: |
| 2248 | return "PORT_DDI_C_2_LANES"; |
| 2249 | case POWER_DOMAIN_PORT_DDI_C_4_LANES: |
| 2250 | return "PORT_DDI_C_4_LANES"; |
| 2251 | case POWER_DOMAIN_PORT_DDI_D_2_LANES: |
| 2252 | return "PORT_DDI_D_2_LANES"; |
| 2253 | case POWER_DOMAIN_PORT_DDI_D_4_LANES: |
| 2254 | return "PORT_DDI_D_4_LANES"; |
| 2255 | case POWER_DOMAIN_PORT_DSI: |
| 2256 | return "PORT_DSI"; |
| 2257 | case POWER_DOMAIN_PORT_CRT: |
| 2258 | return "PORT_CRT"; |
| 2259 | case POWER_DOMAIN_PORT_OTHER: |
| 2260 | return "PORT_OTHER"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2261 | case POWER_DOMAIN_VGA: |
| 2262 | return "VGA"; |
| 2263 | case POWER_DOMAIN_AUDIO: |
| 2264 | return "AUDIO"; |
Paulo Zanoni | bd2bb1b | 2014-07-04 11:27:38 -0300 | [diff] [blame] | 2265 | case POWER_DOMAIN_PLLS: |
| 2266 | return "PLLS"; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2267 | case POWER_DOMAIN_INIT: |
| 2268 | return "INIT"; |
| 2269 | default: |
| 2270 | WARN_ON(1); |
| 2271 | return "?"; |
| 2272 | } |
| 2273 | } |
| 2274 | |
| 2275 | static int i915_power_domain_info(struct seq_file *m, void *unused) |
| 2276 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2277 | struct drm_info_node *node = m->private; |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 2278 | struct drm_device *dev = node->minor->dev; |
| 2279 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2280 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2281 | int i; |
| 2282 | |
| 2283 | mutex_lock(&power_domains->lock); |
| 2284 | |
| 2285 | seq_printf(m, "%-25s %s\n", "Power well/domain", "Use count"); |
| 2286 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2287 | struct i915_power_well *power_well; |
| 2288 | enum intel_display_power_domain power_domain; |
| 2289 | |
| 2290 | power_well = &power_domains->power_wells[i]; |
| 2291 | seq_printf(m, "%-25s %d\n", power_well->name, |
| 2292 | power_well->count); |
| 2293 | |
| 2294 | for (power_domain = 0; power_domain < POWER_DOMAIN_NUM; |
| 2295 | power_domain++) { |
| 2296 | if (!(BIT(power_domain) & power_well->domains)) |
| 2297 | continue; |
| 2298 | |
| 2299 | seq_printf(m, " %-23s %d\n", |
| 2300 | power_domain_str(power_domain), |
| 2301 | power_domains->domain_use_count[power_domain]); |
| 2302 | } |
| 2303 | } |
| 2304 | |
| 2305 | mutex_unlock(&power_domains->lock); |
| 2306 | |
| 2307 | return 0; |
| 2308 | } |
| 2309 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2310 | static void intel_seq_print_mode(struct seq_file *m, int tabs, |
| 2311 | struct drm_display_mode *mode) |
| 2312 | { |
| 2313 | int i; |
| 2314 | |
| 2315 | for (i = 0; i < tabs; i++) |
| 2316 | seq_putc(m, '\t'); |
| 2317 | |
| 2318 | 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", |
| 2319 | mode->base.id, mode->name, |
| 2320 | mode->vrefresh, mode->clock, |
| 2321 | mode->hdisplay, mode->hsync_start, |
| 2322 | mode->hsync_end, mode->htotal, |
| 2323 | mode->vdisplay, mode->vsync_start, |
| 2324 | mode->vsync_end, mode->vtotal, |
| 2325 | mode->type, mode->flags); |
| 2326 | } |
| 2327 | |
| 2328 | static void intel_encoder_info(struct seq_file *m, |
| 2329 | struct intel_crtc *intel_crtc, |
| 2330 | struct intel_encoder *intel_encoder) |
| 2331 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2332 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2333 | struct drm_device *dev = node->minor->dev; |
| 2334 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2335 | struct intel_connector *intel_connector; |
| 2336 | struct drm_encoder *encoder; |
| 2337 | |
| 2338 | encoder = &intel_encoder->base; |
| 2339 | seq_printf(m, "\tencoder %d: type: %s, connectors:\n", |
Jani Nikula | 8e329a0 | 2014-06-03 14:56:21 +0300 | [diff] [blame] | 2340 | encoder->base.id, encoder->name); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2341 | for_each_connector_on_encoder(dev, encoder, intel_connector) { |
| 2342 | struct drm_connector *connector = &intel_connector->base; |
| 2343 | seq_printf(m, "\t\tconnector %d: type: %s, status: %s", |
| 2344 | connector->base.id, |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2345 | connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2346 | drm_get_connector_status_name(connector->status)); |
| 2347 | if (connector->status == connector_status_connected) { |
| 2348 | struct drm_display_mode *mode = &crtc->mode; |
| 2349 | seq_printf(m, ", mode:\n"); |
| 2350 | intel_seq_print_mode(m, 2, mode); |
| 2351 | } else { |
| 2352 | seq_putc(m, '\n'); |
| 2353 | } |
| 2354 | } |
| 2355 | } |
| 2356 | |
| 2357 | static void intel_crtc_info(struct seq_file *m, struct intel_crtc *intel_crtc) |
| 2358 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2359 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2360 | struct drm_device *dev = node->minor->dev; |
| 2361 | struct drm_crtc *crtc = &intel_crtc->base; |
| 2362 | struct intel_encoder *intel_encoder; |
| 2363 | |
Matt Roper | 5aa8a93 | 2014-06-16 10:12:55 -0700 | [diff] [blame] | 2364 | if (crtc->primary->fb) |
| 2365 | seq_printf(m, "\tfb: %d, pos: %dx%d, size: %dx%d\n", |
| 2366 | crtc->primary->fb->base.id, crtc->x, crtc->y, |
| 2367 | crtc->primary->fb->width, crtc->primary->fb->height); |
| 2368 | else |
| 2369 | seq_puts(m, "\tprimary plane disabled\n"); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2370 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
| 2371 | intel_encoder_info(m, intel_crtc, intel_encoder); |
| 2372 | } |
| 2373 | |
| 2374 | static void intel_panel_info(struct seq_file *m, struct intel_panel *panel) |
| 2375 | { |
| 2376 | struct drm_display_mode *mode = panel->fixed_mode; |
| 2377 | |
| 2378 | seq_printf(m, "\tfixed mode:\n"); |
| 2379 | intel_seq_print_mode(m, 2, mode); |
| 2380 | } |
| 2381 | |
| 2382 | static void intel_dp_info(struct seq_file *m, |
| 2383 | struct intel_connector *intel_connector) |
| 2384 | { |
| 2385 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2386 | struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); |
| 2387 | |
| 2388 | seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); |
| 2389 | seq_printf(m, "\taudio support: %s\n", intel_dp->has_audio ? "yes" : |
| 2390 | "no"); |
| 2391 | if (intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2392 | intel_panel_info(m, &intel_connector->panel); |
| 2393 | } |
| 2394 | |
| 2395 | static void intel_hdmi_info(struct seq_file *m, |
| 2396 | struct intel_connector *intel_connector) |
| 2397 | { |
| 2398 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
| 2399 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
| 2400 | |
| 2401 | seq_printf(m, "\taudio support: %s\n", intel_hdmi->has_audio ? "yes" : |
| 2402 | "no"); |
| 2403 | } |
| 2404 | |
| 2405 | static void intel_lvds_info(struct seq_file *m, |
| 2406 | struct intel_connector *intel_connector) |
| 2407 | { |
| 2408 | intel_panel_info(m, &intel_connector->panel); |
| 2409 | } |
| 2410 | |
| 2411 | static void intel_connector_info(struct seq_file *m, |
| 2412 | struct drm_connector *connector) |
| 2413 | { |
| 2414 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| 2415 | struct intel_encoder *intel_encoder = intel_connector->encoder; |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2416 | struct drm_display_mode *mode; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2417 | |
| 2418 | seq_printf(m, "connector %d: type %s, status: %s\n", |
Jani Nikula | c23cc41 | 2014-06-03 14:56:17 +0300 | [diff] [blame] | 2419 | connector->base.id, connector->name, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2420 | drm_get_connector_status_name(connector->status)); |
| 2421 | if (connector->status == connector_status_connected) { |
| 2422 | seq_printf(m, "\tname: %s\n", connector->display_info.name); |
| 2423 | seq_printf(m, "\tphysical dimensions: %dx%dmm\n", |
| 2424 | connector->display_info.width_mm, |
| 2425 | connector->display_info.height_mm); |
| 2426 | seq_printf(m, "\tsubpixel order: %s\n", |
| 2427 | drm_get_subpixel_order_name(connector->display_info.subpixel_order)); |
| 2428 | seq_printf(m, "\tCEA rev: %d\n", |
| 2429 | connector->display_info.cea_rev); |
| 2430 | } |
Dave Airlie | 36cd744 | 2014-05-02 13:44:18 +1000 | [diff] [blame] | 2431 | if (intel_encoder) { |
| 2432 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || |
| 2433 | intel_encoder->type == INTEL_OUTPUT_EDP) |
| 2434 | intel_dp_info(m, intel_connector); |
| 2435 | else if (intel_encoder->type == INTEL_OUTPUT_HDMI) |
| 2436 | intel_hdmi_info(m, intel_connector); |
| 2437 | else if (intel_encoder->type == INTEL_OUTPUT_LVDS) |
| 2438 | intel_lvds_info(m, intel_connector); |
| 2439 | } |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2440 | |
Jesse Barnes | f103fc7 | 2014-02-20 12:39:57 -0800 | [diff] [blame] | 2441 | seq_printf(m, "\tmodes:\n"); |
| 2442 | list_for_each_entry(mode, &connector->modes, head) |
| 2443 | intel_seq_print_mode(m, 2, mode); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2444 | } |
| 2445 | |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2446 | static bool cursor_active(struct drm_device *dev, int pipe) |
| 2447 | { |
| 2448 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2449 | u32 state; |
| 2450 | |
| 2451 | if (IS_845G(dev) || IS_I865G(dev)) |
| 2452 | state = I915_READ(_CURACNTR) & CURSOR_ENABLE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2453 | else |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2454 | state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2455 | |
| 2456 | return state; |
| 2457 | } |
| 2458 | |
| 2459 | static bool cursor_position(struct drm_device *dev, int pipe, int *x, int *y) |
| 2460 | { |
| 2461 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2462 | u32 pos; |
| 2463 | |
Ville Syrjälä | 5efb3e2 | 2014-04-09 13:28:53 +0300 | [diff] [blame] | 2464 | pos = I915_READ(CURPOS(pipe)); |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2465 | |
| 2466 | *x = (pos >> CURSOR_X_SHIFT) & CURSOR_POS_MASK; |
| 2467 | if (pos & (CURSOR_POS_SIGN << CURSOR_X_SHIFT)) |
| 2468 | *x = -*x; |
| 2469 | |
| 2470 | *y = (pos >> CURSOR_Y_SHIFT) & CURSOR_POS_MASK; |
| 2471 | if (pos & (CURSOR_POS_SIGN << CURSOR_Y_SHIFT)) |
| 2472 | *y = -*y; |
| 2473 | |
| 2474 | return cursor_active(dev, pipe); |
| 2475 | } |
| 2476 | |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2477 | static int i915_display_info(struct seq_file *m, void *unused) |
| 2478 | { |
Damien Lespiau | 9f25d00 | 2014-05-13 15:30:28 +0100 | [diff] [blame] | 2479 | struct drm_info_node *node = m->private; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2480 | struct drm_device *dev = node->minor->dev; |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2481 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2482 | struct intel_crtc *crtc; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2483 | struct drm_connector *connector; |
| 2484 | |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2485 | intel_runtime_pm_get(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2486 | drm_modeset_lock_all(dev); |
| 2487 | seq_printf(m, "CRTC info\n"); |
| 2488 | seq_printf(m, "---------\n"); |
Damien Lespiau | d3fcc80 | 2014-05-13 23:32:22 +0100 | [diff] [blame] | 2489 | for_each_intel_crtc(dev, crtc) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2490 | bool active; |
| 2491 | int x, y; |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2492 | |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2493 | seq_printf(m, "CRTC %d: pipe: %c, active=%s (size=%dx%d)\n", |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2494 | crtc->base.base.id, pipe_name(crtc->pipe), |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2495 | yesno(crtc->active), crtc->config.pipe_src_w, crtc->config.pipe_src_h); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2496 | if (crtc->active) { |
Chris Wilson | 065f2ec | 2014-03-12 09:13:13 +0000 | [diff] [blame] | 2497 | intel_crtc_info(m, crtc); |
| 2498 | |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2499 | active = cursor_position(dev, crtc->pipe, &x, &y); |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2500 | 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] | 2501 | yesno(crtc->cursor_base), |
Chris Wilson | 57127ef | 2014-07-04 08:20:11 +0100 | [diff] [blame] | 2502 | x, y, crtc->cursor_width, crtc->cursor_height, |
| 2503 | crtc->cursor_addr, yesno(active)); |
Paulo Zanoni | a23dc65 | 2014-04-01 14:55:11 -0300 | [diff] [blame] | 2504 | } |
Daniel Vetter | cace841 | 2014-05-22 17:56:31 +0200 | [diff] [blame] | 2505 | |
| 2506 | seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", |
| 2507 | yesno(!crtc->cpu_fifo_underrun_disabled), |
| 2508 | yesno(!crtc->pch_fifo_underrun_disabled)); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2509 | } |
| 2510 | |
| 2511 | seq_printf(m, "\n"); |
| 2512 | seq_printf(m, "Connector info\n"); |
| 2513 | seq_printf(m, "--------------\n"); |
| 2514 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 2515 | intel_connector_info(m, connector); |
| 2516 | } |
| 2517 | drm_modeset_unlock_all(dev); |
Paulo Zanoni | b0e5ddf | 2014-04-01 14:55:10 -0300 | [diff] [blame] | 2518 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 2519 | |
| 2520 | return 0; |
| 2521 | } |
| 2522 | |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2523 | static int i915_semaphore_status(struct seq_file *m, void *unused) |
| 2524 | { |
| 2525 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2526 | struct drm_device *dev = node->minor->dev; |
| 2527 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2528 | struct intel_engine_cs *ring; |
| 2529 | int num_rings = hweight32(INTEL_INFO(dev)->ring_mask); |
| 2530 | int i, j, ret; |
| 2531 | |
| 2532 | if (!i915_semaphore_is_enabled(dev)) { |
| 2533 | seq_puts(m, "Semaphores are disabled\n"); |
| 2534 | return 0; |
| 2535 | } |
| 2536 | |
| 2537 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2538 | if (ret) |
| 2539 | return ret; |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2540 | intel_runtime_pm_get(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2541 | |
| 2542 | if (IS_BROADWELL(dev)) { |
| 2543 | struct page *page; |
| 2544 | uint64_t *seqno; |
| 2545 | |
| 2546 | page = i915_gem_object_get_page(dev_priv->semaphore_obj, 0); |
| 2547 | |
| 2548 | seqno = (uint64_t *)kmap_atomic(page); |
| 2549 | for_each_ring(ring, dev_priv, i) { |
| 2550 | uint64_t offset; |
| 2551 | |
| 2552 | seq_printf(m, "%s\n", ring->name); |
| 2553 | |
| 2554 | seq_puts(m, " Last signal:"); |
| 2555 | for (j = 0; j < num_rings; j++) { |
| 2556 | offset = i * I915_NUM_RINGS + j; |
| 2557 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2558 | seqno[offset], offset * 8); |
| 2559 | } |
| 2560 | seq_putc(m, '\n'); |
| 2561 | |
| 2562 | seq_puts(m, " Last wait: "); |
| 2563 | for (j = 0; j < num_rings; j++) { |
| 2564 | offset = i + (j * I915_NUM_RINGS); |
| 2565 | seq_printf(m, "0x%08llx (0x%02llx) ", |
| 2566 | seqno[offset], offset * 8); |
| 2567 | } |
| 2568 | seq_putc(m, '\n'); |
| 2569 | |
| 2570 | } |
| 2571 | kunmap_atomic(seqno); |
| 2572 | } else { |
| 2573 | seq_puts(m, " Last signal:"); |
| 2574 | for_each_ring(ring, dev_priv, i) |
| 2575 | for (j = 0; j < num_rings; j++) |
| 2576 | seq_printf(m, "0x%08x\n", |
| 2577 | I915_READ(ring->semaphore.mbox.signal[j])); |
| 2578 | seq_putc(m, '\n'); |
| 2579 | } |
| 2580 | |
| 2581 | seq_puts(m, "\nSync seqno:\n"); |
| 2582 | for_each_ring(ring, dev_priv, i) { |
| 2583 | for (j = 0; j < num_rings; j++) { |
| 2584 | seq_printf(m, " 0x%08x ", ring->semaphore.sync_seqno[j]); |
| 2585 | } |
| 2586 | seq_putc(m, '\n'); |
| 2587 | } |
| 2588 | seq_putc(m, '\n'); |
| 2589 | |
Paulo Zanoni | 0387206 | 2014-07-09 14:31:57 -0300 | [diff] [blame] | 2590 | intel_runtime_pm_put(dev_priv); |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 2591 | mutex_unlock(&dev->struct_mutex); |
| 2592 | return 0; |
| 2593 | } |
| 2594 | |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2595 | static int i915_shared_dplls_info(struct seq_file *m, void *unused) |
| 2596 | { |
| 2597 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2598 | struct drm_device *dev = node->minor->dev; |
| 2599 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2600 | int i; |
| 2601 | |
| 2602 | drm_modeset_lock_all(dev); |
| 2603 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
| 2604 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
| 2605 | |
| 2606 | seq_printf(m, "DPLL%i: %s, id: %i\n", i, pll->name, pll->id); |
| 2607 | seq_printf(m, " refcount: %i, active: %i, on: %s\n", pll->refcount, |
| 2608 | pll->active, yesno(pll->on)); |
| 2609 | seq_printf(m, " tracked hardware state:\n"); |
| 2610 | seq_printf(m, " dpll: 0x%08x\n", pll->hw_state.dpll); |
| 2611 | seq_printf(m, " dpll_md: 0x%08x\n", pll->hw_state.dpll_md); |
| 2612 | seq_printf(m, " fp0: 0x%08x\n", pll->hw_state.fp0); |
| 2613 | seq_printf(m, " fp1: 0x%08x\n", pll->hw_state.fp1); |
Daniel Vetter | d452c5b | 2014-07-04 11:27:39 -0300 | [diff] [blame] | 2614 | seq_printf(m, " wrpll: 0x%08x\n", pll->hw_state.wrpll); |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 2615 | } |
| 2616 | drm_modeset_unlock_all(dev); |
| 2617 | |
| 2618 | return 0; |
| 2619 | } |
| 2620 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2621 | struct pipe_crc_info { |
| 2622 | const char *name; |
| 2623 | struct drm_device *dev; |
| 2624 | enum pipe pipe; |
| 2625 | }; |
| 2626 | |
Dave Airlie | 11bed958 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 2627 | static int i915_dp_mst_info(struct seq_file *m, void *unused) |
| 2628 | { |
| 2629 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 2630 | struct drm_device *dev = node->minor->dev; |
| 2631 | struct drm_encoder *encoder; |
| 2632 | struct intel_encoder *intel_encoder; |
| 2633 | struct intel_digital_port *intel_dig_port; |
| 2634 | drm_modeset_lock_all(dev); |
| 2635 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 2636 | intel_encoder = to_intel_encoder(encoder); |
| 2637 | if (intel_encoder->type != INTEL_OUTPUT_DISPLAYPORT) |
| 2638 | continue; |
| 2639 | intel_dig_port = enc_to_dig_port(encoder); |
| 2640 | if (!intel_dig_port->dp.can_mst) |
| 2641 | continue; |
| 2642 | |
| 2643 | drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); |
| 2644 | } |
| 2645 | drm_modeset_unlock_all(dev); |
| 2646 | return 0; |
| 2647 | } |
| 2648 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2649 | static int i915_pipe_crc_open(struct inode *inode, struct file *filep) |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2650 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2651 | struct pipe_crc_info *info = inode->i_private; |
| 2652 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2653 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2654 | |
Daniel Vetter | 7eb1c49 | 2013-11-14 11:30:43 +0100 | [diff] [blame] | 2655 | if (info->pipe >= INTEL_INFO(info->dev)->num_pipes) |
| 2656 | return -ENODEV; |
| 2657 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2658 | spin_lock_irq(&pipe_crc->lock); |
| 2659 | |
| 2660 | if (pipe_crc->opened) { |
| 2661 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2662 | return -EBUSY; /* already open */ |
| 2663 | } |
| 2664 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2665 | pipe_crc->opened = true; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2666 | filep->private_data = inode->i_private; |
| 2667 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2668 | spin_unlock_irq(&pipe_crc->lock); |
| 2669 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2670 | return 0; |
| 2671 | } |
| 2672 | |
| 2673 | static int i915_pipe_crc_release(struct inode *inode, struct file *filep) |
| 2674 | { |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2675 | struct pipe_crc_info *info = inode->i_private; |
| 2676 | struct drm_i915_private *dev_priv = info->dev->dev_private; |
| 2677 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2678 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2679 | spin_lock_irq(&pipe_crc->lock); |
| 2680 | pipe_crc->opened = false; |
| 2681 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | be5c7a9 | 2013-10-15 18:55:41 +0100 | [diff] [blame] | 2682 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2683 | return 0; |
| 2684 | } |
| 2685 | |
| 2686 | /* (6 fields, 8 chars each, space separated (5) + '\n') */ |
| 2687 | #define PIPE_CRC_LINE_LEN (6 * 8 + 5 + 1) |
| 2688 | /* account for \'0' */ |
| 2689 | #define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1) |
| 2690 | |
| 2691 | static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc) |
| 2692 | { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2693 | assert_spin_locked(&pipe_crc->lock); |
| 2694 | return CIRC_CNT(pipe_crc->head, pipe_crc->tail, |
| 2695 | INTEL_PIPE_CRC_ENTRIES_NR); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2696 | } |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2697 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2698 | static ssize_t |
| 2699 | i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count, |
| 2700 | loff_t *pos) |
| 2701 | { |
| 2702 | struct pipe_crc_info *info = filep->private_data; |
| 2703 | struct drm_device *dev = info->dev; |
| 2704 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2705 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe]; |
| 2706 | char buf[PIPE_CRC_BUFFER_LEN]; |
| 2707 | int head, tail, n_entries, n; |
| 2708 | ssize_t bytes_read; |
| 2709 | |
| 2710 | /* |
| 2711 | * Don't allow user space to provide buffers not big enough to hold |
| 2712 | * a line of data. |
| 2713 | */ |
| 2714 | if (count < PIPE_CRC_LINE_LEN) |
| 2715 | return -EINVAL; |
| 2716 | |
| 2717 | if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE) |
| 2718 | return 0; |
| 2719 | |
| 2720 | /* nothing to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2721 | spin_lock_irq(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2722 | while (pipe_crc_data_count(pipe_crc) == 0) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2723 | int ret; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2724 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2725 | if (filep->f_flags & O_NONBLOCK) { |
| 2726 | spin_unlock_irq(&pipe_crc->lock); |
| 2727 | return -EAGAIN; |
| 2728 | } |
| 2729 | |
| 2730 | ret = wait_event_interruptible_lock_irq(pipe_crc->wq, |
| 2731 | pipe_crc_data_count(pipe_crc), pipe_crc->lock); |
| 2732 | if (ret) { |
| 2733 | spin_unlock_irq(&pipe_crc->lock); |
| 2734 | return ret; |
| 2735 | } |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2736 | } |
| 2737 | |
| 2738 | /* We now have one or more entries to read */ |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2739 | head = pipe_crc->head; |
| 2740 | tail = pipe_crc->tail; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2741 | n_entries = min((size_t)CIRC_CNT(head, tail, INTEL_PIPE_CRC_ENTRIES_NR), |
| 2742 | count / PIPE_CRC_LINE_LEN); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2743 | spin_unlock_irq(&pipe_crc->lock); |
| 2744 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2745 | bytes_read = 0; |
| 2746 | n = 0; |
| 2747 | do { |
| 2748 | struct intel_pipe_crc_entry *entry = &pipe_crc->entries[tail]; |
| 2749 | int ret; |
| 2750 | |
| 2751 | bytes_read += snprintf(buf, PIPE_CRC_BUFFER_LEN, |
| 2752 | "%8u %8x %8x %8x %8x %8x\n", |
| 2753 | entry->frame, entry->crc[0], |
| 2754 | entry->crc[1], entry->crc[2], |
| 2755 | entry->crc[3], entry->crc[4]); |
| 2756 | |
| 2757 | ret = copy_to_user(user_buf + n * PIPE_CRC_LINE_LEN, |
| 2758 | buf, PIPE_CRC_LINE_LEN); |
| 2759 | if (ret == PIPE_CRC_LINE_LEN) |
| 2760 | return -EFAULT; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 2761 | |
| 2762 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 2763 | tail = (tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2764 | n++; |
| 2765 | } while (--n_entries); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2766 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 2767 | spin_lock_irq(&pipe_crc->lock); |
| 2768 | pipe_crc->tail = tail; |
| 2769 | spin_unlock_irq(&pipe_crc->lock); |
| 2770 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2771 | return bytes_read; |
| 2772 | } |
| 2773 | |
| 2774 | static const struct file_operations i915_pipe_crc_fops = { |
| 2775 | .owner = THIS_MODULE, |
| 2776 | .open = i915_pipe_crc_open, |
| 2777 | .read = i915_pipe_crc_read, |
| 2778 | .release = i915_pipe_crc_release, |
| 2779 | }; |
| 2780 | |
| 2781 | static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = { |
| 2782 | { |
| 2783 | .name = "i915_pipe_A_crc", |
| 2784 | .pipe = PIPE_A, |
| 2785 | }, |
| 2786 | { |
| 2787 | .name = "i915_pipe_B_crc", |
| 2788 | .pipe = PIPE_B, |
| 2789 | }, |
| 2790 | { |
| 2791 | .name = "i915_pipe_C_crc", |
| 2792 | .pipe = PIPE_C, |
| 2793 | }, |
| 2794 | }; |
| 2795 | |
| 2796 | static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor, |
| 2797 | enum pipe pipe) |
| 2798 | { |
| 2799 | struct drm_device *dev = minor->dev; |
| 2800 | struct dentry *ent; |
| 2801 | struct pipe_crc_info *info = &i915_pipe_crc_data[pipe]; |
| 2802 | |
| 2803 | info->dev = dev; |
| 2804 | ent = debugfs_create_file(info->name, S_IRUGO, root, info, |
| 2805 | &i915_pipe_crc_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 2806 | if (!ent) |
| 2807 | return -ENOMEM; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 2808 | |
| 2809 | return drm_add_fake_info_node(minor, ent, info); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2810 | } |
| 2811 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 2812 | static const char * const pipe_crc_sources[] = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2813 | "none", |
| 2814 | "plane1", |
| 2815 | "plane2", |
| 2816 | "pf", |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 2817 | "pipe", |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 2818 | "TV", |
| 2819 | "DP-B", |
| 2820 | "DP-C", |
| 2821 | "DP-D", |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2822 | "auto", |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2823 | }; |
| 2824 | |
| 2825 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 2826 | { |
| 2827 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 2828 | return pipe_crc_sources[source]; |
| 2829 | } |
| 2830 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2831 | static int display_crc_ctl_show(struct seq_file *m, void *data) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2832 | { |
| 2833 | struct drm_device *dev = m->private; |
| 2834 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2835 | int i; |
| 2836 | |
| 2837 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 2838 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 2839 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 2840 | |
| 2841 | return 0; |
| 2842 | } |
| 2843 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2844 | static int display_crc_ctl_open(struct inode *inode, struct file *file) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2845 | { |
| 2846 | struct drm_device *dev = inode->i_private; |
| 2847 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 2848 | return single_open(file, display_crc_ctl_show, dev); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2849 | } |
| 2850 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2851 | 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] | 2852 | uint32_t *val) |
| 2853 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2854 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 2855 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2856 | |
| 2857 | switch (*source) { |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 2858 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2859 | *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; |
| 2860 | break; |
| 2861 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 2862 | *val = 0; |
| 2863 | break; |
| 2864 | default: |
| 2865 | return -EINVAL; |
| 2866 | } |
| 2867 | |
| 2868 | return 0; |
| 2869 | } |
| 2870 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2871 | static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe, |
| 2872 | enum intel_pipe_crc_source *source) |
| 2873 | { |
| 2874 | struct intel_encoder *encoder; |
| 2875 | struct intel_crtc *crtc; |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 2876 | struct intel_digital_port *dig_port; |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2877 | int ret = 0; |
| 2878 | |
| 2879 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 2880 | |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 2881 | drm_modeset_lock_all(dev); |
Damien Lespiau | b2784e1 | 2014-08-05 11:29:37 +0100 | [diff] [blame] | 2882 | for_each_intel_encoder(dev, encoder) { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2883 | if (!encoder->base.crtc) |
| 2884 | continue; |
| 2885 | |
| 2886 | crtc = to_intel_crtc(encoder->base.crtc); |
| 2887 | |
| 2888 | if (crtc->pipe != pipe) |
| 2889 | continue; |
| 2890 | |
| 2891 | switch (encoder->type) { |
| 2892 | case INTEL_OUTPUT_TVOUT: |
| 2893 | *source = INTEL_PIPE_CRC_SOURCE_TV; |
| 2894 | break; |
| 2895 | case INTEL_OUTPUT_DISPLAYPORT: |
| 2896 | case INTEL_OUTPUT_EDP: |
Daniel Vetter | 2675680 | 2013-11-01 10:50:23 +0100 | [diff] [blame] | 2897 | dig_port = enc_to_dig_port(&encoder->base); |
| 2898 | switch (dig_port->port) { |
| 2899 | case PORT_B: |
| 2900 | *source = INTEL_PIPE_CRC_SOURCE_DP_B; |
| 2901 | break; |
| 2902 | case PORT_C: |
| 2903 | *source = INTEL_PIPE_CRC_SOURCE_DP_C; |
| 2904 | break; |
| 2905 | case PORT_D: |
| 2906 | *source = INTEL_PIPE_CRC_SOURCE_DP_D; |
| 2907 | break; |
| 2908 | default: |
| 2909 | WARN(1, "nonexisting DP port %c\n", |
| 2910 | port_name(dig_port->port)); |
| 2911 | break; |
| 2912 | } |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2913 | break; |
| 2914 | } |
| 2915 | } |
Daniel Vetter | 6e9f798 | 2014-05-29 23:54:47 +0200 | [diff] [blame] | 2916 | drm_modeset_unlock_all(dev); |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2917 | |
| 2918 | return ret; |
| 2919 | } |
| 2920 | |
| 2921 | static int vlv_pipe_crc_ctl_reg(struct drm_device *dev, |
| 2922 | enum pipe pipe, |
| 2923 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2924 | uint32_t *val) |
| 2925 | { |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2926 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2927 | bool need_stable_symbols = false; |
| 2928 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2929 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 2930 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 2931 | if (ret) |
| 2932 | return ret; |
| 2933 | } |
| 2934 | |
| 2935 | switch (*source) { |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2936 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2937 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; |
| 2938 | break; |
| 2939 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 2940 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2941 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2942 | break; |
| 2943 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 2944 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV; |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2945 | need_stable_symbols = true; |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2946 | break; |
| 2947 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 2948 | *val = 0; |
| 2949 | break; |
| 2950 | default: |
| 2951 | return -EINVAL; |
| 2952 | } |
| 2953 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2954 | /* |
| 2955 | * When the pipe CRC tap point is after the transcoders we need |
| 2956 | * to tweak symbol-level features to produce a deterministic series of |
| 2957 | * symbols for a given frame. We need to reset those features only once |
| 2958 | * a frame (instead of every nth symbol): |
| 2959 | * - DC-balance: used to ensure a better clock recovery from the data |
| 2960 | * link (SDVO) |
| 2961 | * - DisplayPort scrambling: used for EMI reduction |
| 2962 | */ |
| 2963 | if (need_stable_symbols) { |
| 2964 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 2965 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 2966 | tmp |= DC_BALANCE_RESET_VLV; |
| 2967 | if (pipe == PIPE_A) |
| 2968 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 2969 | else |
| 2970 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 2971 | |
| 2972 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 2973 | } |
| 2974 | |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 2975 | return 0; |
| 2976 | } |
| 2977 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2978 | static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2979 | enum pipe pipe, |
| 2980 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2981 | uint32_t *val) |
| 2982 | { |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 2983 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2984 | bool need_stable_symbols = false; |
| 2985 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 2986 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) { |
| 2987 | int ret = i9xx_pipe_crc_auto_source(dev, pipe, source); |
| 2988 | if (ret) |
| 2989 | return ret; |
| 2990 | } |
| 2991 | |
| 2992 | switch (*source) { |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 2993 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 2994 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; |
| 2995 | break; |
| 2996 | case INTEL_PIPE_CRC_SOURCE_TV: |
| 2997 | if (!SUPPORTS_TV(dev)) |
| 2998 | return -EINVAL; |
| 2999 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE; |
| 3000 | break; |
| 3001 | case INTEL_PIPE_CRC_SOURCE_DP_B: |
| 3002 | if (!IS_G4X(dev)) |
| 3003 | return -EINVAL; |
| 3004 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3005 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3006 | break; |
| 3007 | case INTEL_PIPE_CRC_SOURCE_DP_C: |
| 3008 | if (!IS_G4X(dev)) |
| 3009 | return -EINVAL; |
| 3010 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3011 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3012 | break; |
| 3013 | case INTEL_PIPE_CRC_SOURCE_DP_D: |
| 3014 | if (!IS_G4X(dev)) |
| 3015 | return -EINVAL; |
| 3016 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X; |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3017 | need_stable_symbols = true; |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3018 | break; |
| 3019 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 3020 | *val = 0; |
| 3021 | break; |
| 3022 | default: |
| 3023 | return -EINVAL; |
| 3024 | } |
| 3025 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3026 | /* |
| 3027 | * When the pipe CRC tap point is after the transcoders we need |
| 3028 | * to tweak symbol-level features to produce a deterministic series of |
| 3029 | * symbols for a given frame. We need to reset those features only once |
| 3030 | * a frame (instead of every nth symbol): |
| 3031 | * - DC-balance: used to ensure a better clock recovery from the data |
| 3032 | * link (SDVO) |
| 3033 | * - DisplayPort scrambling: used for EMI reduction |
| 3034 | */ |
| 3035 | if (need_stable_symbols) { |
| 3036 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3037 | |
| 3038 | WARN_ON(!IS_G4X(dev)); |
| 3039 | |
| 3040 | I915_WRITE(PORT_DFT_I9XX, |
| 3041 | I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET); |
| 3042 | |
| 3043 | if (pipe == PIPE_A) |
| 3044 | tmp |= PIPE_A_SCRAMBLE_RESET; |
| 3045 | else |
| 3046 | tmp |= PIPE_B_SCRAMBLE_RESET; |
| 3047 | |
| 3048 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3049 | } |
| 3050 | |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3051 | return 0; |
| 3052 | } |
| 3053 | |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3054 | static void vlv_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3055 | enum pipe pipe) |
| 3056 | { |
| 3057 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3058 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3059 | |
| 3060 | if (pipe == PIPE_A) |
| 3061 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3062 | else |
| 3063 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3064 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) |
| 3065 | tmp &= ~DC_BALANCE_RESET_VLV; |
| 3066 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3067 | |
| 3068 | } |
| 3069 | |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3070 | static void g4x_undo_pipe_scramble_reset(struct drm_device *dev, |
| 3071 | enum pipe pipe) |
| 3072 | { |
| 3073 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3074 | uint32_t tmp = I915_READ(PORT_DFT2_G4X); |
| 3075 | |
| 3076 | if (pipe == PIPE_A) |
| 3077 | tmp &= ~PIPE_A_SCRAMBLE_RESET; |
| 3078 | else |
| 3079 | tmp &= ~PIPE_B_SCRAMBLE_RESET; |
| 3080 | I915_WRITE(PORT_DFT2_G4X, tmp); |
| 3081 | |
| 3082 | if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) { |
| 3083 | I915_WRITE(PORT_DFT_I9XX, |
| 3084 | I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET); |
| 3085 | } |
| 3086 | } |
| 3087 | |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3088 | 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] | 3089 | uint32_t *val) |
| 3090 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3091 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3092 | *source = INTEL_PIPE_CRC_SOURCE_PIPE; |
| 3093 | |
| 3094 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3095 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3096 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; |
| 3097 | break; |
| 3098 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3099 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK; |
| 3100 | break; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3101 | case INTEL_PIPE_CRC_SOURCE_PIPE: |
| 3102 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK; |
| 3103 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3104 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3105 | *val = 0; |
| 3106 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3107 | default: |
| 3108 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3109 | } |
| 3110 | |
| 3111 | return 0; |
| 3112 | } |
| 3113 | |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3114 | static void hsw_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3115 | { |
| 3116 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3117 | struct intel_crtc *crtc = |
| 3118 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
| 3119 | |
| 3120 | drm_modeset_lock_all(dev); |
| 3121 | /* |
| 3122 | * If we use the eDP transcoder we need to make sure that we don't |
| 3123 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3124 | * relevant on hsw with pipe A when using the always-on power well |
| 3125 | * routing. |
| 3126 | */ |
| 3127 | if (crtc->config.cpu_transcoder == TRANSCODER_EDP && |
| 3128 | !crtc->config.pch_pfit.enabled) { |
| 3129 | crtc->config.pch_pfit.force_thru = true; |
| 3130 | |
| 3131 | intel_display_power_get(dev_priv, |
| 3132 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3133 | |
| 3134 | dev_priv->display.crtc_disable(&crtc->base); |
| 3135 | dev_priv->display.crtc_enable(&crtc->base); |
| 3136 | } |
| 3137 | drm_modeset_unlock_all(dev); |
| 3138 | } |
| 3139 | |
| 3140 | static void hsw_undo_trans_edp_pipe_A_crc_wa(struct drm_device *dev) |
| 3141 | { |
| 3142 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3143 | struct intel_crtc *crtc = |
| 3144 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]); |
| 3145 | |
| 3146 | drm_modeset_lock_all(dev); |
| 3147 | /* |
| 3148 | * If we use the eDP transcoder we need to make sure that we don't |
| 3149 | * bypass the pfit, since otherwise the pipe CRC source won't work. Only |
| 3150 | * relevant on hsw with pipe A when using the always-on power well |
| 3151 | * routing. |
| 3152 | */ |
| 3153 | if (crtc->config.pch_pfit.force_thru) { |
| 3154 | crtc->config.pch_pfit.force_thru = false; |
| 3155 | |
| 3156 | dev_priv->display.crtc_disable(&crtc->base); |
| 3157 | dev_priv->display.crtc_enable(&crtc->base); |
| 3158 | |
| 3159 | intel_display_power_put(dev_priv, |
| 3160 | POWER_DOMAIN_PIPE_PANEL_FITTER(PIPE_A)); |
| 3161 | } |
| 3162 | drm_modeset_unlock_all(dev); |
| 3163 | } |
| 3164 | |
| 3165 | static int ivb_pipe_crc_ctl_reg(struct drm_device *dev, |
| 3166 | enum pipe pipe, |
| 3167 | enum intel_pipe_crc_source *source, |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3168 | uint32_t *val) |
| 3169 | { |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3170 | if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) |
| 3171 | *source = INTEL_PIPE_CRC_SOURCE_PF; |
| 3172 | |
| 3173 | switch (*source) { |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3174 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 3175 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 3176 | break; |
| 3177 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 3178 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 3179 | break; |
| 3180 | case INTEL_PIPE_CRC_SOURCE_PF: |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3181 | if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3182 | hsw_trans_edp_pipe_A_crc_wa(dev); |
| 3183 | |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3184 | *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 3185 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3186 | case INTEL_PIPE_CRC_SOURCE_NONE: |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3187 | *val = 0; |
| 3188 | break; |
Daniel Vetter | 3d099a0 | 2013-10-16 22:55:58 +0200 | [diff] [blame] | 3189 | default: |
| 3190 | return -EINVAL; |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3191 | } |
| 3192 | |
| 3193 | return 0; |
| 3194 | } |
| 3195 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3196 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 3197 | enum intel_pipe_crc_source source) |
| 3198 | { |
| 3199 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3200 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Borislav Petkov | 432f334 | 2013-11-21 16:49:46 +0100 | [diff] [blame] | 3201 | u32 val = 0; /* shut up gcc */ |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3202 | int ret; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3203 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3204 | if (pipe_crc->source == source) |
| 3205 | return 0; |
| 3206 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame] | 3207 | /* forbid changing the source without going back to 'none' */ |
| 3208 | if (pipe_crc->source && source) |
| 3209 | return -EINVAL; |
| 3210 | |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3211 | if (IS_GEN2(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3212 | ret = i8xx_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 52f843f | 2013-10-21 17:26:38 +0200 | [diff] [blame] | 3213 | else if (INTEL_INFO(dev)->gen < 5) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3214 | ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 7ac0129 | 2013-10-18 16:37:06 +0200 | [diff] [blame] | 3215 | else if (IS_VALLEYVIEW(dev)) |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3216 | ret = vlv_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 4b79ebf | 2013-10-16 22:55:59 +0200 | [diff] [blame] | 3217 | else if (IS_GEN5(dev) || IS_GEN6(dev)) |
Daniel Vetter | 46a1918 | 2013-11-01 10:50:20 +0100 | [diff] [blame] | 3218 | ret = ilk_pipe_crc_ctl_reg(&source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3219 | else |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3220 | ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val); |
Daniel Vetter | 5b3a856 | 2013-10-16 22:55:48 +0200 | [diff] [blame] | 3221 | |
| 3222 | if (ret != 0) |
| 3223 | return ret; |
| 3224 | |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3225 | /* none -> real source transition */ |
| 3226 | if (source) { |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3227 | DRM_DEBUG_DRIVER("collecting CRCs for pipe %c, %s\n", |
| 3228 | pipe_name(pipe), pipe_crc_source_name(source)); |
| 3229 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3230 | pipe_crc->entries = kzalloc(sizeof(*pipe_crc->entries) * |
| 3231 | INTEL_PIPE_CRC_ENTRIES_NR, |
| 3232 | GFP_KERNEL); |
| 3233 | if (!pipe_crc->entries) |
| 3234 | return -ENOMEM; |
| 3235 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3236 | spin_lock_irq(&pipe_crc->lock); |
| 3237 | pipe_crc->head = 0; |
| 3238 | pipe_crc->tail = 0; |
| 3239 | spin_unlock_irq(&pipe_crc->lock); |
Damien Lespiau | 4b58436 | 2013-10-15 18:55:33 +0100 | [diff] [blame] | 3240 | } |
| 3241 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 3242 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3243 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3244 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 3245 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 3246 | |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3247 | /* real source -> none transition */ |
| 3248 | if (source == INTEL_PIPE_CRC_SOURCE_NONE) { |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3249 | struct intel_pipe_crc_entry *entries; |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3250 | struct intel_crtc *crtc = |
| 3251 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3252 | |
Damien Lespiau | 7cd6ccf | 2013-10-15 18:55:38 +0100 | [diff] [blame] | 3253 | DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n", |
| 3254 | pipe_name(pipe)); |
| 3255 | |
Daniel Vetter | a33d710 | 2014-06-06 08:22:08 +0200 | [diff] [blame] | 3256 | drm_modeset_lock(&crtc->base.mutex, NULL); |
| 3257 | if (crtc->active) |
| 3258 | intel_wait_for_vblank(dev, pipe); |
| 3259 | drm_modeset_unlock(&crtc->base.mutex); |
Daniel Vetter | bcf17ab | 2013-10-16 22:55:50 +0200 | [diff] [blame] | 3260 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3261 | spin_lock_irq(&pipe_crc->lock); |
| 3262 | entries = pipe_crc->entries; |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3263 | pipe_crc->entries = NULL; |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 3264 | spin_unlock_irq(&pipe_crc->lock); |
| 3265 | |
| 3266 | kfree(entries); |
Daniel Vetter | 8409360 | 2013-11-01 10:50:21 +0100 | [diff] [blame] | 3267 | |
| 3268 | if (IS_G4X(dev)) |
| 3269 | g4x_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | 8d2f24c | 2013-11-01 10:50:22 +0100 | [diff] [blame] | 3270 | else if (IS_VALLEYVIEW(dev)) |
| 3271 | vlv_undo_pipe_scramble_reset(dev, pipe); |
Daniel Vetter | fabf6e5 | 2014-05-29 14:10:22 +0200 | [diff] [blame] | 3272 | else if (IS_HASWELL(dev) && pipe == PIPE_A) |
| 3273 | hsw_undo_trans_edp_pipe_A_crc_wa(dev); |
Damien Lespiau | e5f75ac | 2013-10-15 18:55:34 +0100 | [diff] [blame] | 3274 | } |
| 3275 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3276 | return 0; |
| 3277 | } |
| 3278 | |
| 3279 | /* |
| 3280 | * Parse pipe CRC command strings: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3281 | * command: wsp* object wsp+ name wsp+ source wsp* |
| 3282 | * object: 'pipe' |
| 3283 | * name: (A | B | C) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3284 | * source: (none | plane1 | plane2 | pf) |
| 3285 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 3286 | * |
| 3287 | * eg.: |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3288 | * "pipe A plane1" -> Start CRC computations on plane1 of pipe A |
| 3289 | * "pipe A none" -> Stop CRC |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3290 | */ |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3291 | 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] | 3292 | { |
| 3293 | int n_words = 0; |
| 3294 | |
| 3295 | while (*buf) { |
| 3296 | char *end; |
| 3297 | |
| 3298 | /* skip leading white space */ |
| 3299 | buf = skip_spaces(buf); |
| 3300 | if (!*buf) |
| 3301 | break; /* end of buffer */ |
| 3302 | |
| 3303 | /* find end of word */ |
| 3304 | for (end = buf; *end && !isspace(*end); end++) |
| 3305 | ; |
| 3306 | |
| 3307 | if (n_words == max_words) { |
| 3308 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 3309 | max_words); |
| 3310 | return -EINVAL; /* ran out of words[] before bytes */ |
| 3311 | } |
| 3312 | |
| 3313 | if (*end) |
| 3314 | *end++ = '\0'; |
| 3315 | words[n_words++] = buf; |
| 3316 | buf = end; |
| 3317 | } |
| 3318 | |
| 3319 | return n_words; |
| 3320 | } |
| 3321 | |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3322 | enum intel_pipe_crc_object { |
| 3323 | PIPE_CRC_OBJECT_PIPE, |
| 3324 | }; |
| 3325 | |
Daniel Vetter | e8dfcf7 | 2013-10-16 11:51:54 +0200 | [diff] [blame] | 3326 | static const char * const pipe_crc_objects[] = { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3327 | "pipe", |
| 3328 | }; |
| 3329 | |
| 3330 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3331 | 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] | 3332 | { |
| 3333 | int i; |
| 3334 | |
| 3335 | for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++) |
| 3336 | if (!strcmp(buf, pipe_crc_objects[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3337 | *o = i; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3338 | return 0; |
| 3339 | } |
| 3340 | |
| 3341 | return -EINVAL; |
| 3342 | } |
| 3343 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3344 | 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] | 3345 | { |
| 3346 | const char name = buf[0]; |
| 3347 | |
| 3348 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 3349 | return -EINVAL; |
| 3350 | |
| 3351 | *pipe = name - 'A'; |
| 3352 | |
| 3353 | return 0; |
| 3354 | } |
| 3355 | |
| 3356 | static int |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3357 | 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] | 3358 | { |
| 3359 | int i; |
| 3360 | |
| 3361 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 3362 | if (!strcmp(buf, pipe_crc_sources[i])) { |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3363 | *s = i; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3364 | return 0; |
| 3365 | } |
| 3366 | |
| 3367 | return -EINVAL; |
| 3368 | } |
| 3369 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3370 | 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] | 3371 | { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3372 | #define N_WORDS 3 |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3373 | int n_words; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3374 | char *words[N_WORDS]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3375 | enum pipe pipe; |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3376 | enum intel_pipe_crc_object object; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3377 | enum intel_pipe_crc_source source; |
| 3378 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3379 | n_words = display_crc_ctl_tokenize(buf, words, N_WORDS); |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3380 | if (n_words != N_WORDS) { |
| 3381 | DRM_DEBUG_DRIVER("tokenize failed, a command is %d words\n", |
| 3382 | N_WORDS); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3383 | return -EINVAL; |
| 3384 | } |
| 3385 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3386 | if (display_crc_ctl_parse_object(words[0], &object) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3387 | DRM_DEBUG_DRIVER("unknown object %s\n", words[0]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3388 | return -EINVAL; |
| 3389 | } |
| 3390 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3391 | if (display_crc_ctl_parse_pipe(words[1], &pipe) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3392 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[1]); |
| 3393 | return -EINVAL; |
| 3394 | } |
| 3395 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3396 | if (display_crc_ctl_parse_source(words[2], &source) < 0) { |
Damien Lespiau | b94dec8 | 2013-10-15 18:55:35 +0100 | [diff] [blame] | 3397 | DRM_DEBUG_DRIVER("unknown source %s\n", words[2]); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3398 | return -EINVAL; |
| 3399 | } |
| 3400 | |
| 3401 | return pipe_crc_set_source(dev, pipe, source); |
| 3402 | } |
| 3403 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3404 | static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 3405 | size_t len, loff_t *offp) |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3406 | { |
| 3407 | struct seq_file *m = file->private_data; |
| 3408 | struct drm_device *dev = m->private; |
| 3409 | char *tmpbuf; |
| 3410 | int ret; |
| 3411 | |
| 3412 | if (len == 0) |
| 3413 | return 0; |
| 3414 | |
| 3415 | if (len > PAGE_SIZE - 1) { |
| 3416 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 3417 | PAGE_SIZE); |
| 3418 | return -E2BIG; |
| 3419 | } |
| 3420 | |
| 3421 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 3422 | if (!tmpbuf) |
| 3423 | return -ENOMEM; |
| 3424 | |
| 3425 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 3426 | ret = -EFAULT; |
| 3427 | goto out; |
| 3428 | } |
| 3429 | tmpbuf[len] = '\0'; |
| 3430 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3431 | ret = display_crc_ctl_parse(dev, tmpbuf, len); |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3432 | |
| 3433 | out: |
| 3434 | kfree(tmpbuf); |
| 3435 | if (ret < 0) |
| 3436 | return ret; |
| 3437 | |
| 3438 | *offp += len; |
| 3439 | return len; |
| 3440 | } |
| 3441 | |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3442 | static const struct file_operations i915_display_crc_ctl_fops = { |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3443 | .owner = THIS_MODULE, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3444 | .open = display_crc_ctl_open, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3445 | .read = seq_read, |
| 3446 | .llseek = seq_lseek, |
| 3447 | .release = single_release, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 3448 | .write = display_crc_ctl_write |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 3449 | }; |
| 3450 | |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3451 | static void wm_latency_show(struct seq_file *m, const uint16_t wm[5]) |
| 3452 | { |
| 3453 | struct drm_device *dev = m->private; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 3454 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3455 | int level; |
| 3456 | |
| 3457 | drm_modeset_lock_all(dev); |
| 3458 | |
| 3459 | for (level = 0; level < num_levels; level++) { |
| 3460 | unsigned int latency = wm[level]; |
| 3461 | |
| 3462 | /* WM1+ latency values in 0.5us units */ |
| 3463 | if (level > 0) |
| 3464 | latency *= 5; |
| 3465 | |
| 3466 | seq_printf(m, "WM%d %u (%u.%u usec)\n", |
| 3467 | level, wm[level], |
| 3468 | latency / 10, latency % 10); |
| 3469 | } |
| 3470 | |
| 3471 | drm_modeset_unlock_all(dev); |
| 3472 | } |
| 3473 | |
| 3474 | static int pri_wm_latency_show(struct seq_file *m, void *data) |
| 3475 | { |
| 3476 | struct drm_device *dev = m->private; |
| 3477 | |
| 3478 | wm_latency_show(m, to_i915(dev)->wm.pri_latency); |
| 3479 | |
| 3480 | return 0; |
| 3481 | } |
| 3482 | |
| 3483 | static int spr_wm_latency_show(struct seq_file *m, void *data) |
| 3484 | { |
| 3485 | struct drm_device *dev = m->private; |
| 3486 | |
| 3487 | wm_latency_show(m, to_i915(dev)->wm.spr_latency); |
| 3488 | |
| 3489 | return 0; |
| 3490 | } |
| 3491 | |
| 3492 | static int cur_wm_latency_show(struct seq_file *m, void *data) |
| 3493 | { |
| 3494 | struct drm_device *dev = m->private; |
| 3495 | |
| 3496 | wm_latency_show(m, to_i915(dev)->wm.cur_latency); |
| 3497 | |
| 3498 | return 0; |
| 3499 | } |
| 3500 | |
| 3501 | static int pri_wm_latency_open(struct inode *inode, struct file *file) |
| 3502 | { |
| 3503 | struct drm_device *dev = inode->i_private; |
| 3504 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3505 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3506 | return -ENODEV; |
| 3507 | |
| 3508 | return single_open(file, pri_wm_latency_show, dev); |
| 3509 | } |
| 3510 | |
| 3511 | static int spr_wm_latency_open(struct inode *inode, struct file *file) |
| 3512 | { |
| 3513 | struct drm_device *dev = inode->i_private; |
| 3514 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3515 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3516 | return -ENODEV; |
| 3517 | |
| 3518 | return single_open(file, spr_wm_latency_show, dev); |
| 3519 | } |
| 3520 | |
| 3521 | static int cur_wm_latency_open(struct inode *inode, struct file *file) |
| 3522 | { |
| 3523 | struct drm_device *dev = inode->i_private; |
| 3524 | |
Sonika Jindal | 9ad0257 | 2014-07-21 15:23:39 +0530 | [diff] [blame] | 3525 | if (HAS_GMCH_DISPLAY(dev)) |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3526 | return -ENODEV; |
| 3527 | |
| 3528 | return single_open(file, cur_wm_latency_show, dev); |
| 3529 | } |
| 3530 | |
| 3531 | static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, |
| 3532 | size_t len, loff_t *offp, uint16_t wm[5]) |
| 3533 | { |
| 3534 | struct seq_file *m = file->private_data; |
| 3535 | struct drm_device *dev = m->private; |
| 3536 | uint16_t new[5] = { 0 }; |
Damien Lespiau | 546c81f | 2014-05-13 15:30:26 +0100 | [diff] [blame] | 3537 | int num_levels = ilk_wm_max_level(dev) + 1; |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 3538 | int level; |
| 3539 | int ret; |
| 3540 | char tmp[32]; |
| 3541 | |
| 3542 | if (len >= sizeof(tmp)) |
| 3543 | return -EINVAL; |
| 3544 | |
| 3545 | if (copy_from_user(tmp, ubuf, len)) |
| 3546 | return -EFAULT; |
| 3547 | |
| 3548 | tmp[len] = '\0'; |
| 3549 | |
| 3550 | ret = sscanf(tmp, "%hu %hu %hu %hu %hu", &new[0], &new[1], &new[2], &new[3], &new[4]); |
| 3551 | if (ret != num_levels) |
| 3552 | return -EINVAL; |
| 3553 | |
| 3554 | drm_modeset_lock_all(dev); |
| 3555 | |
| 3556 | for (level = 0; level < num_levels; level++) |
| 3557 | wm[level] = new[level]; |
| 3558 | |
| 3559 | drm_modeset_unlock_all(dev); |
| 3560 | |
| 3561 | return len; |
| 3562 | } |
| 3563 | |
| 3564 | |
| 3565 | static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3566 | size_t len, loff_t *offp) |
| 3567 | { |
| 3568 | struct seq_file *m = file->private_data; |
| 3569 | struct drm_device *dev = m->private; |
| 3570 | |
| 3571 | return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.pri_latency); |
| 3572 | } |
| 3573 | |
| 3574 | static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3575 | size_t len, loff_t *offp) |
| 3576 | { |
| 3577 | struct seq_file *m = file->private_data; |
| 3578 | struct drm_device *dev = m->private; |
| 3579 | |
| 3580 | return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.spr_latency); |
| 3581 | } |
| 3582 | |
| 3583 | static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf, |
| 3584 | size_t len, loff_t *offp) |
| 3585 | { |
| 3586 | struct seq_file *m = file->private_data; |
| 3587 | struct drm_device *dev = m->private; |
| 3588 | |
| 3589 | return wm_latency_write(file, ubuf, len, offp, to_i915(dev)->wm.cur_latency); |
| 3590 | } |
| 3591 | |
| 3592 | static const struct file_operations i915_pri_wm_latency_fops = { |
| 3593 | .owner = THIS_MODULE, |
| 3594 | .open = pri_wm_latency_open, |
| 3595 | .read = seq_read, |
| 3596 | .llseek = seq_lseek, |
| 3597 | .release = single_release, |
| 3598 | .write = pri_wm_latency_write |
| 3599 | }; |
| 3600 | |
| 3601 | static const struct file_operations i915_spr_wm_latency_fops = { |
| 3602 | .owner = THIS_MODULE, |
| 3603 | .open = spr_wm_latency_open, |
| 3604 | .read = seq_read, |
| 3605 | .llseek = seq_lseek, |
| 3606 | .release = single_release, |
| 3607 | .write = spr_wm_latency_write |
| 3608 | }; |
| 3609 | |
| 3610 | static const struct file_operations i915_cur_wm_latency_fops = { |
| 3611 | .owner = THIS_MODULE, |
| 3612 | .open = cur_wm_latency_open, |
| 3613 | .read = seq_read, |
| 3614 | .llseek = seq_lseek, |
| 3615 | .release = single_release, |
| 3616 | .write = cur_wm_latency_write |
| 3617 | }; |
| 3618 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3619 | static int |
| 3620 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3621 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3622 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3623 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3624 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3625 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3626 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3627 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3628 | } |
| 3629 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3630 | static int |
| 3631 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3632 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3633 | struct drm_device *dev = data; |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3634 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3635 | |
| 3636 | intel_runtime_pm_get(dev_priv); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3637 | |
Mika Kuoppala | 5817446 | 2014-02-25 17:11:26 +0200 | [diff] [blame] | 3638 | i915_handle_error(dev, val, |
| 3639 | "Manually setting wedged to %llu", val); |
Imre Deak | d46c051 | 2014-04-14 20:24:27 +0300 | [diff] [blame] | 3640 | |
| 3641 | intel_runtime_pm_put(dev_priv); |
| 3642 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3643 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3644 | } |
| 3645 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3646 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 3647 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3648 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 3649 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3650 | static int |
| 3651 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3652 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3653 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3654 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3655 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3656 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3657 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3658 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3659 | } |
| 3660 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3661 | static int |
| 3662 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3663 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3664 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3665 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3666 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3667 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3668 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3669 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 3670 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3671 | if (ret) |
| 3672 | return ret; |
| 3673 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 3674 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3675 | mutex_unlock(&dev->struct_mutex); |
| 3676 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3677 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 3678 | } |
| 3679 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3680 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 3681 | i915_ring_stop_get, i915_ring_stop_set, |
| 3682 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 3683 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 3684 | static int |
| 3685 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 3686 | { |
| 3687 | struct drm_device *dev = data; |
| 3688 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3689 | |
| 3690 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 3691 | return 0; |
| 3692 | } |
| 3693 | |
| 3694 | static int |
| 3695 | i915_ring_missed_irq_set(void *data, u64 val) |
| 3696 | { |
| 3697 | struct drm_device *dev = data; |
| 3698 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3699 | int ret; |
| 3700 | |
| 3701 | /* Lock against concurrent debugfs callers */ |
| 3702 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3703 | if (ret) |
| 3704 | return ret; |
| 3705 | dev_priv->gpu_error.missed_irq_rings = val; |
| 3706 | mutex_unlock(&dev->struct_mutex); |
| 3707 | |
| 3708 | return 0; |
| 3709 | } |
| 3710 | |
| 3711 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 3712 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 3713 | "0x%08llx\n"); |
| 3714 | |
| 3715 | static int |
| 3716 | i915_ring_test_irq_get(void *data, u64 *val) |
| 3717 | { |
| 3718 | struct drm_device *dev = data; |
| 3719 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3720 | |
| 3721 | *val = dev_priv->gpu_error.test_irq_rings; |
| 3722 | |
| 3723 | return 0; |
| 3724 | } |
| 3725 | |
| 3726 | static int |
| 3727 | i915_ring_test_irq_set(void *data, u64 val) |
| 3728 | { |
| 3729 | struct drm_device *dev = data; |
| 3730 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3731 | int ret; |
| 3732 | |
| 3733 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 3734 | |
| 3735 | /* Lock against concurrent debugfs callers */ |
| 3736 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3737 | if (ret) |
| 3738 | return ret; |
| 3739 | |
| 3740 | dev_priv->gpu_error.test_irq_rings = val; |
| 3741 | mutex_unlock(&dev->struct_mutex); |
| 3742 | |
| 3743 | return 0; |
| 3744 | } |
| 3745 | |
| 3746 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 3747 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 3748 | "0x%08llx\n"); |
| 3749 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3750 | #define DROP_UNBOUND 0x1 |
| 3751 | #define DROP_BOUND 0x2 |
| 3752 | #define DROP_RETIRE 0x4 |
| 3753 | #define DROP_ACTIVE 0x8 |
| 3754 | #define DROP_ALL (DROP_UNBOUND | \ |
| 3755 | DROP_BOUND | \ |
| 3756 | DROP_RETIRE | \ |
| 3757 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3758 | static int |
| 3759 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3760 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3761 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3762 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3763 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3764 | } |
| 3765 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3766 | static int |
| 3767 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3768 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3769 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3770 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 3771 | struct drm_i915_gem_object *obj, *next; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3772 | struct i915_address_space *vm; |
| 3773 | struct i915_vma *vma, *x; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3774 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3775 | |
Ben Widawsky | 2f9fe5f | 2013-11-25 09:54:37 -0800 | [diff] [blame] | 3776 | DRM_DEBUG("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3777 | |
| 3778 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 3779 | * on ioctls on -EAGAIN. */ |
| 3780 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 3781 | if (ret) |
| 3782 | return ret; |
| 3783 | |
| 3784 | if (val & DROP_ACTIVE) { |
| 3785 | ret = i915_gpu_idle(dev); |
| 3786 | if (ret) |
| 3787 | goto unlock; |
| 3788 | } |
| 3789 | |
| 3790 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 3791 | i915_gem_retire_requests(dev); |
| 3792 | |
| 3793 | if (val & DROP_BOUND) { |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3794 | list_for_each_entry(vm, &dev_priv->vm_list, global_link) { |
| 3795 | list_for_each_entry_safe(vma, x, &vm->inactive_list, |
| 3796 | mm_list) { |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 3797 | if (vma->pin_count) |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3798 | continue; |
Ben Widawsky | 31a46c9 | 2013-07-31 16:59:55 -0700 | [diff] [blame] | 3799 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 3800 | ret = i915_vma_unbind(vma); |
| 3801 | if (ret) |
| 3802 | goto unlock; |
| 3803 | } |
Ben Widawsky | 31a46c9 | 2013-07-31 16:59:55 -0700 | [diff] [blame] | 3804 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3805 | } |
| 3806 | |
| 3807 | if (val & DROP_UNBOUND) { |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 3808 | list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list, |
| 3809 | global_list) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3810 | if (obj->pages_pin_count == 0) { |
| 3811 | ret = i915_gem_object_put_pages(obj); |
| 3812 | if (ret) |
| 3813 | goto unlock; |
| 3814 | } |
| 3815 | } |
| 3816 | |
| 3817 | unlock: |
| 3818 | mutex_unlock(&dev->struct_mutex); |
| 3819 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3820 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3821 | } |
| 3822 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3823 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 3824 | i915_drop_caches_get, i915_drop_caches_set, |
| 3825 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 3826 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3827 | static int |
| 3828 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3829 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3830 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3831 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3832 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3833 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 3834 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3835 | return -ENODEV; |
| 3836 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3837 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3838 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3839 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3840 | if (ret) |
| 3841 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3842 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3843 | if (IS_VALLEYVIEW(dev)) |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3844 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3845 | else |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3846 | *val = dev_priv->rps.max_freq_softlimit * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3847 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3848 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3849 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3850 | } |
| 3851 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3852 | static int |
| 3853 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3854 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3855 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3856 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3857 | u32 rp_state_cap, hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3858 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3859 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 3860 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3861 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3862 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3863 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3864 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3865 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3866 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3867 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3868 | if (ret) |
| 3869 | return ret; |
| 3870 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3871 | /* |
| 3872 | * Turbo will still be enabled, but won't go above the set value. |
| 3873 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3874 | if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 3875 | val = vlv_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3876 | |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 3877 | hw_max = dev_priv->rps.max_freq; |
| 3878 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3879 | } else { |
| 3880 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3881 | |
| 3882 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3883 | hw_max = dev_priv->rps.max_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3884 | hw_min = (rp_state_cap >> 16) & 0xff; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3885 | } |
| 3886 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3887 | 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] | 3888 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 3889 | return -EINVAL; |
| 3890 | } |
| 3891 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3892 | dev_priv->rps.max_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3893 | |
| 3894 | if (IS_VALLEYVIEW(dev)) |
| 3895 | valleyview_set_rps(dev, val); |
| 3896 | else |
| 3897 | gen6_set_rps(dev, val); |
| 3898 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3899 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3900 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3901 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3902 | } |
| 3903 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3904 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 3905 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3906 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 3907 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3908 | static int |
| 3909 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3910 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3911 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3912 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3913 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3914 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 3915 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3916 | return -ENODEV; |
| 3917 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3918 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3919 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3920 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3921 | if (ret) |
| 3922 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3923 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3924 | if (IS_VALLEYVIEW(dev)) |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3925 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3926 | else |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3927 | *val = dev_priv->rps.min_freq_softlimit * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3928 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3929 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3930 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3931 | } |
| 3932 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3933 | static int |
| 3934 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3935 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3936 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3937 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3938 | u32 rp_state_cap, hw_max, hw_min; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3939 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3940 | |
Tom O'Rourke | daa3afb | 2014-05-30 16:22:10 -0700 | [diff] [blame] | 3941 | if (INTEL_INFO(dev)->gen < 6) |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3942 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3943 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 3944 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 3945 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3946 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3947 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3948 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3949 | if (ret) |
| 3950 | return ret; |
| 3951 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3952 | /* |
| 3953 | * Turbo will still be enabled, but won't go below the set value. |
| 3954 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3955 | if (IS_VALLEYVIEW(dev)) { |
Ville Syrjälä | 2ec3815 | 2013-11-05 22:42:29 +0200 | [diff] [blame] | 3956 | val = vlv_freq_opcode(dev_priv, val); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3957 | |
Ville Syrjälä | 03af204 | 2014-06-28 02:03:53 +0300 | [diff] [blame] | 3958 | hw_max = dev_priv->rps.max_freq; |
| 3959 | hw_min = dev_priv->rps.min_freq; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3960 | } else { |
| 3961 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3962 | |
| 3963 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3964 | hw_max = dev_priv->rps.max_freq; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3965 | hw_min = (rp_state_cap >> 16) & 0xff; |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 3966 | } |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3967 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3968 | 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] | 3969 | mutex_unlock(&dev_priv->rps.hw_lock); |
| 3970 | return -EINVAL; |
| 3971 | } |
| 3972 | |
Ben Widawsky | b39fb29 | 2014-03-19 18:31:11 -0700 | [diff] [blame] | 3973 | dev_priv->rps.min_freq_softlimit = val; |
Jeff McGee | dd0a1aa | 2014-02-04 11:32:31 -0600 | [diff] [blame] | 3974 | |
| 3975 | if (IS_VALLEYVIEW(dev)) |
| 3976 | valleyview_set_rps(dev, val); |
| 3977 | else |
| 3978 | gen6_set_rps(dev, val); |
| 3979 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 3980 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3981 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3982 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3983 | } |
| 3984 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3985 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 3986 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 3987 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 3988 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3989 | static int |
| 3990 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3991 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3992 | struct drm_device *dev = data; |
Jani Nikula | e277a1f | 2014-03-31 14:27:14 +0300 | [diff] [blame] | 3993 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3994 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 3995 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 3996 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 3997 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 3998 | return -ENODEV; |
| 3999 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4000 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 4001 | if (ret) |
| 4002 | return ret; |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4003 | intel_runtime_pm_get(dev_priv); |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 4004 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4005 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4006 | |
| 4007 | intel_runtime_pm_put(dev_priv); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4008 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 4009 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4010 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4011 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4012 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4013 | } |
| 4014 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4015 | static int |
| 4016 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4017 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4018 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4019 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4020 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4021 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 4022 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 4023 | return -ENODEV; |
| 4024 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4025 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4026 | return -EINVAL; |
| 4027 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4028 | intel_runtime_pm_get(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4029 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4030 | |
| 4031 | /* Update the cache sharing policy here as well */ |
| 4032 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 4033 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 4034 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 4035 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 4036 | |
Paulo Zanoni | c8c8fb3 | 2013-11-27 18:21:54 -0200 | [diff] [blame] | 4037 | intel_runtime_pm_put(dev_priv); |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4038 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4039 | } |
| 4040 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 4041 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 4042 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 4043 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4044 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4045 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 4046 | { |
| 4047 | struct drm_device *dev = inode->i_private; |
| 4048 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4049 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4050 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4051 | return 0; |
| 4052 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 4053 | gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4054 | |
| 4055 | return 0; |
| 4056 | } |
| 4057 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 4058 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4059 | { |
| 4060 | struct drm_device *dev = inode->i_private; |
| 4061 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 4062 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 4063 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4064 | return 0; |
| 4065 | |
Deepak S | c8d9a59 | 2013-11-23 14:55:42 +0530 | [diff] [blame] | 4066 | gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4067 | |
| 4068 | return 0; |
| 4069 | } |
| 4070 | |
| 4071 | static const struct file_operations i915_forcewake_fops = { |
| 4072 | .owner = THIS_MODULE, |
| 4073 | .open = i915_forcewake_open, |
| 4074 | .release = i915_forcewake_release, |
| 4075 | }; |
| 4076 | |
| 4077 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 4078 | { |
| 4079 | struct drm_device *dev = minor->dev; |
| 4080 | struct dentry *ent; |
| 4081 | |
| 4082 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4083 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4084 | root, dev, |
| 4085 | &i915_forcewake_fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4086 | if (!ent) |
| 4087 | return -ENOMEM; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4088 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 4089 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4090 | } |
| 4091 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4092 | static int i915_debugfs_create(struct dentry *root, |
| 4093 | struct drm_minor *minor, |
| 4094 | const char *name, |
| 4095 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4096 | { |
| 4097 | struct drm_device *dev = minor->dev; |
| 4098 | struct dentry *ent; |
| 4099 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4100 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4101 | S_IRUGO | S_IWUSR, |
| 4102 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4103 | fops); |
Wei Yongjun | f3c5fe9 | 2013-12-16 14:13:25 +0800 | [diff] [blame] | 4104 | if (!ent) |
| 4105 | return -ENOMEM; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 4106 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4107 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 4108 | } |
| 4109 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4110 | static const struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 4111 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 4112 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 4113 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 4114 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 4115 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 4116 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 4117 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 4118 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4119 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 4120 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 4121 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4122 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 4123 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 4124 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 4125 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 4126 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Deepak S | adb4bd1 | 2014-03-31 11:30:02 +0530 | [diff] [blame] | 4127 | {"i915_frequency_info", i915_frequency_info, 0}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 4128 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 4129 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 4130 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 4131 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 4132 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 4133 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 4134 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 4135 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 4136 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | c0ab1ae | 2014-08-07 13:24:26 +0100 | [diff] [blame^] | 4137 | {"i915_dump_lrc", i915_dump_lrc, 0}, |
Oscar Mateo | 4ba70e4 | 2014-08-07 13:23:20 +0100 | [diff] [blame] | 4138 | {"i915_execlists", i915_execlists, 0}, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4139 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 4140 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 4141 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 4142 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 4143 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Rodrigo Vivi | d2e216d | 2014-01-24 13:36:17 -0200 | [diff] [blame] | 4144 | {"i915_sink_crc_eDP1", i915_sink_crc, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 4145 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 4146 | {"i915_pc8_status", i915_pc8_status, 0}, |
Imre Deak | 1da5158 | 2013-11-25 17:15:35 +0200 | [diff] [blame] | 4147 | {"i915_power_domain_info", i915_power_domain_info, 0}, |
Jesse Barnes | 53f5e3c | 2014-02-07 12:48:15 -0800 | [diff] [blame] | 4148 | {"i915_display_info", i915_display_info, 0}, |
Ben Widawsky | e04934c | 2014-06-30 09:53:42 -0700 | [diff] [blame] | 4149 | {"i915_semaphore_status", i915_semaphore_status, 0}, |
Daniel Vetter | 728e29d | 2014-06-25 22:01:53 +0300 | [diff] [blame] | 4150 | {"i915_shared_dplls_info", i915_shared_dplls_info, 0}, |
Dave Airlie | 11bed958 | 2014-05-12 15:22:27 +1000 | [diff] [blame] | 4151 | {"i915_dp_mst_info", i915_dp_mst_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4152 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4153 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4154 | |
Lespiau, Damien | 06c5bf8 | 2013-10-17 19:09:56 +0100 | [diff] [blame] | 4155 | static const struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4156 | const char *name; |
| 4157 | const struct file_operations *fops; |
| 4158 | } i915_debugfs_files[] = { |
| 4159 | {"i915_wedged", &i915_wedged_fops}, |
| 4160 | {"i915_max_freq", &i915_max_freq_fops}, |
| 4161 | {"i915_min_freq", &i915_min_freq_fops}, |
| 4162 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 4163 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 4164 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 4165 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4166 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 4167 | {"i915_error_state", &i915_error_state_fops}, |
| 4168 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Damien Lespiau | bd9db02 | 2013-10-15 18:55:36 +0100 | [diff] [blame] | 4169 | {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, |
Ville Syrjälä | 369a134 | 2014-01-22 14:36:08 +0200 | [diff] [blame] | 4170 | {"i915_pri_wm_latency", &i915_pri_wm_latency_fops}, |
| 4171 | {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, |
| 4172 | {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, |
Rodrigo Vivi | da46f93 | 2014-08-01 02:04:45 -0700 | [diff] [blame] | 4173 | {"i915_fbc_false_color", &i915_fbc_fc_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4174 | }; |
| 4175 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4176 | void intel_display_crc_init(struct drm_device *dev) |
| 4177 | { |
| 4178 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 4179 | enum pipe pipe; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4180 | |
Daniel Vetter | b378360 | 2013-11-14 11:30:42 +0100 | [diff] [blame] | 4181 | for_each_pipe(pipe) { |
| 4182 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4183 | |
Damien Lespiau | d538bbd | 2013-10-21 14:29:30 +0100 | [diff] [blame] | 4184 | pipe_crc->opened = false; |
| 4185 | spin_lock_init(&pipe_crc->lock); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4186 | init_waitqueue_head(&pipe_crc->wq); |
| 4187 | } |
| 4188 | } |
| 4189 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4190 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4191 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4192 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 4193 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4194 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 4195 | if (ret) |
| 4196 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 4197 | |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4198 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
| 4199 | ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); |
| 4200 | if (ret) |
| 4201 | return ret; |
| 4202 | } |
| 4203 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4204 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4205 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 4206 | i915_debugfs_files[i].name, |
| 4207 | i915_debugfs_files[i].fops); |
| 4208 | if (ret) |
| 4209 | return ret; |
| 4210 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 4211 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4212 | return drm_debugfs_create_files(i915_debugfs_list, |
| 4213 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4214 | minor->debugfs_root, minor); |
| 4215 | } |
| 4216 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4217 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4218 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4219 | int i; |
| 4220 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 4221 | drm_debugfs_remove_files(i915_debugfs_list, |
| 4222 | I915_DEBUGFS_ENTRIES, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4223 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 4224 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 4225 | 1, minor); |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4226 | |
Daniel Vetter | e309a99 | 2013-10-16 22:55:51 +0200 | [diff] [blame] | 4227 | for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { |
Damien Lespiau | 0714442 | 2013-10-15 18:55:40 +0100 | [diff] [blame] | 4228 | struct drm_info_list *info_list = |
| 4229 | (struct drm_info_list *)&i915_pipe_crc_data[i]; |
| 4230 | |
| 4231 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4232 | } |
| 4233 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 4234 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 4235 | struct drm_info_list *info_list = |
| 4236 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 4237 | |
| 4238 | drm_debugfs_remove_files(info_list, 1, minor); |
| 4239 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 4240 | } |