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