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