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