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 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 43 | #if defined(CONFIG_DEBUG_FS) |
| 44 | |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 45 | enum { |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 46 | ACTIVE_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 47 | INACTIVE_LIST, |
Chris Wilson | d21d597 | 2010-09-26 11:19:33 +0100 | [diff] [blame] | 48 | PINNED_LIST, |
Chris Wilson | f13d3f7 | 2010-09-20 17:36:15 +0100 | [diff] [blame] | 49 | }; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 50 | |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 51 | static const char *yesno(int v) |
| 52 | { |
| 53 | return v ? "yes" : "no"; |
| 54 | } |
| 55 | |
| 56 | static int i915_capabilities(struct seq_file *m, void *data) |
| 57 | { |
| 58 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 59 | struct drm_device *dev = node->minor->dev; |
| 60 | const struct intel_device_info *info = INTEL_INFO(dev); |
| 61 | |
| 62 | seq_printf(m, "gen: %d\n", info->gen); |
Paulo Zanoni | 03d00ac | 2011-10-14 18:17:41 -0300 | [diff] [blame] | 63 | seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev)); |
Damien Lespiau | 79fc46d | 2013-04-23 16:37:17 +0100 | [diff] [blame] | 64 | #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x)) |
| 65 | #define SEP_SEMICOLON ; |
| 66 | DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON); |
| 67 | #undef PRINT_FLAG |
| 68 | #undef SEP_SEMICOLON |
Chris Wilson | 70d39fe | 2010-08-25 16:03:34 +0100 | [diff] [blame] | 69 | |
| 70 | return 0; |
| 71 | } |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 72 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 73 | static const char *get_pin_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 74 | { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 75 | if (obj->user_pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 76 | return "P"; |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 77 | else if (obj->pin_count > 0) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 78 | return "p"; |
| 79 | else |
| 80 | return " "; |
| 81 | } |
| 82 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 83 | static const char *get_tiling_flag(struct drm_i915_gem_object *obj) |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 84 | { |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 85 | switch (obj->tiling_mode) { |
| 86 | default: |
| 87 | case I915_TILING_NONE: return " "; |
| 88 | case I915_TILING_X: return "X"; |
| 89 | case I915_TILING_Y: return "Y"; |
| 90 | } |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 93 | static inline const char *get_global_flag(struct drm_i915_gem_object *obj) |
| 94 | { |
| 95 | return obj->has_global_gtt_mapping ? "g" : " "; |
| 96 | } |
| 97 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 98 | static void |
| 99 | describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) |
| 100 | { |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 101 | struct i915_vma *vma; |
Ville Syrjälä | fb1ae91 | 2013-08-22 19:21:30 +0300 | [diff] [blame] | 102 | 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] | 103 | &obj->base, |
| 104 | get_pin_flag(obj), |
| 105 | get_tiling_flag(obj), |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 106 | get_global_flag(obj), |
Eric Anholt | a05a586 | 2011-12-20 08:54:15 -0800 | [diff] [blame] | 107 | obj->base.size / 1024, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 108 | obj->base.read_domains, |
| 109 | obj->base.write_domain, |
Chris Wilson | 0201f1e | 2012-07-20 12:41:01 +0100 | [diff] [blame] | 110 | obj->last_read_seqno, |
| 111 | obj->last_write_seqno, |
Chris Wilson | caea747 | 2010-11-12 13:53:37 +0000 | [diff] [blame] | 112 | obj->last_fenced_seqno, |
Mika Kuoppala | 84734a0 | 2013-07-12 16:50:57 +0300 | [diff] [blame] | 113 | i915_cache_level_str(obj->cache_level), |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 114 | obj->dirty ? " dirty" : "", |
| 115 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
| 116 | if (obj->base.name) |
| 117 | seq_printf(m, " (name: %d)", obj->base.name); |
Chris Wilson | c110a6d | 2012-08-11 15:41:02 +0100 | [diff] [blame] | 118 | if (obj->pin_count) |
| 119 | seq_printf(m, " (pinned x %d)", obj->pin_count); |
Chris Wilson | cc98b41 | 2013-08-09 12:25:09 +0100 | [diff] [blame] | 120 | if (obj->pin_display) |
| 121 | seq_printf(m, " (display)"); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 122 | if (obj->fence_reg != I915_FENCE_REG_NONE) |
| 123 | seq_printf(m, " (fence: %d)", obj->fence_reg); |
Ben Widawsky | 1d693bc | 2013-07-31 17:00:00 -0700 | [diff] [blame] | 124 | list_for_each_entry(vma, &obj->vma_list, vma_link) { |
| 125 | if (!i915_is_ggtt(vma->vm)) |
| 126 | seq_puts(m, " (pp"); |
| 127 | else |
| 128 | seq_puts(m, " (g"); |
| 129 | seq_printf(m, "gtt offset: %08lx, size: %08lx)", |
| 130 | vma->node.start, vma->node.size); |
| 131 | } |
Chris Wilson | c1ad11f | 2012-11-15 11:32:21 +0000 | [diff] [blame] | 132 | if (obj->stolen) |
| 133 | seq_printf(m, " (stolen: %08lx)", obj->stolen->start); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 134 | if (obj->pin_mappable || obj->fault_mappable) { |
| 135 | char s[3], *t = s; |
| 136 | if (obj->pin_mappable) |
| 137 | *t++ = 'p'; |
| 138 | if (obj->fault_mappable) |
| 139 | *t++ = 'f'; |
| 140 | *t = '\0'; |
| 141 | seq_printf(m, " (%s mappable)", s); |
| 142 | } |
Chris Wilson | 69dc498 | 2010-10-19 10:36:51 +0100 | [diff] [blame] | 143 | if (obj->ring != NULL) |
| 144 | seq_printf(m, " (%s)", obj->ring->name); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 147 | static void describe_ctx(struct seq_file *m, struct i915_hw_context *ctx) |
| 148 | { |
| 149 | seq_putc(m, ctx->is_initialized ? 'I' : 'i'); |
| 150 | seq_putc(m, ctx->remap_slice ? 'R' : 'r'); |
| 151 | seq_putc(m, ' '); |
| 152 | } |
| 153 | |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 154 | 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] | 155 | { |
| 156 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 157 | uintptr_t list = (uintptr_t) node->info_ent->data; |
| 158 | struct list_head *head; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 159 | struct drm_device *dev = node->minor->dev; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 160 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 161 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 162 | struct i915_vma *vma; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 163 | size_t total_obj_size, total_gtt_size; |
| 164 | int count, ret; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 165 | |
| 166 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 167 | if (ret) |
| 168 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 169 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 170 | /* FIXME: the user of this interface might want more than just GGTT */ |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 171 | switch (list) { |
| 172 | case ACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 173 | seq_puts(m, "Active:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 174 | head = &vm->active_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 175 | break; |
| 176 | case INACTIVE_LIST: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 177 | seq_puts(m, "Inactive:\n"); |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 178 | head = &vm->inactive_list; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 179 | break; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 180 | default: |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 181 | mutex_unlock(&dev->struct_mutex); |
| 182 | return -EINVAL; |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 183 | } |
| 184 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 185 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 186 | list_for_each_entry(vma, head, mm_list) { |
| 187 | seq_printf(m, " "); |
| 188 | describe_obj(m, vma->obj); |
| 189 | seq_printf(m, "\n"); |
| 190 | total_obj_size += vma->obj->base.size; |
| 191 | total_gtt_size += vma->node.size; |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 192 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 193 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 194 | mutex_unlock(&dev->struct_mutex); |
Carl Worth | 5e118f4 | 2009-03-20 11:54:25 -0700 | [diff] [blame] | 195 | |
Chris Wilson | 8f2480f | 2010-09-26 11:44:19 +0100 | [diff] [blame] | 196 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 197 | count, total_obj_size, total_gtt_size); |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 198 | return 0; |
| 199 | } |
| 200 | |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 201 | static int obj_rank_by_stolen(void *priv, |
| 202 | struct list_head *A, struct list_head *B) |
| 203 | { |
| 204 | struct drm_i915_gem_object *a = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 205 | container_of(A, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 206 | struct drm_i915_gem_object *b = |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 207 | container_of(B, struct drm_i915_gem_object, obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 208 | |
| 209 | return a->stolen->start - b->stolen->start; |
| 210 | } |
| 211 | |
| 212 | static int i915_gem_stolen_list_info(struct seq_file *m, void *data) |
| 213 | { |
| 214 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 215 | struct drm_device *dev = node->minor->dev; |
| 216 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 217 | struct drm_i915_gem_object *obj; |
| 218 | size_t total_obj_size, total_gtt_size; |
| 219 | LIST_HEAD(stolen); |
| 220 | int count, ret; |
| 221 | |
| 222 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 223 | if (ret) |
| 224 | return ret; |
| 225 | |
| 226 | total_obj_size = total_gtt_size = count = 0; |
| 227 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
| 228 | if (obj->stolen == NULL) |
| 229 | continue; |
| 230 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 231 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 232 | |
| 233 | total_obj_size += obj->base.size; |
| 234 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
| 235 | count++; |
| 236 | } |
| 237 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
| 238 | if (obj->stolen == NULL) |
| 239 | continue; |
| 240 | |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 241 | list_add(&obj->obj_exec_link, &stolen); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 242 | |
| 243 | total_obj_size += obj->base.size; |
| 244 | count++; |
| 245 | } |
| 246 | list_sort(NULL, &stolen, obj_rank_by_stolen); |
| 247 | seq_puts(m, "Stolen:\n"); |
| 248 | while (!list_empty(&stolen)) { |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 249 | obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 250 | seq_puts(m, " "); |
| 251 | describe_obj(m, obj); |
| 252 | seq_putc(m, '\n'); |
Ben Widawsky | b25cb2f | 2013-08-14 11:38:33 +0200 | [diff] [blame] | 253 | list_del_init(&obj->obj_exec_link); |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 254 | } |
| 255 | mutex_unlock(&dev->struct_mutex); |
| 256 | |
| 257 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 258 | count, total_obj_size, total_gtt_size); |
| 259 | return 0; |
| 260 | } |
| 261 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 262 | #define count_objects(list, member) do { \ |
| 263 | list_for_each_entry(obj, list, member) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 264 | size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 265 | ++count; \ |
| 266 | if (obj->map_and_fenceable) { \ |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 267 | mappable_size += i915_gem_obj_ggtt_size(obj); \ |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 268 | ++mappable_count; \ |
| 269 | } \ |
| 270 | } \ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 271 | } while (0) |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 272 | |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 273 | struct file_stats { |
| 274 | int count; |
| 275 | size_t total, active, inactive, unbound; |
| 276 | }; |
| 277 | |
| 278 | static int per_file_stats(int id, void *ptr, void *data) |
| 279 | { |
| 280 | struct drm_i915_gem_object *obj = ptr; |
| 281 | struct file_stats *stats = data; |
| 282 | |
| 283 | stats->count++; |
| 284 | stats->total += obj->base.size; |
| 285 | |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 286 | if (i915_gem_obj_ggtt_bound(obj)) { |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 287 | if (!list_empty(&obj->ring_list)) |
| 288 | stats->active += obj->base.size; |
| 289 | else |
| 290 | stats->inactive += obj->base.size; |
| 291 | } else { |
| 292 | if (!list_empty(&obj->global_list)) |
| 293 | stats->unbound += obj->base.size; |
| 294 | } |
| 295 | |
| 296 | return 0; |
| 297 | } |
| 298 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 299 | #define count_vmas(list, member) do { \ |
| 300 | list_for_each_entry(vma, list, member) { \ |
| 301 | size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 302 | ++count; \ |
| 303 | if (vma->obj->map_and_fenceable) { \ |
| 304 | mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ |
| 305 | ++mappable_count; \ |
| 306 | } \ |
| 307 | } \ |
| 308 | } while (0) |
| 309 | |
| 310 | static int i915_gem_object_info(struct seq_file *m, void* data) |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 311 | { |
| 312 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 313 | struct drm_device *dev = node->minor->dev; |
| 314 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 315 | u32 count, mappable_count, purgeable_count; |
| 316 | size_t size, mappable_size, purgeable_size; |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 317 | struct drm_i915_gem_object *obj; |
Ben Widawsky | 5cef07e | 2013-07-16 16:50:08 -0700 | [diff] [blame] | 318 | struct i915_address_space *vm = &dev_priv->gtt.base; |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 319 | struct drm_file *file; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 320 | struct i915_vma *vma; |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 321 | int ret; |
| 322 | |
| 323 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 324 | if (ret) |
| 325 | return ret; |
| 326 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 327 | seq_printf(m, "%u objects, %zu bytes\n", |
| 328 | dev_priv->mm.object_count, |
| 329 | dev_priv->mm.object_memory); |
| 330 | |
| 331 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 332 | count_objects(&dev_priv->mm.bound_list, global_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 333 | seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", |
| 334 | count, mappable_count, size, mappable_size); |
| 335 | |
| 336 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 337 | count_vmas(&vm->active_list, mm_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 338 | seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n", |
| 339 | count, mappable_count, size, mappable_size); |
| 340 | |
| 341 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 342 | count_vmas(&vm->inactive_list, mm_list); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 343 | seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n", |
| 344 | count, mappable_count, size, mappable_size); |
| 345 | |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 346 | size = count = purgeable_size = purgeable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 347 | list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) { |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 348 | size += obj->base.size, ++count; |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 349 | if (obj->madv == I915_MADV_DONTNEED) |
| 350 | purgeable_size += obj->base.size, ++purgeable_count; |
| 351 | } |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 352 | seq_printf(m, "%u unbound objects, %zu bytes\n", count, size); |
| 353 | |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 354 | size = count = mappable_size = mappable_count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 355 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 356 | if (obj->fault_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 357 | size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 358 | ++count; |
| 359 | } |
| 360 | if (obj->pin_mappable) { |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 361 | mappable_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 362 | ++mappable_count; |
| 363 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 364 | if (obj->madv == I915_MADV_DONTNEED) { |
| 365 | purgeable_size += obj->base.size; |
| 366 | ++purgeable_count; |
| 367 | } |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 368 | } |
Chris Wilson | b7abb71 | 2012-08-20 11:33:30 +0200 | [diff] [blame] | 369 | seq_printf(m, "%u purgeable objects, %zu bytes\n", |
| 370 | purgeable_count, purgeable_size); |
Chris Wilson | 6299f99 | 2010-11-24 12:23:44 +0000 | [diff] [blame] | 371 | seq_printf(m, "%u pinned mappable objects, %zu bytes\n", |
| 372 | mappable_count, mappable_size); |
| 373 | seq_printf(m, "%u fault mappable objects, %zu bytes\n", |
| 374 | count, size); |
| 375 | |
Ben Widawsky | 93d1879 | 2013-01-17 12:45:17 -0800 | [diff] [blame] | 376 | seq_printf(m, "%zu [%lu] gtt total\n", |
Ben Widawsky | 853ba5d | 2013-07-16 16:50:05 -0700 | [diff] [blame] | 377 | dev_priv->gtt.base.total, |
| 378 | dev_priv->gtt.mappable_end - dev_priv->gtt.base.start); |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 379 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 380 | seq_putc(m, '\n'); |
Chris Wilson | 2db8e9d | 2013-06-04 23:49:08 +0100 | [diff] [blame] | 381 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
| 382 | struct file_stats stats; |
| 383 | |
| 384 | memset(&stats, 0, sizeof(stats)); |
| 385 | idr_for_each(&file->object_idr, per_file_stats, &stats); |
| 386 | seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n", |
| 387 | get_pid_task(file->pid, PIDTYPE_PID)->comm, |
| 388 | stats.count, |
| 389 | stats.total, |
| 390 | stats.active, |
| 391 | stats.inactive, |
| 392 | stats.unbound); |
| 393 | } |
| 394 | |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 395 | mutex_unlock(&dev->struct_mutex); |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 400 | static int i915_gem_gtt_info(struct seq_file *m, void *data) |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 401 | { |
| 402 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 403 | struct drm_device *dev = node->minor->dev; |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 404 | uintptr_t list = (uintptr_t) node->info_ent->data; |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 405 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 406 | struct drm_i915_gem_object *obj; |
| 407 | size_t total_obj_size, total_gtt_size; |
| 408 | int count, ret; |
| 409 | |
| 410 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 411 | if (ret) |
| 412 | return ret; |
| 413 | |
| 414 | total_obj_size = total_gtt_size = count = 0; |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 415 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 416 | if (list == PINNED_LIST && obj->pin_count == 0) |
| 417 | continue; |
| 418 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 419 | seq_puts(m, " "); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 420 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 421 | seq_putc(m, '\n'); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 422 | total_obj_size += obj->base.size; |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 423 | total_gtt_size += i915_gem_obj_ggtt_size(obj); |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 424 | count++; |
| 425 | } |
| 426 | |
| 427 | mutex_unlock(&dev->struct_mutex); |
| 428 | |
| 429 | seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", |
| 430 | count, total_obj_size, total_gtt_size); |
| 431 | |
| 432 | return 0; |
| 433 | } |
| 434 | |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 435 | static int i915_gem_pageflip_info(struct seq_file *m, void *data) |
| 436 | { |
| 437 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 438 | struct drm_device *dev = node->minor->dev; |
| 439 | unsigned long flags; |
| 440 | struct intel_crtc *crtc; |
| 441 | |
| 442 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 443 | const char pipe = pipe_name(crtc->pipe); |
| 444 | const char plane = plane_name(crtc->plane); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 445 | struct intel_unpin_work *work; |
| 446 | |
| 447 | spin_lock_irqsave(&dev->event_lock, flags); |
| 448 | work = crtc->unpin_work; |
| 449 | if (work == NULL) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 450 | seq_printf(m, "No flip due on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 451 | pipe, plane); |
| 452 | } else { |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 453 | if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 454 | seq_printf(m, "Flip queued on pipe %c (plane %c)\n", |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 455 | pipe, plane); |
| 456 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 457 | 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] | 458 | pipe, plane); |
| 459 | } |
| 460 | if (work->enable_stall_check) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 461 | seq_puts(m, "Stall check enabled, "); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 462 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 463 | seq_puts(m, "Stall check waiting for page flip ioctl, "); |
Chris Wilson | e7d841c | 2012-12-03 11:36:30 +0000 | [diff] [blame] | 464 | seq_printf(m, "%d prepares\n", atomic_read(&work->pending)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 465 | |
| 466 | if (work->old_fb_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 467 | struct drm_i915_gem_object *obj = work->old_fb_obj; |
| 468 | if (obj) |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 469 | seq_printf(m, "Old framebuffer gtt_offset 0x%08lx\n", |
| 470 | i915_gem_obj_ggtt_offset(obj)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 471 | } |
| 472 | if (work->pending_flip_obj) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 473 | struct drm_i915_gem_object *obj = work->pending_flip_obj; |
| 474 | if (obj) |
Ben Widawsky | f343c5f | 2013-07-05 14:41:04 -0700 | [diff] [blame] | 475 | seq_printf(m, "New framebuffer gtt_offset 0x%08lx\n", |
| 476 | i915_gem_obj_ggtt_offset(obj)); |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 477 | } |
| 478 | } |
| 479 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 480 | } |
| 481 | |
| 482 | return 0; |
| 483 | } |
| 484 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 485 | static int i915_gem_request_info(struct seq_file *m, void *data) |
| 486 | { |
| 487 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 488 | struct drm_device *dev = node->minor->dev; |
| 489 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 490 | struct intel_ring_buffer *ring; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 491 | struct drm_i915_gem_request *gem_request; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 492 | int ret, count, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 493 | |
| 494 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 495 | if (ret) |
| 496 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 497 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 498 | count = 0; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 499 | for_each_ring(ring, dev_priv, i) { |
| 500 | if (list_empty(&ring->request_list)) |
| 501 | continue; |
| 502 | |
| 503 | seq_printf(m, "%s requests:\n", ring->name); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 504 | list_for_each_entry(gem_request, |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 505 | &ring->request_list, |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 506 | list) { |
| 507 | seq_printf(m, " %d @ %d\n", |
| 508 | gem_request->seqno, |
| 509 | (int) (jiffies - gem_request->emitted_jiffies)); |
| 510 | } |
| 511 | count++; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 512 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 513 | mutex_unlock(&dev->struct_mutex); |
| 514 | |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 515 | if (count == 0) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 516 | seq_puts(m, "No requests\n"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 517 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 518 | return 0; |
| 519 | } |
| 520 | |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 521 | static void i915_ring_seqno_info(struct seq_file *m, |
| 522 | struct intel_ring_buffer *ring) |
| 523 | { |
| 524 | if (ring->get_seqno) { |
Mika Kuoppala | 43a7b92 | 2012-12-04 15:12:01 +0200 | [diff] [blame] | 525 | seq_printf(m, "Current sequence (%s): %u\n", |
Chris Wilson | b2eadbc | 2012-08-09 10:58:30 +0100 | [diff] [blame] | 526 | ring->name, ring->get_seqno(ring, false)); |
Chris Wilson | b222349 | 2010-10-27 15:27:33 +0100 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 530 | static int i915_gem_seqno_info(struct seq_file *m, void *data) |
| 531 | { |
| 532 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 533 | struct drm_device *dev = node->minor->dev; |
| 534 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 535 | struct intel_ring_buffer *ring; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 536 | int ret, i; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 537 | |
| 538 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 539 | if (ret) |
| 540 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 541 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 542 | for_each_ring(ring, dev_priv, i) |
| 543 | i915_ring_seqno_info(m, ring); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 544 | |
| 545 | mutex_unlock(&dev->struct_mutex); |
| 546 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | |
| 551 | static int i915_interrupt_info(struct seq_file *m, void *data) |
| 552 | { |
| 553 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 554 | struct drm_device *dev = node->minor->dev; |
| 555 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 556 | struct intel_ring_buffer *ring; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 557 | int ret, i, pipe; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 558 | |
| 559 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 560 | if (ret) |
| 561 | return ret; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 562 | |
Jesse Barnes | 7e231dbe | 2012-03-28 13:39:38 -0700 | [diff] [blame] | 563 | if (IS_VALLEYVIEW(dev)) { |
| 564 | seq_printf(m, "Display IER:\t%08x\n", |
| 565 | I915_READ(VLV_IER)); |
| 566 | seq_printf(m, "Display IIR:\t%08x\n", |
| 567 | I915_READ(VLV_IIR)); |
| 568 | seq_printf(m, "Display IIR_RW:\t%08x\n", |
| 569 | I915_READ(VLV_IIR_RW)); |
| 570 | seq_printf(m, "Display IMR:\t%08x\n", |
| 571 | I915_READ(VLV_IMR)); |
| 572 | for_each_pipe(pipe) |
| 573 | seq_printf(m, "Pipe %c stat:\t%08x\n", |
| 574 | pipe_name(pipe), |
| 575 | I915_READ(PIPESTAT(pipe))); |
| 576 | |
| 577 | seq_printf(m, "Master IER:\t%08x\n", |
| 578 | I915_READ(VLV_MASTER_IER)); |
| 579 | |
| 580 | seq_printf(m, "Render IER:\t%08x\n", |
| 581 | I915_READ(GTIER)); |
| 582 | seq_printf(m, "Render IIR:\t%08x\n", |
| 583 | I915_READ(GTIIR)); |
| 584 | seq_printf(m, "Render IMR:\t%08x\n", |
| 585 | I915_READ(GTIMR)); |
| 586 | |
| 587 | seq_printf(m, "PM IER:\t\t%08x\n", |
| 588 | I915_READ(GEN6_PMIER)); |
| 589 | seq_printf(m, "PM IIR:\t\t%08x\n", |
| 590 | I915_READ(GEN6_PMIIR)); |
| 591 | seq_printf(m, "PM IMR:\t\t%08x\n", |
| 592 | I915_READ(GEN6_PMIMR)); |
| 593 | |
| 594 | seq_printf(m, "Port hotplug:\t%08x\n", |
| 595 | I915_READ(PORT_HOTPLUG_EN)); |
| 596 | seq_printf(m, "DPFLIPSTAT:\t%08x\n", |
| 597 | I915_READ(VLV_DPFLIPSTAT)); |
| 598 | seq_printf(m, "DPINVGTT:\t%08x\n", |
| 599 | I915_READ(DPINVGTT)); |
| 600 | |
| 601 | } else if (!HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 602 | seq_printf(m, "Interrupt enable: %08x\n", |
| 603 | I915_READ(IER)); |
| 604 | seq_printf(m, "Interrupt identity: %08x\n", |
| 605 | I915_READ(IIR)); |
| 606 | seq_printf(m, "Interrupt mask: %08x\n", |
| 607 | I915_READ(IMR)); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 608 | for_each_pipe(pipe) |
| 609 | seq_printf(m, "Pipe %c stat: %08x\n", |
| 610 | pipe_name(pipe), |
| 611 | I915_READ(PIPESTAT(pipe))); |
Zhenyu Wang | 5f6a169 | 2009-08-10 21:37:24 +0800 | [diff] [blame] | 612 | } else { |
| 613 | seq_printf(m, "North Display Interrupt enable: %08x\n", |
| 614 | I915_READ(DEIER)); |
| 615 | seq_printf(m, "North Display Interrupt identity: %08x\n", |
| 616 | I915_READ(DEIIR)); |
| 617 | seq_printf(m, "North Display Interrupt mask: %08x\n", |
| 618 | I915_READ(DEIMR)); |
| 619 | seq_printf(m, "South Display Interrupt enable: %08x\n", |
| 620 | I915_READ(SDEIER)); |
| 621 | seq_printf(m, "South Display Interrupt identity: %08x\n", |
| 622 | I915_READ(SDEIIR)); |
| 623 | seq_printf(m, "South Display Interrupt mask: %08x\n", |
| 624 | I915_READ(SDEIMR)); |
| 625 | seq_printf(m, "Graphics Interrupt enable: %08x\n", |
| 626 | I915_READ(GTIER)); |
| 627 | seq_printf(m, "Graphics Interrupt identity: %08x\n", |
| 628 | I915_READ(GTIIR)); |
| 629 | seq_printf(m, "Graphics Interrupt mask: %08x\n", |
| 630 | I915_READ(GTIMR)); |
| 631 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 632 | seq_printf(m, "Interrupts received: %d\n", |
| 633 | atomic_read(&dev_priv->irq_received)); |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 634 | for_each_ring(ring, dev_priv, i) { |
Jesse Barnes | da64c6f | 2011-08-09 09:17:46 -0700 | [diff] [blame] | 635 | if (IS_GEN6(dev) || IS_GEN7(dev)) { |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 636 | seq_printf(m, |
| 637 | "Graphics Interrupt mask (%s): %08x\n", |
| 638 | ring->name, I915_READ_IMR(ring)); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 639 | } |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 640 | i915_ring_seqno_info(m, ring); |
Chris Wilson | 9862e60 | 2011-01-04 22:22:17 +0000 | [diff] [blame] | 641 | } |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 642 | mutex_unlock(&dev->struct_mutex); |
| 643 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 644 | return 0; |
| 645 | } |
| 646 | |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 647 | static int i915_gem_fence_regs_info(struct seq_file *m, void *data) |
| 648 | { |
| 649 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 650 | struct drm_device *dev = node->minor->dev; |
| 651 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 652 | int i, ret; |
| 653 | |
| 654 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 655 | if (ret) |
| 656 | return ret; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 657 | |
| 658 | seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start); |
| 659 | seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs); |
| 660 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 661 | struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj; |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 662 | |
Chris Wilson | 6c085a7 | 2012-08-20 11:40:46 +0200 | [diff] [blame] | 663 | seq_printf(m, "Fence %d, pin count = %d, object = ", |
| 664 | i, dev_priv->fence_regs[i].pin_count); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 665 | if (obj == NULL) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 666 | seq_puts(m, "unused"); |
Chris Wilson | c2c347a9 | 2010-10-27 15:11:53 +0100 | [diff] [blame] | 667 | else |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 668 | describe_obj(m, obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 669 | seq_putc(m, '\n'); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 670 | } |
| 671 | |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 672 | mutex_unlock(&dev->struct_mutex); |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 673 | return 0; |
| 674 | } |
| 675 | |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 676 | static int i915_hws_info(struct seq_file *m, void *data) |
| 677 | { |
| 678 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 679 | struct drm_device *dev = node->minor->dev; |
| 680 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 681 | struct intel_ring_buffer *ring; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 682 | const u32 *hws; |
Chris Wilson | 4066c0a | 2010-10-29 21:00:54 +0100 | [diff] [blame] | 683 | int i; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 684 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 685 | ring = &dev_priv->ring[(uintptr_t)node->info_ent->data]; |
Daniel Vetter | 1a240d4 | 2012-11-29 22:18:51 +0100 | [diff] [blame] | 686 | hws = ring->status_page.page_addr; |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 687 | if (hws == NULL) |
| 688 | return 0; |
| 689 | |
| 690 | for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) { |
| 691 | seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", |
| 692 | i * 4, |
| 693 | hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); |
| 694 | } |
| 695 | return 0; |
| 696 | } |
| 697 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 698 | static ssize_t |
| 699 | i915_error_state_write(struct file *filp, |
| 700 | const char __user *ubuf, |
| 701 | size_t cnt, |
| 702 | loff_t *ppos) |
| 703 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 704 | struct i915_error_state_file_priv *error_priv = filp->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 705 | struct drm_device *dev = error_priv->dev; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 706 | int ret; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 707 | |
| 708 | DRM_DEBUG_DRIVER("Resetting error state\n"); |
| 709 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 710 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 711 | if (ret) |
| 712 | return ret; |
| 713 | |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 714 | i915_destroy_error_state(dev); |
| 715 | mutex_unlock(&dev->struct_mutex); |
| 716 | |
| 717 | return cnt; |
| 718 | } |
| 719 | |
| 720 | static int i915_error_state_open(struct inode *inode, struct file *file) |
| 721 | { |
| 722 | struct drm_device *dev = inode->i_private; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 723 | struct i915_error_state_file_priv *error_priv; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 724 | |
| 725 | error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL); |
| 726 | if (!error_priv) |
| 727 | return -ENOMEM; |
| 728 | |
| 729 | error_priv->dev = dev; |
| 730 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 731 | i915_error_state_get(dev, error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 732 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 733 | file->private_data = error_priv; |
| 734 | |
| 735 | return 0; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | static int i915_error_state_release(struct inode *inode, struct file *file) |
| 739 | { |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 740 | struct i915_error_state_file_priv *error_priv = file->private_data; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 741 | |
Mika Kuoppala | 95d5bfb | 2013-06-06 15:18:40 +0300 | [diff] [blame] | 742 | i915_error_state_put(error_priv); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 743 | kfree(error_priv); |
| 744 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, |
| 749 | size_t count, loff_t *pos) |
| 750 | { |
| 751 | struct i915_error_state_file_priv *error_priv = file->private_data; |
| 752 | struct drm_i915_error_state_buf error_str; |
| 753 | loff_t tmp_pos = 0; |
| 754 | ssize_t ret_count = 0; |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 755 | int ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 756 | |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 757 | ret = i915_error_state_buf_init(&error_str, count, *pos); |
| 758 | if (ret) |
| 759 | return ret; |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 760 | |
Mika Kuoppala | fc16b48 | 2013-06-06 15:18:39 +0300 | [diff] [blame] | 761 | ret = i915_error_state_to_str(&error_str, error_priv); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 762 | if (ret) |
| 763 | goto out; |
| 764 | |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 765 | ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos, |
| 766 | error_str.buf, |
| 767 | error_str.bytes); |
| 768 | |
| 769 | if (ret_count < 0) |
| 770 | ret = ret_count; |
| 771 | else |
| 772 | *pos = error_str.start + ret_count; |
| 773 | out: |
Mika Kuoppala | 4dc955f | 2013-06-06 15:18:41 +0300 | [diff] [blame] | 774 | i915_error_state_buf_release(&error_str); |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 775 | return ret ?: ret_count; |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 776 | } |
| 777 | |
| 778 | static const struct file_operations i915_error_state_fops = { |
| 779 | .owner = THIS_MODULE, |
| 780 | .open = i915_error_state_open, |
Mika Kuoppala | edc3d88 | 2013-05-23 13:55:35 +0300 | [diff] [blame] | 781 | .read = i915_error_state_read, |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 782 | .write = i915_error_state_write, |
| 783 | .llseek = default_llseek, |
| 784 | .release = i915_error_state_release, |
| 785 | }; |
| 786 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 787 | static int |
| 788 | i915_next_seqno_get(void *data, u64 *val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 789 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 790 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 791 | drm_i915_private_t *dev_priv = dev->dev_private; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 792 | int ret; |
| 793 | |
| 794 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 795 | if (ret) |
| 796 | return ret; |
| 797 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 798 | *val = dev_priv->next_seqno; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 799 | mutex_unlock(&dev->struct_mutex); |
| 800 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 801 | return 0; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 802 | } |
| 803 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 804 | static int |
| 805 | i915_next_seqno_set(void *data, u64 val) |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 806 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 807 | struct drm_device *dev = data; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 808 | int ret; |
| 809 | |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 810 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 811 | if (ret) |
| 812 | return ret; |
| 813 | |
Mika Kuoppala | e94fbaa | 2012-12-19 11:13:09 +0200 | [diff] [blame] | 814 | ret = i915_gem_set_seqno(dev, val); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 815 | mutex_unlock(&dev->struct_mutex); |
| 816 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 817 | return ret; |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 818 | } |
| 819 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 820 | DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops, |
| 821 | i915_next_seqno_get, i915_next_seqno_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 822 | "0x%llx\n"); |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 823 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 824 | static int i915_rstdby_delays(struct seq_file *m, void *unused) |
| 825 | { |
| 826 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 827 | struct drm_device *dev = node->minor->dev; |
| 828 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 829 | u16 crstanddelay; |
| 830 | int ret; |
| 831 | |
| 832 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 833 | if (ret) |
| 834 | return ret; |
| 835 | |
| 836 | crstanddelay = I915_READ16(CRSTANDVID); |
| 837 | |
| 838 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 839 | |
| 840 | seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f)); |
| 841 | |
| 842 | return 0; |
| 843 | } |
| 844 | |
| 845 | static int i915_cur_delayinfo(struct seq_file *m, void *unused) |
| 846 | { |
| 847 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 848 | struct drm_device *dev = node->minor->dev; |
| 849 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 850 | int ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 851 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 852 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 853 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 854 | if (IS_GEN5(dev)) { |
| 855 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
| 856 | u16 rgvstat = I915_READ16(MEMSTAT_ILK); |
| 857 | |
| 858 | seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); |
| 859 | seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f); |
| 860 | seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> |
| 861 | MEMSTAT_VID_SHIFT); |
| 862 | seq_printf(m, "Current P-state: %d\n", |
| 863 | (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 864 | } else if ((IS_GEN6(dev) || IS_GEN7(dev)) && !IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 865 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
| 866 | u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS); |
| 867 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 868 | u32 rpstat, cagf, reqf; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 869 | u32 rpupei, rpcurup, rpprevup; |
| 870 | u32 rpdownei, rpcurdown, rpprevdown; |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 871 | int max_freq; |
| 872 | |
| 873 | /* RPSTAT1 is in the GT power well */ |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 874 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 875 | if (ret) |
| 876 | return ret; |
| 877 | |
Ben Widawsky | fcca792 | 2011-04-25 11:23:07 -0700 | [diff] [blame] | 878 | gen6_gt_force_wake_get(dev_priv); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 879 | |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 880 | reqf = I915_READ(GEN6_RPNSWREQ); |
| 881 | reqf &= ~GEN6_TURBO_DISABLE; |
| 882 | if (IS_HASWELL(dev)) |
| 883 | reqf >>= 24; |
| 884 | else |
| 885 | reqf >>= 25; |
| 886 | reqf *= GT_FREQUENCY_MULTIPLIER; |
| 887 | |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 888 | rpstat = I915_READ(GEN6_RPSTAT1); |
| 889 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
| 890 | rpcurup = I915_READ(GEN6_RP_CUR_UP); |
| 891 | rpprevup = I915_READ(GEN6_RP_PREV_UP); |
| 892 | rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI); |
| 893 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
| 894 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 895 | if (IS_HASWELL(dev)) |
| 896 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
| 897 | else |
| 898 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
| 899 | cagf *= GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 900 | |
Ben Widawsky | d1ebd816 | 2011-04-25 20:11:50 +0100 | [diff] [blame] | 901 | gen6_gt_force_wake_put(dev_priv); |
| 902 | mutex_unlock(&dev->struct_mutex); |
| 903 | |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 904 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 905 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 906 | seq_printf(m, "Render p-state ratio: %d\n", |
| 907 | (gt_perf_status & 0xff00) >> 8); |
| 908 | seq_printf(m, "Render p-state VID: %d\n", |
| 909 | gt_perf_status & 0xff); |
| 910 | seq_printf(m, "Render p-state limit: %d\n", |
| 911 | rp_state_limits & 0xff); |
Chris Wilson | 8e8c06c | 2013-08-26 19:51:01 -0300 | [diff] [blame] | 912 | seq_printf(m, "RPNSWREQ: %dMHz\n", reqf); |
Ben Widawsky | f82855d | 2013-01-29 12:00:15 -0800 | [diff] [blame] | 913 | seq_printf(m, "CAGF: %dMHz\n", cagf); |
Jesse Barnes | ccab5c8 | 2011-01-18 15:49:25 -0800 | [diff] [blame] | 914 | seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & |
| 915 | GEN6_CURICONT_MASK); |
| 916 | seq_printf(m, "RP CUR UP: %dus\n", rpcurup & |
| 917 | GEN6_CURBSYTAVG_MASK); |
| 918 | seq_printf(m, "RP PREV UP: %dus\n", rpprevup & |
| 919 | GEN6_CURBSYTAVG_MASK); |
| 920 | seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei & |
| 921 | GEN6_CURIAVG_MASK); |
| 922 | seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown & |
| 923 | GEN6_CURBSYTAVG_MASK); |
| 924 | seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown & |
| 925 | GEN6_CURBSYTAVG_MASK); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 926 | |
| 927 | max_freq = (rp_state_cap & 0xff0000) >> 16; |
| 928 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 929 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 930 | |
| 931 | max_freq = (rp_state_cap & 0xff00) >> 8; |
| 932 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 933 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 934 | |
| 935 | max_freq = rp_state_cap & 0xff; |
| 936 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
Ben Widawsky | c8735b0 | 2012-09-07 19:43:39 -0700 | [diff] [blame] | 937 | max_freq * GT_FREQUENCY_MULTIPLIER); |
Ben Widawsky | 31c7738 | 2013-04-05 14:29:22 -0700 | [diff] [blame] | 938 | |
| 939 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
| 940 | dev_priv->rps.hw_max * GT_FREQUENCY_MULTIPLIER); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 941 | } else if (IS_VALLEYVIEW(dev)) { |
| 942 | u32 freq_sts, val; |
| 943 | |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 944 | mutex_lock(&dev_priv->rps.hw_lock); |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 945 | freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 946 | seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); |
| 947 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
| 948 | |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 949 | val = vlv_punit_read(dev_priv, PUNIT_FUSE_BUS1); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 950 | seq_printf(m, "max GPU freq: %d MHz\n", |
| 951 | vlv_gpu_freq(dev_priv->mem_freq, val)); |
| 952 | |
Jani Nikula | 6493625 | 2013-05-22 15:36:20 +0300 | [diff] [blame] | 953 | val = vlv_punit_read(dev_priv, PUNIT_REG_GPU_LFM); |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 954 | seq_printf(m, "min GPU freq: %d MHz\n", |
| 955 | vlv_gpu_freq(dev_priv->mem_freq, val)); |
| 956 | |
| 957 | seq_printf(m, "current GPU freq: %d MHz\n", |
| 958 | vlv_gpu_freq(dev_priv->mem_freq, |
| 959 | (freq_sts >> 8) & 0xff)); |
Jesse Barnes | 259bd5d | 2013-04-22 15:59:30 -0700 | [diff] [blame] | 960 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 961 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 962 | seq_puts(m, "no P-state info available\n"); |
Jesse Barnes | 3b8d8d9 | 2010-12-17 14:19:02 -0800 | [diff] [blame] | 963 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 964 | |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | static int i915_delayfreq_table(struct seq_file *m, void *unused) |
| 969 | { |
| 970 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 971 | struct drm_device *dev = node->minor->dev; |
| 972 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 973 | u32 delayfreq; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 974 | int ret, i; |
| 975 | |
| 976 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 977 | if (ret) |
| 978 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 979 | |
| 980 | for (i = 0; i < 16; i++) { |
| 981 | delayfreq = I915_READ(PXVFREQ_BASE + i * 4); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 982 | seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq, |
| 983 | (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 984 | } |
| 985 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 986 | mutex_unlock(&dev->struct_mutex); |
| 987 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | static inline int MAP_TO_MV(int map) |
| 992 | { |
| 993 | return 1250 - (map * 25); |
| 994 | } |
| 995 | |
| 996 | static int i915_inttoext_table(struct seq_file *m, void *unused) |
| 997 | { |
| 998 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 999 | struct drm_device *dev = node->minor->dev; |
| 1000 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1001 | u32 inttoext; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1002 | int ret, i; |
| 1003 | |
| 1004 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1005 | if (ret) |
| 1006 | return ret; |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1007 | |
| 1008 | for (i = 1; i <= 32; i++) { |
| 1009 | inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4); |
| 1010 | seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext); |
| 1011 | } |
| 1012 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1013 | mutex_unlock(&dev->struct_mutex); |
| 1014 | |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1015 | return 0; |
| 1016 | } |
| 1017 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1018 | static int ironlake_drpc_info(struct seq_file *m) |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1019 | { |
| 1020 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1021 | struct drm_device *dev = node->minor->dev; |
| 1022 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1023 | u32 rgvmodectl, rstdbyctl; |
| 1024 | u16 crstandvid; |
| 1025 | int ret; |
| 1026 | |
| 1027 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1028 | if (ret) |
| 1029 | return ret; |
| 1030 | |
| 1031 | rgvmodectl = I915_READ(MEMMODECTL); |
| 1032 | rstdbyctl = I915_READ(RSTDBYCTL); |
| 1033 | crstandvid = I915_READ16(CRSTANDVID); |
| 1034 | |
| 1035 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1036 | |
| 1037 | seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ? |
| 1038 | "yes" : "no"); |
| 1039 | seq_printf(m, "Boost freq: %d\n", |
| 1040 | (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> |
| 1041 | MEMMODE_BOOST_FREQ_SHIFT); |
| 1042 | seq_printf(m, "HW control enabled: %s\n", |
| 1043 | rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no"); |
| 1044 | seq_printf(m, "SW control enabled: %s\n", |
| 1045 | rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no"); |
| 1046 | seq_printf(m, "Gated voltage change: %s\n", |
| 1047 | rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no"); |
| 1048 | seq_printf(m, "Starting frequency: P%d\n", |
| 1049 | (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1050 | seq_printf(m, "Max P-state: P%d\n", |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1051 | (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1052 | seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); |
| 1053 | seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); |
| 1054 | seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); |
| 1055 | seq_printf(m, "Render standby enabled: %s\n", |
| 1056 | (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes"); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1057 | seq_puts(m, "Current RS state: "); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1058 | switch (rstdbyctl & RSX_STATUS_MASK) { |
| 1059 | case RSX_STATUS_ON: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1060 | seq_puts(m, "on\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1061 | break; |
| 1062 | case RSX_STATUS_RC1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1063 | seq_puts(m, "RC1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1064 | break; |
| 1065 | case RSX_STATUS_RC1E: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1066 | seq_puts(m, "RC1E\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1067 | break; |
| 1068 | case RSX_STATUS_RS1: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1069 | seq_puts(m, "RS1\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1070 | break; |
| 1071 | case RSX_STATUS_RS2: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1072 | seq_puts(m, "RS2 (RC6)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1073 | break; |
| 1074 | case RSX_STATUS_RS3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1075 | seq_puts(m, "RC3 (RC6+)\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1076 | break; |
| 1077 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1078 | seq_puts(m, "unknown\n"); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 1079 | break; |
| 1080 | } |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 1081 | |
| 1082 | return 0; |
| 1083 | } |
| 1084 | |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1085 | static int gen6_drpc_info(struct seq_file *m) |
| 1086 | { |
| 1087 | |
| 1088 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1089 | struct drm_device *dev = node->minor->dev; |
| 1090 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1091 | u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0; |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1092 | unsigned forcewake_count; |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1093 | int count = 0, ret; |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1094 | |
| 1095 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1096 | if (ret) |
| 1097 | return ret; |
| 1098 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1099 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1100 | forcewake_count = dev_priv->uncore.forcewake_count; |
| 1101 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 93b525d | 2012-01-25 13:52:43 +0100 | [diff] [blame] | 1102 | |
| 1103 | if (forcewake_count) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1104 | seq_puts(m, "RC information inaccurate because somebody " |
| 1105 | "holds a forcewake reference \n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1106 | } else { |
| 1107 | /* NB: we cannot use forcewake, else we read the wrong values */ |
| 1108 | while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1)) |
| 1109 | udelay(10); |
| 1110 | seq_printf(m, "RC information accurate: %s\n", yesno(count < 51)); |
| 1111 | } |
| 1112 | |
| 1113 | gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS); |
Chris Wilson | ed71f1b | 2013-07-19 20:36:56 +0100 | [diff] [blame] | 1114 | 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] | 1115 | |
| 1116 | rpmodectl1 = I915_READ(GEN6_RP_CONTROL); |
| 1117 | rcctl1 = I915_READ(GEN6_RC_CONTROL); |
| 1118 | mutex_unlock(&dev->struct_mutex); |
Ben Widawsky | 44cbd33 | 2012-11-06 14:36:36 +0000 | [diff] [blame] | 1119 | mutex_lock(&dev_priv->rps.hw_lock); |
| 1120 | sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids); |
| 1121 | mutex_unlock(&dev_priv->rps.hw_lock); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1122 | |
| 1123 | seq_printf(m, "Video Turbo Mode: %s\n", |
| 1124 | yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO)); |
| 1125 | seq_printf(m, "HW control enabled: %s\n", |
| 1126 | yesno(rpmodectl1 & GEN6_RP_ENABLE)); |
| 1127 | seq_printf(m, "SW control enabled: %s\n", |
| 1128 | yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) == |
| 1129 | GEN6_RP_MEDIA_SW_MODE)); |
Eric Anholt | fff24e2 | 2012-01-23 16:14:05 -0800 | [diff] [blame] | 1130 | seq_printf(m, "RC1e Enabled: %s\n", |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1131 | yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); |
| 1132 | seq_printf(m, "RC6 Enabled: %s\n", |
| 1133 | yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); |
| 1134 | seq_printf(m, "Deep RC6 Enabled: %s\n", |
| 1135 | yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); |
| 1136 | seq_printf(m, "Deepest RC6 Enabled: %s\n", |
| 1137 | yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1138 | seq_puts(m, "Current RC state: "); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1139 | switch (gt_core_status & GEN6_RCn_MASK) { |
| 1140 | case GEN6_RC0: |
| 1141 | if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1142 | seq_puts(m, "Core Power Down\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1143 | else |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1144 | seq_puts(m, "on\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1145 | break; |
| 1146 | case GEN6_RC3: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1147 | seq_puts(m, "RC3\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1148 | break; |
| 1149 | case GEN6_RC6: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1150 | seq_puts(m, "RC6\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1151 | break; |
| 1152 | case GEN6_RC7: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1153 | seq_puts(m, "RC7\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1154 | break; |
| 1155 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1156 | seq_puts(m, "Unknown\n"); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1157 | break; |
| 1158 | } |
| 1159 | |
| 1160 | seq_printf(m, "Core Power Down: %s\n", |
| 1161 | yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); |
Ben Widawsky | cce66a2 | 2012-03-27 18:59:38 -0700 | [diff] [blame] | 1162 | |
| 1163 | /* Not exactly sure what this is */ |
| 1164 | seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n", |
| 1165 | I915_READ(GEN6_GT_GFX_RC6_LOCKED)); |
| 1166 | seq_printf(m, "RC6 residency since boot: %u\n", |
| 1167 | I915_READ(GEN6_GT_GFX_RC6)); |
| 1168 | seq_printf(m, "RC6+ residency since boot: %u\n", |
| 1169 | I915_READ(GEN6_GT_GFX_RC6p)); |
| 1170 | seq_printf(m, "RC6++ residency since boot: %u\n", |
| 1171 | I915_READ(GEN6_GT_GFX_RC6pp)); |
| 1172 | |
Ben Widawsky | ecd8fae | 2012-09-26 10:34:02 -0700 | [diff] [blame] | 1173 | seq_printf(m, "RC6 voltage: %dmV\n", |
| 1174 | GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); |
| 1175 | seq_printf(m, "RC6+ voltage: %dmV\n", |
| 1176 | GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); |
| 1177 | seq_printf(m, "RC6++ voltage: %dmV\n", |
| 1178 | GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); |
Ben Widawsky | 4d85529 | 2011-12-12 19:34:16 -0800 | [diff] [blame] | 1179 | return 0; |
| 1180 | } |
| 1181 | |
| 1182 | static int i915_drpc_info(struct seq_file *m, void *unused) |
| 1183 | { |
| 1184 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1185 | struct drm_device *dev = node->minor->dev; |
| 1186 | |
| 1187 | if (IS_GEN6(dev) || IS_GEN7(dev)) |
| 1188 | return gen6_drpc_info(m); |
| 1189 | else |
| 1190 | return ironlake_drpc_info(m); |
| 1191 | } |
| 1192 | |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1193 | static int i915_fbc_status(struct seq_file *m, void *unused) |
| 1194 | { |
| 1195 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1196 | struct drm_device *dev = node->minor->dev; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1197 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1198 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1199 | if (!I915_HAS_FBC(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1200 | seq_puts(m, "FBC unsupported on this chipset\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1201 | return 0; |
| 1202 | } |
| 1203 | |
Adam Jackson | ee5382a | 2010-04-23 11:17:39 -0400 | [diff] [blame] | 1204 | if (intel_fbc_enabled(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1205 | seq_puts(m, "FBC enabled\n"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1206 | } else { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1207 | seq_puts(m, "FBC disabled: "); |
Ben Widawsky | 5c3fe8b | 2013-06-27 16:30:21 -0700 | [diff] [blame] | 1208 | switch (dev_priv->fbc.no_fbc_reason) { |
Chris Wilson | 29ebf90 | 2013-07-27 17:23:55 +0100 | [diff] [blame] | 1209 | case FBC_OK: |
| 1210 | seq_puts(m, "FBC actived, but currently disabled in hardware"); |
| 1211 | break; |
| 1212 | case FBC_UNSUPPORTED: |
| 1213 | seq_puts(m, "unsupported by this chipset"); |
| 1214 | break; |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1215 | case FBC_NO_OUTPUT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1216 | seq_puts(m, "no outputs"); |
Chris Wilson | bed4a67 | 2010-09-11 10:47:47 +0100 | [diff] [blame] | 1217 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1218 | case FBC_STOLEN_TOO_SMALL: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1219 | seq_puts(m, "not enough stolen memory"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1220 | break; |
| 1221 | case FBC_UNSUPPORTED_MODE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1222 | seq_puts(m, "mode not supported"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1223 | break; |
| 1224 | case FBC_MODE_TOO_LARGE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1225 | seq_puts(m, "mode too large"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1226 | break; |
| 1227 | case FBC_BAD_PLANE: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1228 | seq_puts(m, "FBC unsupported on plane"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1229 | break; |
| 1230 | case FBC_NOT_TILED: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1231 | seq_puts(m, "scanout buffer not tiled"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1232 | break; |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1233 | case FBC_MULTIPLE_PIPES: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1234 | seq_puts(m, "multiple pipes are enabled"); |
Jesse Barnes | 9c928d1 | 2010-07-23 15:20:00 -0700 | [diff] [blame] | 1235 | break; |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1236 | case FBC_MODULE_PARAM: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1237 | seq_puts(m, "disabled per module param (default off)"); |
Jesse Barnes | c1a9f04 | 2011-05-05 15:24:21 -0700 | [diff] [blame] | 1238 | break; |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1239 | case FBC_CHIP_DEFAULT: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1240 | seq_puts(m, "disabled per chip default"); |
Damien Lespiau | 8a5729a | 2013-06-24 16:22:02 +0100 | [diff] [blame] | 1241 | break; |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1242 | default: |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1243 | seq_puts(m, "unknown reason"); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1244 | } |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1245 | seq_putc(m, '\n'); |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 1246 | } |
| 1247 | return 0; |
| 1248 | } |
| 1249 | |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1250 | static int i915_ips_status(struct seq_file *m, void *unused) |
| 1251 | { |
| 1252 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1253 | struct drm_device *dev = node->minor->dev; |
| 1254 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1255 | |
Damien Lespiau | f5adf94 | 2013-06-24 18:29:34 +0100 | [diff] [blame] | 1256 | if (!HAS_IPS(dev)) { |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 1257 | seq_puts(m, "not supported\n"); |
| 1258 | return 0; |
| 1259 | } |
| 1260 | |
| 1261 | if (I915_READ(IPS_CTL) & IPS_ENABLE) |
| 1262 | seq_puts(m, "enabled\n"); |
| 1263 | else |
| 1264 | seq_puts(m, "disabled\n"); |
| 1265 | |
| 1266 | return 0; |
| 1267 | } |
| 1268 | |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1269 | static int i915_sr_status(struct seq_file *m, void *unused) |
| 1270 | { |
| 1271 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1272 | struct drm_device *dev = node->minor->dev; |
| 1273 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1274 | bool sr_enabled = false; |
| 1275 | |
Yuanhan Liu | 1398261 | 2010-12-15 15:42:31 +0800 | [diff] [blame] | 1276 | if (HAS_PCH_SPLIT(dev)) |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1277 | sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 1278 | else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1279 | sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; |
| 1280 | else if (IS_I915GM(dev)) |
| 1281 | sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; |
| 1282 | else if (IS_PINEVIEW(dev)) |
| 1283 | sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; |
| 1284 | |
Chris Wilson | 5ba2aaa | 2010-08-19 18:04:08 +0100 | [diff] [blame] | 1285 | seq_printf(m, "self-refresh: %s\n", |
| 1286 | sr_enabled ? "enabled" : "disabled"); |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 1287 | |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1291 | static int i915_emon_status(struct seq_file *m, void *unused) |
| 1292 | { |
| 1293 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1294 | struct drm_device *dev = node->minor->dev; |
| 1295 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1296 | unsigned long temp, chipset, gfx; |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1297 | int ret; |
| 1298 | |
Chris Wilson | 582be6b | 2012-04-30 19:35:02 +0100 | [diff] [blame] | 1299 | if (!IS_GEN5(dev)) |
| 1300 | return -ENODEV; |
| 1301 | |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1302 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1303 | if (ret) |
| 1304 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1305 | |
| 1306 | temp = i915_mch_val(dev_priv); |
| 1307 | chipset = i915_chipset_val(dev_priv); |
| 1308 | gfx = i915_gfx_val(dev_priv); |
Chris Wilson | de227ef | 2010-07-03 07:58:38 +0100 | [diff] [blame] | 1309 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1310 | |
| 1311 | seq_printf(m, "GMCH temp: %ld\n", temp); |
| 1312 | seq_printf(m, "Chipset power: %ld\n", chipset); |
| 1313 | seq_printf(m, "GFX power: %ld\n", gfx); |
| 1314 | seq_printf(m, "Total power: %ld\n", chipset + gfx); |
| 1315 | |
| 1316 | return 0; |
| 1317 | } |
| 1318 | |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1319 | static int i915_ring_freq_table(struct seq_file *m, void *unused) |
| 1320 | { |
| 1321 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1322 | struct drm_device *dev = node->minor->dev; |
| 1323 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1324 | int ret; |
| 1325 | int gpu_freq, ia_freq; |
| 1326 | |
Jesse Barnes | 1c70c0c | 2011-06-29 13:34:36 -0700 | [diff] [blame] | 1327 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1328 | seq_puts(m, "unsupported on this chipset\n"); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1329 | return 0; |
| 1330 | } |
| 1331 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 1332 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 1333 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1334 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1335 | if (ret) |
| 1336 | return ret; |
| 1337 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1338 | 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] | 1339 | |
Daniel Vetter | c6a828d | 2012-08-08 23:35:35 +0200 | [diff] [blame] | 1340 | for (gpu_freq = dev_priv->rps.min_delay; |
| 1341 | gpu_freq <= dev_priv->rps.max_delay; |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1342 | gpu_freq++) { |
Ben Widawsky | 42c0526 | 2012-09-26 10:34:00 -0700 | [diff] [blame] | 1343 | ia_freq = gpu_freq; |
| 1344 | sandybridge_pcode_read(dev_priv, |
| 1345 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
| 1346 | &ia_freq); |
Chris Wilson | 3ebecd0 | 2013-04-12 19:10:13 +0100 | [diff] [blame] | 1347 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", |
| 1348 | gpu_freq * GT_FREQUENCY_MULTIPLIER, |
| 1349 | ((ia_freq >> 0) & 0xff) * 100, |
| 1350 | ((ia_freq >> 8) & 0xff) * 100); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1351 | } |
| 1352 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 1353 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 1354 | |
| 1355 | return 0; |
| 1356 | } |
| 1357 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1358 | static int i915_gfxec(struct seq_file *m, void *unused) |
| 1359 | { |
| 1360 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1361 | struct drm_device *dev = node->minor->dev; |
| 1362 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1363 | int ret; |
| 1364 | |
| 1365 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1366 | if (ret) |
| 1367 | return ret; |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1368 | |
| 1369 | seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4)); |
| 1370 | |
Ben Widawsky | 616fdb5 | 2011-10-05 11:44:54 -0700 | [diff] [blame] | 1371 | mutex_unlock(&dev->struct_mutex); |
| 1372 | |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 1373 | return 0; |
| 1374 | } |
| 1375 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1376 | static int i915_opregion(struct seq_file *m, void *unused) |
| 1377 | { |
| 1378 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1379 | struct drm_device *dev = node->minor->dev; |
| 1380 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1381 | struct intel_opregion *opregion = &dev_priv->opregion; |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1382 | void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1383 | int ret; |
| 1384 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1385 | if (data == NULL) |
| 1386 | return -ENOMEM; |
| 1387 | |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1388 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1389 | if (ret) |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1390 | goto out; |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1391 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1392 | if (opregion->header) { |
| 1393 | memcpy_fromio(data, opregion->header, OPREGION_SIZE); |
| 1394 | seq_write(m, data, OPREGION_SIZE); |
| 1395 | } |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1396 | |
| 1397 | mutex_unlock(&dev->struct_mutex); |
| 1398 | |
Daniel Vetter | 0d38f00 | 2012-04-21 22:49:10 +0200 | [diff] [blame] | 1399 | out: |
| 1400 | kfree(data); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1401 | return 0; |
| 1402 | } |
| 1403 | |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1404 | static int i915_gem_framebuffer_info(struct seq_file *m, void *data) |
| 1405 | { |
| 1406 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1407 | struct drm_device *dev = node->minor->dev; |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1408 | struct intel_fbdev *ifbdev = NULL; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1409 | struct intel_framebuffer *fb; |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1410 | |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1411 | #ifdef CONFIG_DRM_I915_FBDEV |
| 1412 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1413 | int ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1414 | if (ret) |
| 1415 | return ret; |
| 1416 | |
| 1417 | ifbdev = dev_priv->fbdev; |
| 1418 | fb = to_intel_framebuffer(ifbdev->helper.fb); |
| 1419 | |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1420 | 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] | 1421 | fb->base.width, |
| 1422 | fb->base.height, |
| 1423 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1424 | fb->base.bits_per_pixel, |
| 1425 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1426 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1427 | seq_putc(m, '\n'); |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1428 | mutex_unlock(&dev->mode_config.mutex); |
Daniel Vetter | 4520f53 | 2013-10-09 09:18:51 +0200 | [diff] [blame] | 1429 | #endif |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1430 | |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1431 | mutex_lock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1432 | list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) { |
| 1433 | if (&fb->base == ifbdev->helper.fb) |
| 1434 | continue; |
| 1435 | |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1436 | 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] | 1437 | fb->base.width, |
| 1438 | fb->base.height, |
| 1439 | fb->base.depth, |
Daniel Vetter | 623f978 | 2012-12-11 16:21:38 +0100 | [diff] [blame] | 1440 | fb->base.bits_per_pixel, |
| 1441 | atomic_read(&fb->base.refcount.refcount)); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 1442 | describe_obj(m, fb->obj); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1443 | seq_putc(m, '\n'); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1444 | } |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1445 | mutex_unlock(&dev->mode_config.fb_lock); |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 1446 | |
| 1447 | return 0; |
| 1448 | } |
| 1449 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1450 | static int i915_context_status(struct seq_file *m, void *unused) |
| 1451 | { |
| 1452 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1453 | struct drm_device *dev = node->minor->dev; |
| 1454 | drm_i915_private_t *dev_priv = dev->dev_private; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1455 | struct intel_ring_buffer *ring; |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1456 | struct i915_hw_context *ctx; |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1457 | int ret, i; |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1458 | |
| 1459 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
| 1460 | if (ret) |
| 1461 | return ret; |
| 1462 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1463 | if (dev_priv->ips.pwrctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1464 | seq_puts(m, "power context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1465 | describe_obj(m, dev_priv->ips.pwrctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1466 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1467 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1468 | |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1469 | if (dev_priv->ips.renderctx) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1470 | seq_puts(m, "render context "); |
Daniel Vetter | 3e37394 | 2012-11-02 19:55:04 +0100 | [diff] [blame] | 1471 | describe_obj(m, dev_priv->ips.renderctx); |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1472 | seq_putc(m, '\n'); |
Ben Widawsky | dc501fb | 2011-06-29 11:41:51 -0700 | [diff] [blame] | 1473 | } |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1474 | |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1475 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
| 1476 | seq_puts(m, "HW context "); |
Ben Widawsky | 3ccfd19 | 2013-09-18 19:03:18 -0700 | [diff] [blame] | 1477 | describe_ctx(m, ctx); |
Ben Widawsky | a33afea | 2013-09-17 21:12:45 -0700 | [diff] [blame] | 1478 | for_each_ring(ring, dev_priv, i) |
| 1479 | if (ring->default_context == ctx) |
| 1480 | seq_printf(m, "(default context %s) ", ring->name); |
| 1481 | |
| 1482 | describe_obj(m, ctx->obj); |
| 1483 | seq_putc(m, '\n'); |
Ben Widawsky | a168c29 | 2013-02-14 15:05:12 -0800 | [diff] [blame] | 1484 | } |
| 1485 | |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 1486 | mutex_unlock(&dev->mode_config.mutex); |
| 1487 | |
| 1488 | return 0; |
| 1489 | } |
| 1490 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1491 | static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data) |
| 1492 | { |
| 1493 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1494 | struct drm_device *dev = node->minor->dev; |
| 1495 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 9f1f46a | 2011-12-14 13:57:03 +0100 | [diff] [blame] | 1496 | unsigned forcewake_count; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1497 | |
Chris Wilson | 907b28c | 2013-07-19 20:36:52 +0100 | [diff] [blame] | 1498 | spin_lock_irq(&dev_priv->uncore.lock); |
| 1499 | forcewake_count = dev_priv->uncore.forcewake_count; |
| 1500 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 9f1f46a | 2011-12-14 13:57:03 +0100 | [diff] [blame] | 1501 | |
| 1502 | seq_printf(m, "forcewake count = %u\n", forcewake_count); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 1503 | |
| 1504 | return 0; |
| 1505 | } |
| 1506 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1507 | static const char *swizzle_string(unsigned swizzle) |
| 1508 | { |
Damien Lespiau | aee56cf | 2013-06-24 22:59:49 +0100 | [diff] [blame] | 1509 | switch (swizzle) { |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1510 | case I915_BIT_6_SWIZZLE_NONE: |
| 1511 | return "none"; |
| 1512 | case I915_BIT_6_SWIZZLE_9: |
| 1513 | return "bit9"; |
| 1514 | case I915_BIT_6_SWIZZLE_9_10: |
| 1515 | return "bit9/bit10"; |
| 1516 | case I915_BIT_6_SWIZZLE_9_11: |
| 1517 | return "bit9/bit11"; |
| 1518 | case I915_BIT_6_SWIZZLE_9_10_11: |
| 1519 | return "bit9/bit10/bit11"; |
| 1520 | case I915_BIT_6_SWIZZLE_9_17: |
| 1521 | return "bit9/bit17"; |
| 1522 | case I915_BIT_6_SWIZZLE_9_10_17: |
| 1523 | return "bit9/bit10/bit17"; |
| 1524 | case I915_BIT_6_SWIZZLE_UNKNOWN: |
Masanari Iida | 8a168ca | 2012-12-29 02:00:09 +0900 | [diff] [blame] | 1525 | return "unknown"; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | return "bug"; |
| 1529 | } |
| 1530 | |
| 1531 | static int i915_swizzle_info(struct seq_file *m, void *data) |
| 1532 | { |
| 1533 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1534 | struct drm_device *dev = node->minor->dev; |
| 1535 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1536 | int ret; |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1537 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 1538 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1539 | if (ret) |
| 1540 | return ret; |
| 1541 | |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1542 | seq_printf(m, "bit6 swizzle for X-tiling = %s\n", |
| 1543 | swizzle_string(dev_priv->mm.bit_6_swizzle_x)); |
| 1544 | seq_printf(m, "bit6 swizzle for Y-tiling = %s\n", |
| 1545 | swizzle_string(dev_priv->mm.bit_6_swizzle_y)); |
| 1546 | |
| 1547 | if (IS_GEN3(dev) || IS_GEN4(dev)) { |
| 1548 | seq_printf(m, "DDC = 0x%08x\n", |
| 1549 | I915_READ(DCC)); |
| 1550 | seq_printf(m, "C0DRB3 = 0x%04x\n", |
| 1551 | I915_READ16(C0DRB3)); |
| 1552 | seq_printf(m, "C1DRB3 = 0x%04x\n", |
| 1553 | I915_READ16(C1DRB3)); |
Daniel Vetter | 3fa7d23 | 2012-01-31 16:47:56 +0100 | [diff] [blame] | 1554 | } else if (IS_GEN6(dev) || IS_GEN7(dev)) { |
| 1555 | seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n", |
| 1556 | I915_READ(MAD_DIMM_C0)); |
| 1557 | seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n", |
| 1558 | I915_READ(MAD_DIMM_C1)); |
| 1559 | seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n", |
| 1560 | I915_READ(MAD_DIMM_C2)); |
| 1561 | seq_printf(m, "TILECTL = 0x%08x\n", |
| 1562 | I915_READ(TILECTL)); |
| 1563 | seq_printf(m, "ARB_MODE = 0x%08x\n", |
| 1564 | I915_READ(ARB_MODE)); |
| 1565 | seq_printf(m, "DISP_ARB_CTL = 0x%08x\n", |
| 1566 | I915_READ(DISP_ARB_CTL)); |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 1567 | } |
| 1568 | mutex_unlock(&dev->struct_mutex); |
| 1569 | |
| 1570 | return 0; |
| 1571 | } |
| 1572 | |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 1573 | static int i915_ppgtt_info(struct seq_file *m, void *data) |
| 1574 | { |
| 1575 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1576 | struct drm_device *dev = node->minor->dev; |
| 1577 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1578 | struct intel_ring_buffer *ring; |
| 1579 | int i, ret; |
| 1580 | |
| 1581 | |
| 1582 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1583 | if (ret) |
| 1584 | return ret; |
| 1585 | if (INTEL_INFO(dev)->gen == 6) |
| 1586 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE)); |
| 1587 | |
Chris Wilson | a2c7f6f | 2012-09-01 20:51:22 +0100 | [diff] [blame] | 1588 | for_each_ring(ring, dev_priv, i) { |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 1589 | seq_printf(m, "%s\n", ring->name); |
| 1590 | if (INTEL_INFO(dev)->gen == 7) |
| 1591 | seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring))); |
| 1592 | seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring))); |
| 1593 | seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring))); |
| 1594 | seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring))); |
| 1595 | } |
| 1596 | if (dev_priv->mm.aliasing_ppgtt) { |
| 1597 | struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; |
| 1598 | |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1599 | seq_puts(m, "aliasing PPGTT:\n"); |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 1600 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset); |
| 1601 | } |
| 1602 | seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK)); |
| 1603 | mutex_unlock(&dev->struct_mutex); |
| 1604 | |
| 1605 | return 0; |
| 1606 | } |
| 1607 | |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1608 | static int i915_dpio_info(struct seq_file *m, void *data) |
| 1609 | { |
| 1610 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1611 | struct drm_device *dev = node->minor->dev; |
| 1612 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1613 | int ret; |
| 1614 | |
| 1615 | |
| 1616 | if (!IS_VALLEYVIEW(dev)) { |
Damien Lespiau | 267f0c9 | 2013-06-24 22:59:48 +0100 | [diff] [blame] | 1617 | seq_puts(m, "unsupported\n"); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1618 | return 0; |
| 1619 | } |
| 1620 | |
Daniel Vetter | 0915300 | 2012-12-12 14:06:44 +0100 | [diff] [blame] | 1621 | ret = mutex_lock_interruptible(&dev_priv->dpio_lock); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1622 | if (ret) |
| 1623 | return ret; |
| 1624 | |
| 1625 | seq_printf(m, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL)); |
| 1626 | |
| 1627 | seq_printf(m, "DPIO_DIV_A: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1628 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_DIV_A)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1629 | seq_printf(m, "DPIO_DIV_B: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1630 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_DIV_B)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1631 | |
| 1632 | seq_printf(m, "DPIO_REFSFR_A: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1633 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_REFSFR_A)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1634 | seq_printf(m, "DPIO_REFSFR_B: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1635 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_REFSFR_B)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1636 | |
| 1637 | seq_printf(m, "DPIO_CORE_CLK_A: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1638 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_CORE_CLK_A)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1639 | seq_printf(m, "DPIO_CORE_CLK_B: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1640 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_CORE_CLK_B)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1641 | |
Ville Syrjälä | 4abb2c3 | 2013-06-14 14:02:53 +0300 | [diff] [blame] | 1642 | seq_printf(m, "DPIO_LPF_COEFF_A: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1643 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_LPF_COEFF_A)); |
Ville Syrjälä | 4abb2c3 | 2013-06-14 14:02:53 +0300 | [diff] [blame] | 1644 | seq_printf(m, "DPIO_LPF_COEFF_B: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1645 | vlv_dpio_read(dev_priv, PIPE_A, _DPIO_LPF_COEFF_B)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1646 | |
| 1647 | seq_printf(m, "DPIO_FASTCLK_DISABLE: 0x%08x\n", |
Chon Ming Lee | 5e69f97 | 2013-09-05 20:41:49 +0800 | [diff] [blame] | 1648 | vlv_dpio_read(dev_priv, PIPE_A, DPIO_FASTCLK_DISABLE)); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1649 | |
Daniel Vetter | 0915300 | 2012-12-12 14:06:44 +0100 | [diff] [blame] | 1650 | mutex_unlock(&dev_priv->dpio_lock); |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 1651 | |
| 1652 | return 0; |
| 1653 | } |
| 1654 | |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 1655 | static int i915_llc(struct seq_file *m, void *data) |
| 1656 | { |
| 1657 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1658 | struct drm_device *dev = node->minor->dev; |
| 1659 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1660 | |
| 1661 | /* Size calculation for LLC is a bit of a pain. Ignore for now. */ |
| 1662 | seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev))); |
| 1663 | seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size); |
| 1664 | |
| 1665 | return 0; |
| 1666 | } |
| 1667 | |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 1668 | static int i915_edp_psr_status(struct seq_file *m, void *data) |
| 1669 | { |
| 1670 | struct drm_info_node *node = m->private; |
| 1671 | struct drm_device *dev = node->minor->dev; |
| 1672 | struct drm_i915_private *dev_priv = dev->dev_private; |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 1673 | u32 psrperf = 0; |
| 1674 | bool enabled = false; |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 1675 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 1676 | seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support)); |
| 1677 | seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 1678 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 1679 | enabled = HAS_PSR(dev) && |
| 1680 | I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE; |
| 1681 | seq_printf(m, "Enabled: %s\n", yesno(enabled)); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 1682 | |
Rodrigo Vivi | a031d70 | 2013-10-03 16:15:06 -0300 | [diff] [blame] | 1683 | if (HAS_PSR(dev)) |
| 1684 | psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) & |
| 1685 | EDP_PSR_PERF_CNT_MASK; |
| 1686 | seq_printf(m, "Performance_Counter: %u\n", psrperf); |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 1687 | |
| 1688 | return 0; |
| 1689 | } |
| 1690 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 1691 | static int i915_energy_uJ(struct seq_file *m, void *data) |
| 1692 | { |
| 1693 | struct drm_info_node *node = m->private; |
| 1694 | struct drm_device *dev = node->minor->dev; |
| 1695 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1696 | u64 power; |
| 1697 | u32 units; |
| 1698 | |
| 1699 | if (INTEL_INFO(dev)->gen < 6) |
| 1700 | return -ENODEV; |
| 1701 | |
| 1702 | rdmsrl(MSR_RAPL_POWER_UNIT, power); |
| 1703 | power = (power & 0x1f00) >> 8; |
| 1704 | units = 1000000 / (1 << power); /* convert to uJ */ |
| 1705 | power = I915_READ(MCH_SECP_NRG_STTS); |
| 1706 | power *= units; |
| 1707 | |
| 1708 | seq_printf(m, "%llu", (long long unsigned)power); |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 1709 | |
| 1710 | return 0; |
| 1711 | } |
| 1712 | |
| 1713 | static int i915_pc8_status(struct seq_file *m, void *unused) |
| 1714 | { |
| 1715 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1716 | struct drm_device *dev = node->minor->dev; |
| 1717 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1718 | |
| 1719 | if (!IS_HASWELL(dev)) { |
| 1720 | seq_puts(m, "not supported\n"); |
| 1721 | return 0; |
| 1722 | } |
| 1723 | |
| 1724 | mutex_lock(&dev_priv->pc8.lock); |
| 1725 | seq_printf(m, "Requirements met: %s\n", |
| 1726 | yesno(dev_priv->pc8.requirements_met)); |
| 1727 | seq_printf(m, "GPU idle: %s\n", yesno(dev_priv->pc8.gpu_idle)); |
| 1728 | seq_printf(m, "Disable count: %d\n", dev_priv->pc8.disable_count); |
| 1729 | seq_printf(m, "IRQs disabled: %s\n", |
| 1730 | yesno(dev_priv->pc8.irqs_disabled)); |
| 1731 | seq_printf(m, "Enabled: %s\n", yesno(dev_priv->pc8.enabled)); |
| 1732 | mutex_unlock(&dev_priv->pc8.lock); |
| 1733 | |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 1734 | return 0; |
| 1735 | } |
| 1736 | |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1737 | static int i915_pipe_crc(struct seq_file *m, void *data) |
| 1738 | { |
| 1739 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1740 | struct drm_device *dev = node->minor->dev; |
| 1741 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1742 | enum pipe pipe = (enum pipe)node->info_ent->data; |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1743 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
| 1744 | int head, tail; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1745 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 1746 | if (dev_priv->pipe_crc[pipe].source == INTEL_PIPE_CRC_SOURCE_NONE) { |
| 1747 | seq_puts(m, "none\n"); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1748 | return 0; |
| 1749 | } |
| 1750 | |
Damien Lespiau | ac2300d | 2013-10-15 18:55:30 +0100 | [diff] [blame] | 1751 | seq_puts(m, " frame CRC1 CRC2 CRC3 CRC4 CRC5\n"); |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1752 | head = atomic_read(&pipe_crc->head); |
| 1753 | tail = atomic_read(&pipe_crc->tail); |
| 1754 | |
| 1755 | while (CIRC_CNT(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) >= 1) { |
| 1756 | struct intel_pipe_crc_entry *entry = &pipe_crc->entries[tail]; |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1757 | |
Damien Lespiau | ac2300d | 2013-10-15 18:55:30 +0100 | [diff] [blame] | 1758 | seq_printf(m, "%8u %8x %8x %8x %8x %8x\n", entry->frame, |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1759 | entry->crc[0], entry->crc[1], entry->crc[2], |
| 1760 | entry->crc[3], entry->crc[4]); |
Damien Lespiau | b2c88f5 | 2013-10-15 18:55:29 +0100 | [diff] [blame] | 1761 | |
| 1762 | BUILD_BUG_ON_NOT_POWER_OF_2(INTEL_PIPE_CRC_ENTRIES_NR); |
| 1763 | tail = (tail + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); |
| 1764 | atomic_set(&pipe_crc->tail, tail); |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 1765 | } |
| 1766 | |
| 1767 | return 0; |
| 1768 | } |
| 1769 | |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 1770 | static const char *pipe_crc_sources[] = { |
| 1771 | "none", |
| 1772 | "plane1", |
| 1773 | "plane2", |
| 1774 | "pf", |
| 1775 | }; |
| 1776 | |
| 1777 | static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) |
| 1778 | { |
| 1779 | BUILD_BUG_ON(ARRAY_SIZE(pipe_crc_sources) != INTEL_PIPE_CRC_SOURCE_MAX); |
| 1780 | return pipe_crc_sources[source]; |
| 1781 | } |
| 1782 | |
| 1783 | static int pipe_crc_ctl_show(struct seq_file *m, void *data) |
| 1784 | { |
| 1785 | struct drm_device *dev = m->private; |
| 1786 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1787 | int i; |
| 1788 | |
| 1789 | for (i = 0; i < I915_MAX_PIPES; i++) |
| 1790 | seq_printf(m, "%c %s\n", pipe_name(i), |
| 1791 | pipe_crc_source_name(dev_priv->pipe_crc[i].source)); |
| 1792 | |
| 1793 | return 0; |
| 1794 | } |
| 1795 | |
| 1796 | static int pipe_crc_ctl_open(struct inode *inode, struct file *file) |
| 1797 | { |
| 1798 | struct drm_device *dev = inode->i_private; |
| 1799 | |
| 1800 | return single_open(file, pipe_crc_ctl_show, dev); |
| 1801 | } |
| 1802 | |
| 1803 | static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, |
| 1804 | enum intel_pipe_crc_source source) |
| 1805 | { |
| 1806 | struct drm_i915_private *dev_priv = dev->dev_private; |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 1807 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 1808 | u32 val; |
| 1809 | |
| 1810 | |
| 1811 | return -ENODEV; |
| 1812 | |
| 1813 | if (!IS_IVYBRIDGE(dev)) |
| 1814 | return -ENODEV; |
| 1815 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 1816 | if (pipe_crc->source == source) |
| 1817 | return 0; |
| 1818 | |
Damien Lespiau | ae676fc | 2013-10-15 18:55:32 +0100 | [diff] [blame^] | 1819 | /* forbid changing the source without going back to 'none' */ |
| 1820 | if (pipe_crc->source && source) |
| 1821 | return -EINVAL; |
| 1822 | |
Damien Lespiau | cc3da17 | 2013-10-15 18:55:31 +0100 | [diff] [blame] | 1823 | pipe_crc->source = source; |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 1824 | |
| 1825 | switch (source) { |
| 1826 | case INTEL_PIPE_CRC_SOURCE_PLANE1: |
| 1827 | val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; |
| 1828 | break; |
| 1829 | case INTEL_PIPE_CRC_SOURCE_PLANE2: |
| 1830 | val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB; |
| 1831 | break; |
| 1832 | case INTEL_PIPE_CRC_SOURCE_PF: |
| 1833 | val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB; |
| 1834 | break; |
| 1835 | case INTEL_PIPE_CRC_SOURCE_NONE: |
| 1836 | default: |
| 1837 | val = 0; |
| 1838 | break; |
| 1839 | } |
| 1840 | |
| 1841 | I915_WRITE(PIPE_CRC_CTL(pipe), val); |
| 1842 | POSTING_READ(PIPE_CRC_CTL(pipe)); |
| 1843 | |
| 1844 | return 0; |
| 1845 | } |
| 1846 | |
| 1847 | /* |
| 1848 | * Parse pipe CRC command strings: |
| 1849 | * command: wsp* pipe wsp+ source wsp* |
| 1850 | * pipe: (A | B | C) |
| 1851 | * source: (none | plane1 | plane2 | pf) |
| 1852 | * wsp: (#0x20 | #0x9 | #0xA)+ |
| 1853 | * |
| 1854 | * eg.: |
| 1855 | * "A plane1" -> Start CRC computations on plane1 of pipe A |
| 1856 | * "A none" -> Stop CRC |
| 1857 | */ |
| 1858 | static int pipe_crc_ctl_tokenize(char *buf, char *words[], int max_words) |
| 1859 | { |
| 1860 | int n_words = 0; |
| 1861 | |
| 1862 | while (*buf) { |
| 1863 | char *end; |
| 1864 | |
| 1865 | /* skip leading white space */ |
| 1866 | buf = skip_spaces(buf); |
| 1867 | if (!*buf) |
| 1868 | break; /* end of buffer */ |
| 1869 | |
| 1870 | /* find end of word */ |
| 1871 | for (end = buf; *end && !isspace(*end); end++) |
| 1872 | ; |
| 1873 | |
| 1874 | if (n_words == max_words) { |
| 1875 | DRM_DEBUG_DRIVER("too many words, allowed <= %d\n", |
| 1876 | max_words); |
| 1877 | return -EINVAL; /* ran out of words[] before bytes */ |
| 1878 | } |
| 1879 | |
| 1880 | if (*end) |
| 1881 | *end++ = '\0'; |
| 1882 | words[n_words++] = buf; |
| 1883 | buf = end; |
| 1884 | } |
| 1885 | |
| 1886 | return n_words; |
| 1887 | } |
| 1888 | |
| 1889 | static int pipe_crc_ctl_parse_pipe(const char *buf, enum pipe *pipe) |
| 1890 | { |
| 1891 | const char name = buf[0]; |
| 1892 | |
| 1893 | if (name < 'A' || name >= pipe_name(I915_MAX_PIPES)) |
| 1894 | return -EINVAL; |
| 1895 | |
| 1896 | *pipe = name - 'A'; |
| 1897 | |
| 1898 | return 0; |
| 1899 | } |
| 1900 | |
| 1901 | static int |
| 1902 | pipe_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *source) |
| 1903 | { |
| 1904 | int i; |
| 1905 | |
| 1906 | for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) |
| 1907 | if (!strcmp(buf, pipe_crc_sources[i])) { |
| 1908 | *source = i; |
| 1909 | return 0; |
| 1910 | } |
| 1911 | |
| 1912 | return -EINVAL; |
| 1913 | } |
| 1914 | |
| 1915 | static int pipe_crc_ctl_parse(struct drm_device *dev, char *buf, size_t len) |
| 1916 | { |
| 1917 | #define MAX_WORDS 2 |
| 1918 | int n_words; |
| 1919 | char *words[MAX_WORDS]; |
| 1920 | enum pipe pipe; |
| 1921 | enum intel_pipe_crc_source source; |
| 1922 | |
| 1923 | n_words = pipe_crc_ctl_tokenize(buf, words, MAX_WORDS); |
| 1924 | if (n_words != 2) { |
| 1925 | DRM_DEBUG_DRIVER("tokenize failed, a command is 2 words\n"); |
| 1926 | return -EINVAL; |
| 1927 | } |
| 1928 | |
| 1929 | if (pipe_crc_ctl_parse_pipe(words[0], &pipe) < 0) { |
| 1930 | DRM_DEBUG_DRIVER("unknown pipe %s\n", words[0]); |
| 1931 | return -EINVAL; |
| 1932 | } |
| 1933 | |
| 1934 | if (pipe_crc_ctl_parse_source(words[1], &source) < 0) { |
| 1935 | DRM_DEBUG_DRIVER("unknown source %s\n", words[1]); |
| 1936 | return -EINVAL; |
| 1937 | } |
| 1938 | |
| 1939 | return pipe_crc_set_source(dev, pipe, source); |
| 1940 | } |
| 1941 | |
| 1942 | static ssize_t pipe_crc_ctl_write(struct file *file, const char __user *ubuf, |
| 1943 | size_t len, loff_t *offp) |
| 1944 | { |
| 1945 | struct seq_file *m = file->private_data; |
| 1946 | struct drm_device *dev = m->private; |
| 1947 | char *tmpbuf; |
| 1948 | int ret; |
| 1949 | |
| 1950 | if (len == 0) |
| 1951 | return 0; |
| 1952 | |
| 1953 | if (len > PAGE_SIZE - 1) { |
| 1954 | DRM_DEBUG_DRIVER("expected <%lu bytes into pipe crc control\n", |
| 1955 | PAGE_SIZE); |
| 1956 | return -E2BIG; |
| 1957 | } |
| 1958 | |
| 1959 | tmpbuf = kmalloc(len + 1, GFP_KERNEL); |
| 1960 | if (!tmpbuf) |
| 1961 | return -ENOMEM; |
| 1962 | |
| 1963 | if (copy_from_user(tmpbuf, ubuf, len)) { |
| 1964 | ret = -EFAULT; |
| 1965 | goto out; |
| 1966 | } |
| 1967 | tmpbuf[len] = '\0'; |
| 1968 | |
| 1969 | ret = pipe_crc_ctl_parse(dev, tmpbuf, len); |
| 1970 | |
| 1971 | out: |
| 1972 | kfree(tmpbuf); |
| 1973 | if (ret < 0) |
| 1974 | return ret; |
| 1975 | |
| 1976 | *offp += len; |
| 1977 | return len; |
| 1978 | } |
| 1979 | |
| 1980 | static const struct file_operations i915_pipe_crc_ctl_fops = { |
| 1981 | .owner = THIS_MODULE, |
| 1982 | .open = pipe_crc_ctl_open, |
| 1983 | .read = seq_read, |
| 1984 | .llseek = seq_lseek, |
| 1985 | .release = single_release, |
| 1986 | .write = pipe_crc_ctl_write |
| 1987 | }; |
| 1988 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1989 | static int |
| 1990 | i915_wedged_get(void *data, u64 *val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1991 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1992 | struct drm_device *dev = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1993 | drm_i915_private_t *dev_priv = dev->dev_private; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1994 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1995 | *val = atomic_read(&dev_priv->gpu_error.reset_counter); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1996 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 1997 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 1998 | } |
| 1999 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2000 | static int |
| 2001 | i915_wedged_set(void *data, u64 val) |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2002 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2003 | struct drm_device *dev = data; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2004 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2005 | DRM_INFO("Manually setting wedged to %llu\n", val); |
Chris Wilson | 527f9e9 | 2010-11-11 01:16:58 +0000 | [diff] [blame] | 2006 | i915_handle_error(dev, val); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2007 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2008 | return 0; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2009 | } |
| 2010 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2011 | DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops, |
| 2012 | i915_wedged_get, i915_wedged_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 2013 | "%llu\n"); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2014 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2015 | static int |
| 2016 | i915_ring_stop_get(void *data, u64 *val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2017 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2018 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2019 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2020 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2021 | *val = dev_priv->gpu_error.stop_rings; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2022 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2023 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2024 | } |
| 2025 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2026 | static int |
| 2027 | i915_ring_stop_set(void *data, u64 val) |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2028 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2029 | struct drm_device *dev = data; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2030 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2031 | int ret; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2032 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2033 | DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val); |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2034 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2035 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2036 | if (ret) |
| 2037 | return ret; |
| 2038 | |
Daniel Vetter | 99584db | 2012-11-14 17:14:04 +0100 | [diff] [blame] | 2039 | dev_priv->gpu_error.stop_rings = val; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2040 | mutex_unlock(&dev->struct_mutex); |
| 2041 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2042 | return 0; |
Daniel Vetter | e5eb3d6 | 2012-05-03 14:48:16 +0200 | [diff] [blame] | 2043 | } |
| 2044 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2045 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops, |
| 2046 | i915_ring_stop_get, i915_ring_stop_set, |
| 2047 | "0x%08llx\n"); |
Daniel Vetter | d544230 | 2012-04-27 15:17:40 +0200 | [diff] [blame] | 2048 | |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 2049 | static int |
| 2050 | i915_ring_missed_irq_get(void *data, u64 *val) |
| 2051 | { |
| 2052 | struct drm_device *dev = data; |
| 2053 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2054 | |
| 2055 | *val = dev_priv->gpu_error.missed_irq_rings; |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
| 2059 | static int |
| 2060 | i915_ring_missed_irq_set(void *data, u64 val) |
| 2061 | { |
| 2062 | struct drm_device *dev = data; |
| 2063 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2064 | int ret; |
| 2065 | |
| 2066 | /* Lock against concurrent debugfs callers */ |
| 2067 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2068 | if (ret) |
| 2069 | return ret; |
| 2070 | dev_priv->gpu_error.missed_irq_rings = val; |
| 2071 | mutex_unlock(&dev->struct_mutex); |
| 2072 | |
| 2073 | return 0; |
| 2074 | } |
| 2075 | |
| 2076 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops, |
| 2077 | i915_ring_missed_irq_get, i915_ring_missed_irq_set, |
| 2078 | "0x%08llx\n"); |
| 2079 | |
| 2080 | static int |
| 2081 | i915_ring_test_irq_get(void *data, u64 *val) |
| 2082 | { |
| 2083 | struct drm_device *dev = data; |
| 2084 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2085 | |
| 2086 | *val = dev_priv->gpu_error.test_irq_rings; |
| 2087 | |
| 2088 | return 0; |
| 2089 | } |
| 2090 | |
| 2091 | static int |
| 2092 | i915_ring_test_irq_set(void *data, u64 val) |
| 2093 | { |
| 2094 | struct drm_device *dev = data; |
| 2095 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2096 | int ret; |
| 2097 | |
| 2098 | DRM_DEBUG_DRIVER("Masking interrupts on rings 0x%08llx\n", val); |
| 2099 | |
| 2100 | /* Lock against concurrent debugfs callers */ |
| 2101 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2102 | if (ret) |
| 2103 | return ret; |
| 2104 | |
| 2105 | dev_priv->gpu_error.test_irq_rings = val; |
| 2106 | mutex_unlock(&dev->struct_mutex); |
| 2107 | |
| 2108 | return 0; |
| 2109 | } |
| 2110 | |
| 2111 | DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, |
| 2112 | i915_ring_test_irq_get, i915_ring_test_irq_set, |
| 2113 | "0x%08llx\n"); |
| 2114 | |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2115 | #define DROP_UNBOUND 0x1 |
| 2116 | #define DROP_BOUND 0x2 |
| 2117 | #define DROP_RETIRE 0x4 |
| 2118 | #define DROP_ACTIVE 0x8 |
| 2119 | #define DROP_ALL (DROP_UNBOUND | \ |
| 2120 | DROP_BOUND | \ |
| 2121 | DROP_RETIRE | \ |
| 2122 | DROP_ACTIVE) |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2123 | static int |
| 2124 | i915_drop_caches_get(void *data, u64 *val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2125 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2126 | *val = DROP_ALL; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2127 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2128 | return 0; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2129 | } |
| 2130 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2131 | static int |
| 2132 | i915_drop_caches_set(void *data, u64 val) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2133 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2134 | struct drm_device *dev = data; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2135 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2136 | struct drm_i915_gem_object *obj, *next; |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 2137 | struct i915_address_space *vm; |
| 2138 | struct i915_vma *vma, *x; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2139 | int ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2140 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2141 | DRM_DEBUG_DRIVER("Dropping caches: 0x%08llx\n", val); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2142 | |
| 2143 | /* No need to check and wait for gpu resets, only libdrm auto-restarts |
| 2144 | * on ioctls on -EAGAIN. */ |
| 2145 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2146 | if (ret) |
| 2147 | return ret; |
| 2148 | |
| 2149 | if (val & DROP_ACTIVE) { |
| 2150 | ret = i915_gpu_idle(dev); |
| 2151 | if (ret) |
| 2152 | goto unlock; |
| 2153 | } |
| 2154 | |
| 2155 | if (val & (DROP_RETIRE | DROP_ACTIVE)) |
| 2156 | i915_gem_retire_requests(dev); |
| 2157 | |
| 2158 | if (val & DROP_BOUND) { |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 2159 | list_for_each_entry(vm, &dev_priv->vm_list, global_link) { |
| 2160 | list_for_each_entry_safe(vma, x, &vm->inactive_list, |
| 2161 | mm_list) { |
| 2162 | if (vma->obj->pin_count) |
| 2163 | continue; |
Ben Widawsky | 31a46c9 | 2013-07-31 16:59:55 -0700 | [diff] [blame] | 2164 | |
Ben Widawsky | ca191b1 | 2013-07-31 17:00:14 -0700 | [diff] [blame] | 2165 | ret = i915_vma_unbind(vma); |
| 2166 | if (ret) |
| 2167 | goto unlock; |
| 2168 | } |
Ben Widawsky | 31a46c9 | 2013-07-31 16:59:55 -0700 | [diff] [blame] | 2169 | } |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2170 | } |
| 2171 | |
| 2172 | if (val & DROP_UNBOUND) { |
Ben Widawsky | 35c20a6 | 2013-05-31 11:28:48 -0700 | [diff] [blame] | 2173 | list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list, |
| 2174 | global_list) |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2175 | if (obj->pages_pin_count == 0) { |
| 2176 | ret = i915_gem_object_put_pages(obj); |
| 2177 | if (ret) |
| 2178 | goto unlock; |
| 2179 | } |
| 2180 | } |
| 2181 | |
| 2182 | unlock: |
| 2183 | mutex_unlock(&dev->struct_mutex); |
| 2184 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2185 | return ret; |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2186 | } |
| 2187 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2188 | DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops, |
| 2189 | i915_drop_caches_get, i915_drop_caches_set, |
| 2190 | "0x%08llx\n"); |
Chris Wilson | dd624af | 2013-01-15 12:39:35 +0000 | [diff] [blame] | 2191 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2192 | static int |
| 2193 | i915_max_freq_get(void *data, u64 *val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2194 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2195 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2196 | drm_i915_private_t *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2197 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2198 | |
| 2199 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 2200 | return -ENODEV; |
| 2201 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 2202 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 2203 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2204 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2205 | if (ret) |
| 2206 | return ret; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2207 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 2208 | if (IS_VALLEYVIEW(dev)) |
| 2209 | *val = vlv_gpu_freq(dev_priv->mem_freq, |
| 2210 | dev_priv->rps.max_delay); |
| 2211 | else |
| 2212 | *val = dev_priv->rps.max_delay * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2213 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2214 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2215 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2216 | } |
| 2217 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2218 | static int |
| 2219 | i915_max_freq_set(void *data, u64 val) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2220 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2221 | struct drm_device *dev = data; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2222 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2223 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2224 | |
| 2225 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 2226 | return -ENODEV; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2227 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 2228 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 2229 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2230 | DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2231 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2232 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2233 | if (ret) |
| 2234 | return ret; |
| 2235 | |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2236 | /* |
| 2237 | * Turbo will still be enabled, but won't go above the set value. |
| 2238 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 2239 | if (IS_VALLEYVIEW(dev)) { |
| 2240 | val = vlv_freq_opcode(dev_priv->mem_freq, val); |
| 2241 | dev_priv->rps.max_delay = val; |
| 2242 | gen6_set_rps(dev, val); |
| 2243 | } else { |
| 2244 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
| 2245 | dev_priv->rps.max_delay = val; |
| 2246 | gen6_set_rps(dev, val); |
| 2247 | } |
| 2248 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2249 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2250 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2251 | return 0; |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2252 | } |
| 2253 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2254 | DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops, |
| 2255 | i915_max_freq_get, i915_max_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 2256 | "%llu\n"); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2257 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2258 | static int |
| 2259 | i915_min_freq_get(void *data, u64 *val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2260 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2261 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2262 | drm_i915_private_t *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2263 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2264 | |
| 2265 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 2266 | return -ENODEV; |
| 2267 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 2268 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 2269 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2270 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2271 | if (ret) |
| 2272 | return ret; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2273 | |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 2274 | if (IS_VALLEYVIEW(dev)) |
| 2275 | *val = vlv_gpu_freq(dev_priv->mem_freq, |
| 2276 | dev_priv->rps.min_delay); |
| 2277 | else |
| 2278 | *val = dev_priv->rps.min_delay * GT_FREQUENCY_MULTIPLIER; |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2279 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2280 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2281 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2282 | } |
| 2283 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2284 | static int |
| 2285 | i915_min_freq_set(void *data, u64 val) |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2286 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2287 | struct drm_device *dev = data; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2288 | struct drm_i915_private *dev_priv = dev->dev_private; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2289 | int ret; |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2290 | |
| 2291 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 2292 | return -ENODEV; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2293 | |
Tom O'Rourke | 5c9669c | 2013-09-16 14:56:43 -0700 | [diff] [blame] | 2294 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
| 2295 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2296 | DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2297 | |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2298 | ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock); |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2299 | if (ret) |
| 2300 | return ret; |
| 2301 | |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2302 | /* |
| 2303 | * Turbo will still be enabled, but won't go below the set value. |
| 2304 | */ |
Jesse Barnes | 0a073b8 | 2013-04-17 15:54:58 -0700 | [diff] [blame] | 2305 | if (IS_VALLEYVIEW(dev)) { |
| 2306 | val = vlv_freq_opcode(dev_priv->mem_freq, val); |
| 2307 | dev_priv->rps.min_delay = val; |
| 2308 | valleyview_set_rps(dev, val); |
| 2309 | } else { |
| 2310 | do_div(val, GT_FREQUENCY_MULTIPLIER); |
| 2311 | dev_priv->rps.min_delay = val; |
| 2312 | gen6_set_rps(dev, val); |
| 2313 | } |
Jesse Barnes | 4fc688c | 2012-11-02 11:14:01 -0700 | [diff] [blame] | 2314 | mutex_unlock(&dev_priv->rps.hw_lock); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2315 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2316 | return 0; |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2317 | } |
| 2318 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2319 | DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops, |
| 2320 | i915_min_freq_get, i915_min_freq_set, |
Mika Kuoppala | 3a3b4f9 | 2013-04-12 12:10:05 +0300 | [diff] [blame] | 2321 | "%llu\n"); |
Jesse Barnes | 1523c31 | 2012-05-25 12:34:54 -0700 | [diff] [blame] | 2322 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2323 | static int |
| 2324 | i915_cache_sharing_get(void *data, u64 *val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2325 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2326 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2327 | drm_i915_private_t *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2328 | u32 snpcr; |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2329 | int ret; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2330 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2331 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 2332 | return -ENODEV; |
| 2333 | |
Daniel Vetter | 22bcfc6 | 2012-08-09 15:07:02 +0200 | [diff] [blame] | 2334 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 2335 | if (ret) |
| 2336 | return ret; |
| 2337 | |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2338 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 2339 | mutex_unlock(&dev_priv->dev->struct_mutex); |
| 2340 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2341 | *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2342 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2343 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2344 | } |
| 2345 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2346 | static int |
| 2347 | i915_cache_sharing_set(void *data, u64 val) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2348 | { |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2349 | struct drm_device *dev = data; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2350 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2351 | u32 snpcr; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2352 | |
Daniel Vetter | 004777c | 2012-08-09 15:07:01 +0200 | [diff] [blame] | 2353 | if (!(IS_GEN6(dev) || IS_GEN7(dev))) |
| 2354 | return -ENODEV; |
| 2355 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2356 | if (val > 3) |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2357 | return -EINVAL; |
| 2358 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2359 | DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2360 | |
| 2361 | /* Update the cache sharing policy here as well */ |
| 2362 | snpcr = I915_READ(GEN6_MBCUNIT_SNPCR); |
| 2363 | snpcr &= ~GEN6_MBC_SNPCR_MASK; |
| 2364 | snpcr |= (val << GEN6_MBC_SNPCR_SHIFT); |
| 2365 | I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr); |
| 2366 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2367 | return 0; |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2368 | } |
| 2369 | |
Kees Cook | 647416f | 2013-03-10 14:10:06 -0700 | [diff] [blame] | 2370 | DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops, |
| 2371 | i915_cache_sharing_get, i915_cache_sharing_set, |
| 2372 | "%llu\n"); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2373 | |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2374 | /* As the drm_debugfs_init() routines are called before dev->dev_private is |
| 2375 | * allocated we need to hook into the minor for release. */ |
| 2376 | static int |
| 2377 | drm_add_fake_info_node(struct drm_minor *minor, |
| 2378 | struct dentry *ent, |
| 2379 | const void *key) |
| 2380 | { |
| 2381 | struct drm_info_node *node; |
| 2382 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 2383 | node = kmalloc(sizeof(*node), GFP_KERNEL); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2384 | if (node == NULL) { |
| 2385 | debugfs_remove(ent); |
| 2386 | return -ENOMEM; |
| 2387 | } |
| 2388 | |
| 2389 | node->minor = minor; |
| 2390 | node->dent = ent; |
| 2391 | node->info_ent = (void *) key; |
Marcin Slusarz | b3e067c | 2011-11-09 22:20:35 +0100 | [diff] [blame] | 2392 | |
| 2393 | mutex_lock(&minor->debugfs_lock); |
| 2394 | list_add(&node->list, &minor->debugfs_list); |
| 2395 | mutex_unlock(&minor->debugfs_lock); |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2396 | |
| 2397 | return 0; |
| 2398 | } |
| 2399 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2400 | static int i915_forcewake_open(struct inode *inode, struct file *file) |
| 2401 | { |
| 2402 | struct drm_device *dev = inode->i_private; |
| 2403 | struct drm_i915_private *dev_priv = dev->dev_private; |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2404 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 2405 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2406 | return 0; |
| 2407 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2408 | gen6_gt_force_wake_get(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2409 | |
| 2410 | return 0; |
| 2411 | } |
| 2412 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 2413 | static int i915_forcewake_release(struct inode *inode, struct file *file) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2414 | { |
| 2415 | struct drm_device *dev = inode->i_private; |
| 2416 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 2417 | |
Daniel Vetter | 075edca | 2012-01-24 09:44:28 +0100 | [diff] [blame] | 2418 | if (INTEL_INFO(dev)->gen < 6) |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2419 | return 0; |
| 2420 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2421 | gen6_gt_force_wake_put(dev_priv); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2422 | |
| 2423 | return 0; |
| 2424 | } |
| 2425 | |
| 2426 | static const struct file_operations i915_forcewake_fops = { |
| 2427 | .owner = THIS_MODULE, |
| 2428 | .open = i915_forcewake_open, |
| 2429 | .release = i915_forcewake_release, |
| 2430 | }; |
| 2431 | |
| 2432 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) |
| 2433 | { |
| 2434 | struct drm_device *dev = minor->dev; |
| 2435 | struct dentry *ent; |
| 2436 | |
| 2437 | ent = debugfs_create_file("i915_forcewake_user", |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 2438 | S_IRUSR, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2439 | root, dev, |
| 2440 | &i915_forcewake_fops); |
| 2441 | if (IS_ERR(ent)) |
| 2442 | return PTR_ERR(ent); |
| 2443 | |
Ben Widawsky | 8eb5729 | 2011-05-11 15:10:58 -0700 | [diff] [blame] | 2444 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2445 | } |
| 2446 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 2447 | static int i915_debugfs_create(struct dentry *root, |
| 2448 | struct drm_minor *minor, |
| 2449 | const char *name, |
| 2450 | const struct file_operations *fops) |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2451 | { |
| 2452 | struct drm_device *dev = minor->dev; |
| 2453 | struct dentry *ent; |
| 2454 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 2455 | ent = debugfs_create_file(name, |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2456 | S_IRUGO | S_IWUSR, |
| 2457 | root, dev, |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 2458 | fops); |
Jesse Barnes | 358733e | 2011-07-27 11:53:01 -0700 | [diff] [blame] | 2459 | if (IS_ERR(ent)) |
| 2460 | return PTR_ERR(ent); |
| 2461 | |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 2462 | return drm_add_fake_info_node(minor, ent, fops); |
Jesse Barnes | 07b7ddd | 2011-08-03 11:28:44 -0700 | [diff] [blame] | 2463 | } |
| 2464 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 2465 | static struct drm_info_list i915_debugfs_list[] = { |
Chris Wilson | 311bd68 | 2011-01-13 19:06:50 +0000 | [diff] [blame] | 2466 | {"i915_capabilities", i915_capabilities, 0}, |
Chris Wilson | 73aa808 | 2010-09-30 11:46:12 +0100 | [diff] [blame] | 2467 | {"i915_gem_objects", i915_gem_object_info, 0}, |
Chris Wilson | 08c1832 | 2011-01-10 00:00:24 +0000 | [diff] [blame] | 2468 | {"i915_gem_gtt", i915_gem_gtt_info, 0}, |
Chris Wilson | 1b50247 | 2012-04-24 15:47:30 +0100 | [diff] [blame] | 2469 | {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 2470 | {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, |
Ben Gamari | 433e12f | 2009-02-17 20:08:51 -0500 | [diff] [blame] | 2471 | {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST}, |
Chris Wilson | 6d2b888 | 2013-08-07 18:30:54 +0100 | [diff] [blame] | 2472 | {"i915_gem_stolen", i915_gem_stolen_list_info }, |
Simon Farnsworth | 4e5359c | 2010-09-01 17:47:52 +0100 | [diff] [blame] | 2473 | {"i915_gem_pageflip", i915_gem_pageflip_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2474 | {"i915_gem_request", i915_gem_request_info, 0}, |
| 2475 | {"i915_gem_seqno", i915_gem_seqno_info, 0}, |
Chris Wilson | a6172a8 | 2009-02-11 14:26:38 +0000 | [diff] [blame] | 2476 | {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2477 | {"i915_gem_interrupt", i915_interrupt_info, 0}, |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2478 | {"i915_gem_hws", i915_hws_info, 0, (void *)RCS}, |
| 2479 | {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, |
| 2480 | {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, |
Xiang, Haihao | 9010ebf | 2013-05-29 09:22:36 -0700 | [diff] [blame] | 2481 | {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 2482 | {"i915_rstdby_delays", i915_rstdby_delays, 0}, |
| 2483 | {"i915_cur_delayinfo", i915_cur_delayinfo, 0}, |
| 2484 | {"i915_delayfreq_table", i915_delayfreq_table, 0}, |
| 2485 | {"i915_inttoext_table", i915_inttoext_table, 0}, |
| 2486 | {"i915_drpc_info", i915_drpc_info, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 2487 | {"i915_emon_status", i915_emon_status, 0}, |
Jesse Barnes | 23b2f8b | 2011-06-28 13:04:16 -0700 | [diff] [blame] | 2488 | {"i915_ring_freq_table", i915_ring_freq_table, 0}, |
Jesse Barnes | 7648fa9 | 2010-05-20 14:28:11 -0700 | [diff] [blame] | 2489 | {"i915_gfxec", i915_gfxec, 0}, |
Jesse Barnes | b5e50c3 | 2010-02-05 12:42:41 -0800 | [diff] [blame] | 2490 | {"i915_fbc_status", i915_fbc_status, 0}, |
Paulo Zanoni | 92d4462 | 2013-05-31 16:33:24 -0300 | [diff] [blame] | 2491 | {"i915_ips_status", i915_ips_status, 0}, |
Jesse Barnes | 4a9bef3 | 2010-02-05 12:47:35 -0800 | [diff] [blame] | 2492 | {"i915_sr_status", i915_sr_status, 0}, |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 2493 | {"i915_opregion", i915_opregion, 0}, |
Chris Wilson | 37811fc | 2010-08-25 22:45:57 +0100 | [diff] [blame] | 2494 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
Ben Widawsky | e76d363 | 2011-03-19 18:14:29 -0700 | [diff] [blame] | 2495 | {"i915_context_status", i915_context_status, 0}, |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2496 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, |
Daniel Vetter | ea16a3c | 2011-12-14 13:57:16 +0100 | [diff] [blame] | 2497 | {"i915_swizzle_info", i915_swizzle_info, 0}, |
Daniel Vetter | 3cf17fc | 2012-02-09 17:15:49 +0100 | [diff] [blame] | 2498 | {"i915_ppgtt_info", i915_ppgtt_info, 0}, |
Jesse Barnes | 57f350b | 2012-03-28 13:39:25 -0700 | [diff] [blame] | 2499 | {"i915_dpio", i915_dpio_info, 0}, |
Ben Widawsky | 63573eb | 2013-07-04 11:02:07 -0700 | [diff] [blame] | 2500 | {"i915_llc", i915_llc, 0}, |
Rodrigo Vivi | e91fd8c | 2013-07-11 18:44:59 -0300 | [diff] [blame] | 2501 | {"i915_edp_psr_status", i915_edp_psr_status, 0}, |
Jesse Barnes | ec013e7 | 2013-08-20 10:29:23 +0100 | [diff] [blame] | 2502 | {"i915_energy_uJ", i915_energy_uJ, 0}, |
Paulo Zanoni | 371db66 | 2013-08-19 13:18:10 -0300 | [diff] [blame] | 2503 | {"i915_pc8_status", i915_pc8_status, 0}, |
Shuang He | 8bf1e9f | 2013-10-15 18:55:27 +0100 | [diff] [blame] | 2504 | {"i915_pipe_A_crc", i915_pipe_crc, 0, (void *)PIPE_A}, |
| 2505 | {"i915_pipe_B_crc", i915_pipe_crc, 0, (void *)PIPE_B}, |
| 2506 | {"i915_pipe_C_crc", i915_pipe_crc, 0, (void *)PIPE_C}, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2507 | }; |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 2508 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2509 | |
Ville Syrjälä | 2b4bd0e | 2013-08-07 15:11:52 +0300 | [diff] [blame] | 2510 | static struct i915_debugfs_files { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2511 | const char *name; |
| 2512 | const struct file_operations *fops; |
| 2513 | } i915_debugfs_files[] = { |
| 2514 | {"i915_wedged", &i915_wedged_fops}, |
| 2515 | {"i915_max_freq", &i915_max_freq_fops}, |
| 2516 | {"i915_min_freq", &i915_min_freq_fops}, |
| 2517 | {"i915_cache_sharing", &i915_cache_sharing_fops}, |
| 2518 | {"i915_ring_stop", &i915_ring_stop_fops}, |
Chris Wilson | 094f9a5 | 2013-09-25 17:34:55 +0100 | [diff] [blame] | 2519 | {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, |
| 2520 | {"i915_ring_test_irq", &i915_ring_test_irq_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2521 | {"i915_gem_drop_caches", &i915_drop_caches_fops}, |
| 2522 | {"i915_error_state", &i915_error_state_fops}, |
| 2523 | {"i915_next_seqno", &i915_next_seqno_fops}, |
Daniel Vetter | 926321d | 2013-10-16 13:30:34 +0200 | [diff] [blame] | 2524 | {"i915_pipe_crc_ctl", &i915_pipe_crc_ctl_fops}, |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2525 | }; |
| 2526 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 2527 | int i915_debugfs_init(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2528 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2529 | int ret, i; |
Chris Wilson | f3cd474 | 2009-10-13 22:20:20 +0100 | [diff] [blame] | 2530 | |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2531 | ret = i915_forcewake_create(minor->debugfs_root, minor); |
| 2532 | if (ret) |
| 2533 | return ret; |
Daniel Vetter | 6a9c308 | 2011-12-14 13:57:11 +0100 | [diff] [blame] | 2534 | |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2535 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 2536 | ret = i915_debugfs_create(minor->debugfs_root, minor, |
| 2537 | i915_debugfs_files[i].name, |
| 2538 | i915_debugfs_files[i].fops); |
| 2539 | if (ret) |
| 2540 | return ret; |
| 2541 | } |
Mika Kuoppala | 4063321 | 2012-12-04 15:12:00 +0200 | [diff] [blame] | 2542 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 2543 | return drm_debugfs_create_files(i915_debugfs_list, |
| 2544 | I915_DEBUGFS_ENTRIES, |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2545 | minor->debugfs_root, minor); |
| 2546 | } |
| 2547 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 2548 | void i915_debugfs_cleanup(struct drm_minor *minor) |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2549 | { |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2550 | int i; |
| 2551 | |
Ben Gamari | 27c202a | 2009-07-01 22:26:52 -0400 | [diff] [blame] | 2552 | drm_debugfs_remove_files(i915_debugfs_list, |
| 2553 | I915_DEBUGFS_ENTRIES, minor); |
Ben Widawsky | 6d794d4 | 2011-04-25 11:25:56 -0700 | [diff] [blame] | 2554 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, |
| 2555 | 1, minor); |
Daniel Vetter | 34b9674 | 2013-07-04 20:49:44 +0200 | [diff] [blame] | 2556 | for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { |
| 2557 | struct drm_info_list *info_list = |
| 2558 | (struct drm_info_list *) i915_debugfs_files[i].fops; |
| 2559 | |
| 2560 | drm_debugfs_remove_files(info_list, 1, minor); |
| 2561 | } |
Ben Gamari | 2017263 | 2009-02-17 20:08:50 -0500 | [diff] [blame] | 2562 | } |
| 2563 | |
| 2564 | #endif /* CONFIG_DEBUG_FS */ |